Skip to content

How to use rehype-external-links with micromark #132

Discussion options

You must be logged in to vote

Usage would go through remark (which wraps micromark) and rehype.
For example https://github.com/rehypejs/rehype-external-links#use

import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeExternalLinks from 'rehype-external-links'
import rehypeStringify from 'rehype-stringify'

const file = await unified()
  .use(remarkParse)
  .use(remarkRehype)
  .use(rehypeExternalLinks, {rel: ['nofollow']})
  .use(rehypeStringify)
  .process('[rehype](https://github.com/rehypejs/rehype)')

console.log(String(file))

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jespertheend
Comment options

@jespertheend
Comment options

Answer selected by jespertheend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants