micromark-extension-gfm-autolink-literal
micromark syntax extension for GitHub-Flavored-Markdown autolink literals
Repository Health
Technical Analysis
micromark-extension-gfm-autolink-literal is a low-level tokenizer extension for the micromark markdown parser that adds GFM’s extra literal-autolink syntax: bare http(s):// URLs, www.-prefixed domains, and email addresses become recognized tokens during parsing without needing markdown link syntax. It implements GitHub’s parse-time autolinking algorithm; the companion transform-time algorithm (used for www./http/https links in issues, PRs, and comments) is handled separately by mdast-util-gfm-autolink-literal at the AST layer, since this package operates purely at the tokenizer level with no syntax tree.
As a micromark syntax extension, it is meant to be composed into a micromark parse call (or, more commonly, pulled in transitively through micromark-extension-gfm or remark-gfm) rather than installed and used directly by most developers. It ships an html compile extension alongside the syntax extension so consumers using micromark’s HTML compiler get correct autolink rendering out of the box.
What You Get
gfmAutolinkLiteral()syntax extension registering literal-autolink tokenization with micromarkgfmAutolinkLiteralHtml()compile extension for correct HTML output from micromark’s own HTML compiler- Faithful reproduction of GitHub’s parse-time autolink algorithm, including known edge cases from cmark-gfm
- URI sanitization via
micromark-util-sanitize-urito avoid unsafe autolinked hrefs - Full TypeScript types with 100% enforced type coverage and a battery of fixture-based conformance tests
Common Use Cases
- Assembling a custom micromark-based markdown parser that needs GFM autolinks without the full GFM extension bundle
- Building a markdown-to-HTML pipeline (via micromark directly) that must linkify bare URLs and emails per GitHub’s rules
- Providing the syntax layer underneath
mdast-util-gfm-autolink-literalwhen working at the mdast/unified level - Verifying or testing markdown renderers against GitHub’s documented (and sometimes buggy) autolink edge cases
Under The Hood
Architecture - The published index.js/lib/ are generated by a tsc --build + micromark-build step from TypeScript-annotated JS source (not committed to the repo, per .gitignore), exposing a gfmAutolinkLiteral() tokenizer extension that plugs into micromark’s state-machine-based parser via its construct/effects API, plus a separate gfmAutolinkLiteralHtml() compile extension for micromark’s own HTML compiler — keeping tokenization and HTML rendering as two independently composable pieces.
Tech Stack - Plain JavaScript with JSDoc-driven TypeScript types, depending only on sibling micromark-util-* packages (character, sanitize-uri, symbol, types) from the same monorepo family, with dual development/default export conditions so a richer dev build can run in tests.
Code Quality - test/index.js (542 lines) drives conformance against dozens of paired .md/.html fixture files covering domain/path/www/email/character-reference edge cases (many mirroring documented cmark-gfm bugs), run under both dev and prod conditions with c8 --100 enforcing full statement coverage.
API Design - The two-function surface (gfmAutolinkLiteral(), gfmAutolinkLiteralHtml()) follows the same extension-factory convention used across every micromark-extension-* package, so it composes predictably into a micromark() call’s extensions/htmlExtensions arrays; the tradeoff is that this low-level API is rarely meant for direct use — most consumers reach it only transitively through remark-gfm or micromark-extension-gfm, so the learning curve is steep for anyone not already familiar with micromark’s extension model.
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.