How to use remark-rehype - 1 common examples

To help you get started, we’ve selected a few remark-rehype 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 logux / logux.io / scripts / steps / build-api.js View on Github external
function toHtml (parent, tree) {
  if (!tree) return []
  unistVisit(tree, 'link', node => {
    if (/^[\w#.]+$/.test(node.url)) {
      let ref = node.children[0].value
      if (ref.startsWith('#')) {
        if (!parent) throw new Error(`Unknown parent for ${ ref }`)
        ref = parent + ref
      }
      node.url = '#' + toSlug(ref.replace(/#/g, '-'))
    }
  })
  return remarkRehype()(tree).children
}

remark-rehype

remark plugin that turns markdown into HTML to support rehype

MIT
Latest version published 3 months ago

Package Health Score

81 / 100
Full package analysis

Popular remark-rehype functions