Project: syntax-tree/mdast-util-gfm-autolink-literal

Package: mdast-util-gfm-autolink-literal@1.0.1

  1. Dependents: 4
  2. mdast extension to parse and serialize GFM autolink literals
  1. util 143
  2. utility 139
  3. markdown 131
  4. unist 127
  5. mdast 85
  6. mdast-util 30
  7. markup 18
  8. gfm 18
  9. link 15
  10. url 13
  11. autolink 5
  12. auto 4
  13. literal 4
  14. raw 3


Build Coverage Downloads Size Sponsors Backers Chat

Extension for mdast-util-from-markdown and/or mdast-util-to-markdown to support GitHub flavored markdown autolink literals in mdast. When parsing (from-markdown), must be combined with micromark-extension-gfm-autolink-literal.

When to use this

Use mdast-util-gfm if you want all of GFM. Use this otherwise.


This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.


npm install mdast-util-gfm-autolink-literal


Say our module, example.js, looks as follows:

import {fromMarkdown} from 'mdast-util-from-markdown'
import {toMarkdown} from 'mdast-util-to-markdown'
import {gfmAutolinkLiteral} from 'micromark-extension-gfm-autolink-literal'
import {gfmAutolinkLiteralFromMarkdown, gfmAutolinkLiteralToMarkdown} from 'mdast-util-gfm-autolink-literal'

const doc = 'www.example.com, https://example.com, and contact@example.com.'

const tree = fromMarkdown(doc, {
  extensions: [gfmAutolinkLiteral],
  mdastExtensions: [gfmAutolinkLiteralFromMarkdown]


const out = toMarkdown(tree, {extensions: [gfmAutolinkLiteralToMarkdown]})


Now, running node example yields:

  type: 'root',
  children: [
      type: 'paragraph',
      children: [
          type: 'link',
          title: null,
          url: 'http://www.example.com',
          children: [{type: 'text', value: 'www.example.com'}]
        {type: 'text', value: ', '},
          type: 'link',
          title: null,
          url: 'https://example.com',
          children: [{type: 'text', value: 'https://example.com'}]
        {type: 'text', value: ', and '},
          type: 'link',
          title: null,
          url: 'mailto:contact@example.com',
          children: [{type: 'text', value: 'contact@example.com'}]
        {type: 'text', value: '.'}
[www.example.com](http://www.example.com), <https://example.com>, and <contact@example.com>.




Support literal autolinks. The exports are extensions, respectively for mdast-util-from-markdown and mdast-util-to-markdown.


See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Titus Wormer