How to use the hast-util-select.select 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 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 / 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
    .selectAll('.vendor-list > ul > li > .vendor-container', tree)
    .forEach(one)
github wooorm / checkmoji / build.js View on Github external
function oncategory(err, res, body) {
  bail(err)

  var tree = proc.parse(body)

  debug('Category: %s', collapse(toString(query.select('h1', tree))).trim())

  query.selectAll('.emoji-list a', tree).forEach(get)
}
github wooorm / svg-element-attributes / build.js View on Github external
function each(node) {
      q.selectAll('.element', node)
        .map(toString)
        .forEach(add(map, toString(q.select('.attribute-name', node))))
    }
  }
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
    .selectAll('.vendor-list > ul > li > .vendor-container', tree)
github wooorm / checkmoji / build.js View on Github external
function one(node) {
    var platform = collapse(toString(query.select('.vendor-info', node))).trim()
    var img = query.select('.vendor-image img', node).properties.src
    var pid = platform.toLowerCase().replace(/\s+/g, '')
    var dir = path.join('src', 'image', pid)

    entry.platforms.push(pid)

    if (!(pid in platforms)) {
      platforms[pid] = platform

      try {
        fs.mkdirSync(dir)
      } catch (error) {
        if (error.code !== 'EEXIST') {
          bail(error)
        }
      }
    }
github wooorm / checkmoji / build.js View on Github external
function one(node) {
    var platform = collapse(toString(query.select('.vendor-info', node))).trim()
    var img = query.select('.vendor-image img', node).properties.src
    var pid = platform.toLowerCase().replace(/\s+/g, '')
    var dir = path.join('src', 'image', pid)

    entry.platforms.push(pid)

    if (!(pid in platforms)) {
      platforms[pid] = platform

      try {
        fs.mkdirSync(dir)
      } catch (error) {
        if (error.code !== 'EEXIST') {
          bail(error)
        }
      }
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
    .selectAll('.vendor-list > ul > li > .vendor-container', tree)
    .forEach(one)

hast-util-select

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

MIT
Latest version published 25 days ago

Package Health Score

84 / 100
Full package analysis

Popular hast-util-select functions