How to use the htmlparser2.DomUtils.find function in htmlparser2

To help you get started, we’ve selected a few htmlparser2 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 realywithoutname / mini-program-webpack-loader / src / classes / Wxml.js View on Github external
usedComponents () {
    let tags = []
    DomUtils.find((el) => {
      let { name, attribs = {} } = el

      // 记录所有非原生组件名
      if (name && !isNativeTag(name)) {
        tags.push(name)
      }

      let attrKeys = Object.keys(attribs)

      /**
       * 使用自定义组件是抽象组件
       */
      if (/generic:/.test(attrKeys.join(';'))) {
        attrKeys.forEach(key => {
          /generic:/.test(key) && tags.push(attribs[key])
        })
github hexojs / hexo-util / lib / toc_obj.js View on Github external
function tocObj(str, options = {}) {
  options = Object.assign({
    min_depth: 1,
    max_depth: 6
  }, options);

  const headingsSelector = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].slice(options.min_depth - 1, options.max_depth).join(',');

  const dom = parseHtml(str);
  const headings = DomUtils.find(el => headingsSelector.includes(el.tagName), dom, true);

  const result = [];

  if (!headings.length) return result;

  for (const el of headings) {
    const level = +el.name[1];
    const id = getId(el);
    const text = escapeHTML(DomUtils.getText(el));

    result.push({ text, id, level });
  }

  return result;
}
github isleofcode / corber / lib / tasks / add-cordova-js.js View on Github external
const scriptElementExists = function(dom) {
  return DomUtils.find(function(element) {
    return element.type === 'script' && element.attribs.src === 'cordova.js';
  }, dom, true, 1).length > 0;
};
github isleofcode / corber / lib / tasks / add-cordova-js.js View on Github external
const getBodyElement = function(dom) {
  return DomUtils.find(function(element) {
    return element.type === 'tag' && element.name === 'body';
  }, dom, true, 1)[0];
};
github realywithoutname / mini-program-webpack-loader / src / helpers / wxml-parser.js View on Github external
module.exports.find = function find (content, test) {
  let dom = parseDOM(content, {
    recognizeSelfClosing: true,
    lowerCaseAttributeNames: false
  })
  DomUtils.find(test, dom, true)
  return dom
}
github realywithoutname / mini-program-webpack-loader / src / helpers / wxml.js View on Github external
static find (content, callback) {
    let dom = parseDOM(content, {
      recognizeSelfClosing: true,
      lowerCaseAttributeNames: false
    })
    DomUtils.find(callback, dom, true)
    return dom
  }