mdast-util-gfm-autolink-literal
mdast extension to parse and serialize GitHub-Flavored-Markdown autolink literals
Repository Health
Technical Analysis
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 formdast-util-from-markdown, converting GFM autolink literals into mdast link nodesgfmAutolinkLiteralToMarkdown()extension formdast-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.
Used by 3 apps in this directory
AFFiNE
Productivity · Project Management · Note Taking
Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.
KeystoneJS
CMS · Developer Tools
The superpowered headless CMS for developers built with GraphQL and React
Rallly
Scheduling
Self-hostable group scheduling polls that eliminate back-and-forth emails and find the best meeting time for everyone.