Parses the received HTML code.
<p>
The resulting object can be used on the other methods. Only the content
of the {@code <body>} tag will be parsed.

@param html
HTML to parse
@return the parsed HTML body
324149
public final Element parse(final String html) {
        checkNotNull(html, "Received a null pointer as body");

        return Jsoup.parse(html).body();
    }
1261448
public MailBuilder content(Body body) {
        return text(body.text()).html(body.html());
    }
1346411
protected IScriptReporter getHtmlTag(ServletRequest req)
    {
        Html html = (Html) req.getAttribute(Html.HTML_TAG_ID);
        if (html != null && html instanceof IScriptReporter)
            return (IScriptReporter) html;
        return null;
    }
725558
function parseHTML(html) {
	var temp = [];

	function push(code, type, padding) {
		code = code.replace(/\n/g, '');
		if (padding) {
			temp.push({code: code, type: type, padding: padding});
		} else {
			temp.push({code: code, type: type});
		}
	}

	function dig(nodes) {
		for (var i = 0; i < nodes.length; i ++) {
			var node = nodes[i];
			switch (node.type) {
				case 'comment':
				break;

				case 'text':
				var words = trim(node.raw).split(' ');
				for (var j = 0, jj = words.length; j < jj; j++) {
					push(words[j] + (j + 1 == jj ? '' : ' '), 'text');
				}
				break;

				case 'directive':
				push('<' + node.raw + '>', 'tag');
				break;

				default:
				var tag = node.name;
				var attribs = node.attribs || {};

				push('<' + tag, 'tag', paddingHTML);
				for (var key in attribs) {
					push(' ' + key + '="' + attribs[key] + '"', 'tag', paddingHTML);
				}
				push('>', 'tag');

				switch (tag) {
					case 'br':
					case 'input':
					case 'hr':
					case 'link':
					case 'meta':
					case 'img':
					case 'embed':
					case 'param':
					case 'area':
					case 'base':
					case 'col':
					case 'keygen':
					case 'source':
					continue;

					case 'script':
					if ((!attribs.type || attribs.type == 'text/javascript') && node.children && node.children[0]) {
						temp = temp.concat(parseJS(node.children[0].raw));
					}
					break;

					case 'style':
					if ((!attribs.type || attribs.type == 'text/css') && node.children && node.children[0]) {
						temp = temp.concat(parseCSS(node.children[0].raw));
					}
					break;

					default:
					if (node.children) dig(node.children);
				}

				push('</' + tag + '>', 'tag')
			}
		}
	}

	var handler = new htmlparser.DefaultHandler(function (error, dom) {});
	new htmlparser.Parser(handler).parseComplete(html);
	dig(handler.dom);

	var nodes = [];
	for (var i = 0, j = 0, ii = temp.length, lastType; i < ii; i++) {
		var tmp = temp[i];
		if (i && (lastType == tmp.type || !tmp.type)) {
			nodes[++j] = tmp;
		} else {
			if (!nodes[j]) {
				nodes[j] = tmp;
			} else {
				nodes[j].code += tmp.code;
				nodes[j].padding = tmp.padding;
			}
		}
		lastType = tmp.type;
	}
	return nodes;
}
369801
public function parse(string $html): string
    {
        $html = ltrim($html);
        $this->setTokenPosition($html);

        try {
            $this->name = $this->parseElementName($html);
            $remainingHtml = $this->parseAttributes($html);
            $posOfClosingBracket = $this->getPositionOfElementEndTag($remainingHtml);

            // Is self-closing?
            $posOfSelfClosingBracket = \mb_strpos($remainingHtml, '/>');
            $remainingHtml = \mb_substr($remainingHtml, $posOfClosingBracket + 1);
            if ($posOfSelfClosingBracket !== false && $posOfSelfClosingBracket === $posOfClosingBracket - 1) {
                // Self-closing element. (Note: $this->valuue is unchanged.)
                return $remainingHtml;
            }

            // Lets close those closed-only elements that are left open.
            if (\in_array($this->name, self::VOID_ELEMENTS, true)) {
                return $remainingHtml;
            }

            // Open element.
            return $this->parseContents($remainingHtml);
        } catch (ParseException $e) {
            if ($this->getThrowOnError()) {
                throw $e;
            }
        }

        return '';
    }
1076826
public static List<Node> parse(String html) {
    HtmlParser parser = new HtmlParser(html);
    return parser.parse();
  }
696943
public boolean parse(final boolean fragment) throws FrameworkException {

		init();

		if (StringUtils.isNotBlank(code)) {

			if (!isDeployment) {
				logger.info("##### Start parsing code for page {} #####", new Object[]{name});
			} else {

				// a trailing slash to all void/self-closing tags so the XML parser can parse it correctly
				code = code.replaceAll("<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)([^>]*)>", "<$1$2/>");
			}

			if (fragment) {

				if (isDeployment) {

					final List<Node> nodeList = Parser.parseXmlFragment(code, "");
					parsedDocument            = Document.createShell("");
					final Element body        = parsedDocument.body();
					final Node[] nodes        = nodeList.toArray(new Node[nodeList.size()]);

					for (int i = nodes.length - 1; i > 0; i--) {
					    nodes[i].remove();
					}

					for (Node node : nodes) {
					    body.appendChild(node);
					}

				} else {

					parsedDocument = Jsoup.parseBodyFragment(code);
				}

			} else {

				if (isDeployment) {

					parsedDocument = Jsoup.parse(code, "", Parser.xmlParser());

				} else {

					parsedDocument = Jsoup.parse(code);
				}

			}

		} else {

			if (!isDeployment) {
				logger.info("##### Start fetching {} for page {} #####", new Object[]{address, name});
			}

			code = HttpHelper.get(address);
			parsedDocument = Jsoup.parse(code);

		}

		return true;

	}
1353122
function parseHtml(html, sourceCodeStore) {
    const isFragment = !/^\s*<(!doctype|html|head|body|!--)/iu.test(html)
    const document = (isFragment ? parse5.parseFragment : parse5.parse)(html, {
        sourceCodeLocationInfo: true,
    })

    return parse5NodeToToken(document, null, html, sourceCodeStore, html.length)
}
1175161
def parse(html):
    
    if not html:
        return html, []

    parser = HTMLToTelegramParser()
    parser.feed(_add_surrogate(html))
    text = helpers.strip_text(parser.text, parser.entities)
    return _del_surrogate(text), parser.entities
1196240
public static String unescapeHtml4(String html) {
		Html4Unescape unescape = new Html4Unescape();
		return unescape.replace(html).toString();
	}
751066
public static byte[] process(CharSequence html) {
		ByteArrayOutputStream baos = null;
		try {
			baos = new ByteArrayOutputStream();
			process(html, baos);
			return baos.toByteArray();
		}
		finally {
			if (baos != null) {
				try {
					baos.close();
				}
				catch (IOException e) {
					log.warn("Close Byte Array Inpout Stream Error Caused.", e);
				}
			}
		}
	}
1080049
public static HtmlTree CODE(Content body) {
        HtmlTree htmltree = new HtmlTree(HtmlTag.CODE, nullCheck(body));
        return htmltree;
    }
1043351
public static HtmlTree TITLE(Content body) {
        HtmlTree htmltree = new HtmlTree(HtmlTag.TITLE, nullCheck(body));
        return htmltree;
    }
947661
public static String htmlDecode(final String encodedHtml) {
        validate(encodedHtml, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        String[] entities = encodedHtml.split("&\\W+;");
        return Arrays.stream(entities).map(e -> HtmlEntities.decodedEntities.get(e)).collect(joining());
    }
654363
public function parse($html)
    {
        $this->logger->info('*** Starting parse process...');

        $this->dom = $this->loadHTML($html);

        // Checking for minimum HTML to work with.
        if (!($root = $this->dom->getElementsByTagName('body')->item(0)) || !$root->firstChild) {
            $this->logger->emergency('No body tag present or body tag empty');

            throw new ParseException('Invalid or incomplete HTML.');
        }

        $this->getMetadata();

        $this->getMainImage();

        while (true) {
            $root = $root->firstChild;

            $elementsToScore = $this->getNodes($root);
            $this->logger->debug(sprintf('Elements to score: \'%s\'', count($elementsToScore)));

            $result = $this->rateNodes($elementsToScore);

            /*
             * Now that we've gone through the full algorithm, check to see if
             * we got any meaningful content. If we didn't, we may need to re-run
             * grabArticle with different flags set. This gives us a higher likelihood of
             * finding the content, and the sieve approach gives us a higher likelihood of
             * finding the -right- content.
             */

            $length = mb_strlen(preg_replace(NodeUtility::$regexps['onlyWhitespace'], '', $result->textContent));

            $this->logger->info(sprintf('[Parsing] Article parsed. Amount of words: %s. Current threshold is: %s', $length, $this->configuration->getCharThreshold()));

            if ($result && $length < $this->configuration->getCharThreshold()) {
                $this->dom = $this->loadHTML($html);
                $root = $this->dom->getElementsByTagName('body')->item(0);

                if ($this->configuration->getStripUnlikelyCandidates()) {
                    $this->logger->debug('[Parsing] Threshold not met, trying again setting StripUnlikelyCandidates as false');
                    $this->configuration->setStripUnlikelyCandidates(false);
                    $this->attempts[] = ['articleContent' => $result, 'textLength' => $length];
                } elseif ($this->configuration->getWeightClasses()) {
                    $this->logger->debug('[Parsing] Threshold not met, trying again setting WeightClasses as false');
                    $this->configuration->setWeightClasses(false);
                    $this->attempts[] = ['articleContent' => $result, 'textLength' => $length];
                } elseif ($this->configuration->getCleanConditionally()) {
                    $this->logger->debug('[Parsing] Threshold not met, trying again setting CleanConditionally as false');
                    $this->configuration->setCleanConditionally(false);
                    $this->attempts[] = ['articleContent' => $result, 'textLength' => $length];
                } else {
                    $this->logger->debug('[Parsing] Threshold not met, searching across attempts for some content.');
                    $this->attempts[] = ['articleContent' => $result, 'textLength' => $length];

                    // No luck after removing flags, just return the longest text we found during the different loops
                    usort($this->attempts, function ($a, $b) {
                        return $a['textLength'] < $b['textLength'];
                    });

                    // But first check if we actually have something
                    if (!$this->attempts[0]['textLength']) {
                        $this->logger->emergency('[Parsing] Could not parse text, giving up :(');

                        throw new ParseException('Could not parse text.');
                    }

                    $this->logger->debug('[Parsing] Threshold not met, but found some content in previous attempts.');

                    $result = $this->attempts[0]['articleContent'];
                    break;
                }
            } else {
                break;
            }
        }

        $result = $this->postProcessContent($result);

        // If we haven't found an excerpt in the article's metadata, use the article's
        // first paragraph as the excerpt. This can be used for displaying a preview of
        // the article's content.
        if (!$this->getExcerpt()) {
            $this->logger->debug('[Parsing] No excerpt text found on metadata, extracting first p node and using it as excerpt.');
            $paragraphs = $result->getElementsByTagName('p');
            if ($paragraphs->length > 0) {
                $this->setExcerpt(trim($paragraphs->item(0)->textContent));
            }
        }

        $this->setContent($result);

        $this->logger->info('*** Parse successful :)');

        return true;
    }
786787
public Example parse( String html )
    {
        String text = removeComments( html );

		return doParse(text);
    }
545476
public int doEndTag() throws JspException {
        // Get body content (trim is CRUCIAL, as some XML parsers are picky...)
        String body = bodyContent.getString().trim();

        // Do transformation
        transform(new StreamSource(new ByteArrayInputStream(body.getBytes())));

        return super.doEndTag();
    }