mdast-util-gfm-autolink-literal

mdast extension to parse and serialize GitHub-Flavored-Markdown autolink literals

Library
npm
v2.0.1
16stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
34/100Needs Attention
Development Activity24
Maintenance24
Community16
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
70/100Good
Architecture78
Code Quality85
Innovation60
Learning Curve55

mdast-util-gfm-autolink-literal adds GitHub Flavored Markdown (GFM) autolink-literal support to the mdast/unified ecosystem: bare URLs, www. links, and email addresses written as plain text get recognized and turned into proper link nodes in the syntax tree, and serialized back out to matching markdown. It exports two extensions, gfmAutolinkLiteralFromMarkdown for mdast-util-from-markdown and gfmAutolinkLiteralToMarkdown for mdast-util-to-markdown, mirroring GitHub’s own two-pass autolinking behavior (a parse-time algorithm and a stricter transform-time algorithm applied to issues/PRs/comments).

It is one of many small, single-purpose packages maintained under the syntax-tree/unified/remark collective, designed to be composed rather than used standalone — it must be paired with micromark-extension-gfm-autolink-literal for parsing, and is typically pulled in transitively via mdast-util-gfm or remark-gfm rather than installed directly by most end users.

What You Get

  • gfmAutolinkLiteralFromMarkdown() extension for mdast-util-from-markdown, converting GFM autolink literals into mdast link nodes
  • gfmAutolinkLiteralToMarkdown() extension for mdast-util-to-markdown, serializing those link nodes back into GFM-compatible markdown
  • Faithful reproduction of GitHub’s two-pass autolinking behavior (parse-time vs. transform-time algorithms)
  • Full TypeScript types generated from JSDoc, with 100% enforced type coverage
  • Zero-config composability with mdast-util-gfm, remark-gfm, and the wider unified toolchain

Common Use Cases

  • Building a custom remark/unified markdown processing pipeline that needs GFM-compliant autolink handling without pulling in all of GFM
  • Rendering GitHub-flavored markdown content (issues, comments, READMEs) accurately outside of GitHub itself
  • Powering static site generators or CMSs that convert markdown to HTML and need bare URLs/emails linkified per GFM rules
  • Serializing a programmatically-modified mdast tree back to markdown while preserving autolink literal syntax

Under The Hood

Architecture - lib/index.js (292 lines) defines two extension factories: gfmAutolinkLiteralFromMarkdown, which registers enter/exit handlers for literalAutolink, literalAutolinkEmail, literalAutolinkHttp, and literalAutolinkWww token types plus a transforms pass that runs mdast-util-find-and-replace over already-built phrasing content to catch GitHub’s second-pass transform-time autolinking; and gfmAutolinkLiteralToMarkdown, which serializes link nodes back to literal-autolink markdown when they match the original literal shape.

Tech Stack - Plain ESM JavaScript with JSDoc-based TypeScript types (@import comments referencing mdast-util-from-markdown/to-markdown/mdast types), built with tsc --build and type-coverage enforcing 100% strict type coverage; runtime dependencies are all narrowly-scoped syntax-tree utilities (ccount, devlop, mdast-util-find-and-replace, micromark-util-character).

Code Quality - test/index.js (495 lines) runs under both development and production Node conditions via c8 --100, enforcing full statement coverage; the package also runs xo linting and remark-preset-wooorm formatting as part of its build/test pipeline, reflecting the syntax-tree collective’s consistently rigorous package standards.

API Design - The two-extension-factory pattern (fromMarkdown()/toMarkdown()) matches the conventions used across every other mdast-util-* and micromark-extension-* package in the ecosystem, so anyone familiar with one extension already knows how to wire this one in; the tradeoff is that the API is not meant to be used standalone — it requires understanding the broader unified/mdast/micromark composition model to use correctly.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search