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

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

  1. Dependencies: 3·Dependents: 4
  2. mdast extension to parse and serialize GFM autolink literals
  1. markdown 142
  2. util 128
  3. utility 124
  4. unist 120
  5. mdast 89
  6. mdast-util 29
  7. gfm 18
  8. markup 17
  9. link 15
  10. url 11
  11. autolink 4
  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.

You might want to use this package through remark-gfm with remark.



npm install mdast-util-gfm-autolink-literal


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

var fromMarkdown = require('mdast-util-from-markdown')
var toMarkdown = require('mdast-util-to-markdown')
var syntax = require('micromark-extension-gfm-autolink-literal')
var autolinkLiteral = require('mdast-util-gfm-autolink-literal')

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

var tree = fromMarkdown(doc, {
  extensions: [syntax],
  mdastExtensions: [autolinkLiteral.fromMarkdown]


var out = toMarkdown(tree, {extensions: [autolinkLiteral.toMarkdown]})


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>.




Note: the separate extensions are also available at mdast-util-gfm-autolink-literal/from-markdown and mdast-util-gfm-autolink-literal/to-markdown.

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