How to use the cheerio/lib/utils.isHtml function in cheerio

To help you get started, we’ve selected a few cheerio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airbnb / enzyme / packages / enzyme / src / Utils.js View on Github external
export function loadCheerioRoot(html) {
  if (!html) {
    return cheerio.root();
  }

  if (!isHtml(html)) {
    // use isDocument=false to create fragment
    return cheerio.load(html, null, false).root();
  }

  return cheerio.load('')(html);
}
github Enalean / tuleap / tools / utils / scripts / gettext / extract.js View on Github external
_parseElement($, el, filename, content) {
        if (el.type === "comment" && cheerioUtils.isHtml(el.data)) {
            // Recursive parse call if el.data is recognized as HTML.
            return this._extractTranslationDataFromNodes(
                Array.from($(el.data)),
                $,
                filename,
                content
            );
        }

        const reference = new exports.TranslationReference(filename, content, el.startIndex);
        const node = $(el);

        if (this._hasTranslationToken(node)) {
            const text = node.html().trim();
            if (text.length !== 0) {
                return [
github Polyconseil / easygettext / src / extract.js View on Github external
_parseElement($, el, filename, content) {
    if (el.type === 'comment' && cheerioUtils.isHtml(el.data)) {
      // Recursive parse call if el.data is recognized as HTML.
      return this._extractTranslationDataFromNodes(Array.from($(el.data)), $, filename, content);
    }

    const reference = new exports.TranslationReference(filename, content, el.startIndex);
    const node = $(el);

    if (this._hasTranslationToken(node)) {
      const text = this._getNodeHTML(node)

      if (text.length !== 0) {
        return [new exports.NodeTranslationInfo(node, text, reference, this.options.attributes)];
      }
    }

    // In-depth search for filters