How to use hast-util-select - 10 common examples

To help you get started, we’ve selected a few hast-util-select 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 words / buzzwords / build.js View on Github external
function onconcat(buf) {
  var tree = unified()
    .use(parse)
    .parse(buf)

  var values = selectAll('#mw-content-text > ul li, .columns > ul li', tree)
    .map(function(node) {
      return toString(node.children[0])
    })
    .map(function(value) {
      // Split comment from buzzword.
      var match = value.match(/^([\s\S+]+?)( [-–/] ?|\(|,)/)

      if (match) {
        value = match[1]
      }

      // Remove abbreviation from buzzword.
      value = value.replace(/^[A-Z]+[-–/] /, '')

      // Remove multiple cases.
      value = value.replace(/\/\w.+/, '')
github wooorm / html-element-attributes / build.js View on Github external
function onconcat(buf) {
    var nodes = q.selectAll('#attributes-1 tbody tr', processor.parse(buf))

    // Throw if we didn’t match, e.g., when the spec updates.
    if (nodes.length === 0) {
      throw new Error('Missing results in html')
    }

    nodes.forEach(each)

    done()
  }
github freeCodeCamp / freeCodeCamp / tools / challenge-md-parser / solution-to-data.js View on Github external
function visitor(node) {
      if (sectionFilter(node, 'solution')) {
        const solutions = selectAll('code', node).map(
          element => element.children[0].value
        );
        file.data = {
          ...file.data,
          solutions
        };
      }
    }
    visit(tree, 'element', visitor);
github wooorm / html-element-attributes / build.js View on Github external
function each(node) {
    var name = q.select('[title="Name"]', node)
    var elements = q.select('[title="Related Elements"]', node)

    if (!name || !elements) {
      return
    }

    name = trim(toString(name))
    elements = toString(elements)

    if (!name || ev(name)) {
      return
    }

    if (/All elements/.test(elements)) {
      elements = ['*']
    } else {
github wooorm / html-element-attributes / build.js View on Github external
function each(node) {
    var name = q.select('[title="Name"]', node)
    var elements = q.select('[title="Related Elements"]', node)

    if (!name || !elements) {
      return
    }

    name = trim(toString(name))
    elements = toString(elements)

    if (!name || ev(name)) {
      return
    }

    if (/All elements/.test(elements)) {
      elements = ['*']
    } else {
      elements = elements.split(/,/g)
github wooorm / svg-element-attributes / build.js View on Github external
function each(node) {
      var elements = q.selectAll('.element-name', node)

      q.selectAll('.attr-name', node).forEach(every)

      function every(name) {
        elements
          .map(toString)
          .map(clean)
          .forEach(add(map, clean(toString(name))))
      }
    }
github wooorm / html-tag-names / build.js View on Github external
function onconcat(buf) {
    selectAll('tbody th code', proc.parse(buf)).forEach(each)

    done()
  }
github ChristianMurphy / selective / @selective / lint / lint.js View on Github external
rule(`selective:${name}`, (tree, file) => {
      const matches = selectAll(selector, tree);

      if (matches.length > 0) {
        for (const match of matches) {
          file.message(description, match.position);
        }
      }
    })
  );
github wooorm / svg-element-attributes / build.js View on Github external
function onconcat(buf) {
    var tree = proc.parse(buf)
    var map = {}
    var nodes = q.selectAll('.property-table tr', tree)

    if (nodes.length === 0) {
      throw new Error('Couldn’t find rows in SVG 1')
    }

    nodes.forEach(each)

    done(map)

    function each(node) {
      var elements = q.selectAll('.element-name', node)

      q.selectAll('.attr-name', node).forEach(every)

      function every(name) {
        elements
github wooorm / svg-tag-names / build.js View on Github external
function onconcat(buf) {
  selectAll('.element-name', proc.parse(buf)).forEach(add)

  count++

  if (count === urls.length) {
    fs.writeFile('index.json', JSON.stringify(list.sort(), 0, 2) + '\n', bail)
  }

  function add(node) {
    var data = toString(node).slice(1, -1)

    if (data && list.indexOf(data) === -1) {
      list.push(data)
    }
  }
}

hast-util-select

hast utility for `querySelector`, `querySelectorAll`, and `matches`

MIT
Latest version published 23 days ago

Package Health Score

84 / 100
Full package analysis

Popular hast-util-select functions