Network Performance Monitor
    Wondering what’s next for npm?Check out our public roadmap! »

    micromark-extension-gfm-autolink-literal
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    micromark-extension-gfm-autolink-literal

    Build Coverage Downloads Size Sponsors Backers Chat

    micromark extension to support GitHub flavored markdown (GFM) literal autolinks.

    This syntax extension matches the GFM spec and how literal autolinks work in several places on github.com. GitHub employs two algorithms to autolink: one at parse time and one at transform time (similar to how @mentions are done at transform time). This difference can be observed because character references and escapes are handled differently. But also because issues/PRs/comments omit (perhaps by accident?) the second algorithm for www., http://, and https:// links (but not for email links).

    As this is a syntax extension, it focuses on the first algorithm. The html part of this extension does not operate on an AST and hence can’t perform the second algorithm. mdast-util-gfm-autolink-literal adds support for the second.

    When to use this

    You should probably use micromark-extension-gfm, which combines this package with other GFM features, instead. Alternatively, if you don’t want all of GFM, use this package.

    Install

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

    npm:

    npm install micromark-extension-gfm-autolink-literal

    Use

    import {micromark} from 'micromark'
    import {
      gfmAutolinkLiteral,
      gfmAutolinkLiteralHtml
    } from 'micromark-extension-gfm-autolink-literal'
    
    const output = micromark('Just a URL: www.example.com.', {
      extensions: [gfmAutolinkLiteral],
      htmlExtensions: [gfmAutolinkLiteralHtml]
    })
    
    console.log(output)

    Yields:

    <p>Just a URL: <a href="http://www.example.com">www.example.com</a>.</p>

    API

    This package exports the following identifiers: gfmAutolinkLiteral, gfmAutolinkLiteralHtml. There is no default export.

    The export map supports the endorsed development condition. Run node --conditions development module.js to get instrumented dev code. Without this condition, production code is loaded.

    gfmAutolinkLiteral

    gfmAutolinkLiteralHtml

    An extension for the micromark parser (to parse; can be passed in extensions) and one for the HTML compiler (to compile as <a> elements; can be passed in htmlExtensions).

    Related

    Contribute

    See contributing.md in micromark/.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.

    License

    MIT © Titus Wormer

    Install

    npm i micromark-extension-gfm-autolink-literal

    DownloadsWeekly Downloads

    230,165

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    41.3 kB

    Total Files

    15

    Last publish

    Collaborators

    • avatar