How to use the hast-util-select.selectAll function in hast-util-select

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 / 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)
    }
  }
}
github wooorm / html-void-elements / build.js View on Github external
function onconcat(buf) {
  var dl = q.select('#elements-2 ~ dl dd', proc.parse(buf))

  q.selectAll('code', dl).forEach(each)

  fs.writeFile('index.json', JSON.stringify(list.sort(), 0, 2) + '\n', bail)
}
github wooorm / checkmoji / build.js View on Github external
function onemoji(err, res, body) {
  bail(err)

  var tree = proc.parse(body)
  var related = query.selectAll('.emoji-list > li > a', tree)
  var emoji = query.select('#emoji-copy', tree).properties.value
  var title = query.select('h1', tree)
  var id = query
    .select('[property="og:url"]', tree)
    .properties.content.slice(1, -1)
  var entry = {
    id: id,
    title: collapse(toString(title.children[title.children.length - 1])).trim(),
    platforms: []
  }

  data[emoji] = entry

  debug('Emoji: %s (%s, %s)', entry.id, emoji, entry.title)

  query

hast-util-select

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

MIT
Latest version published 6 months ago

Package Health Score

70 / 100
Full package analysis

Popular hast-util-select functions