mdast-util-gfm-task-list-item

mdast extensions to parse and serialize GitHub Flavored Markdown task list items.

Library
npm
v2.0.0
6stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
22/100Needs Attention
Development Activity0
Maintenance20
Community8
Maturity60
Momentum0

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture82
Code Quality84
Innovation64
Learning Curve74

mdast-util-gfm-task-list-item is part of the unified/syntax-tree ecosystem and provides two extensions that add GitHub Flavored Markdown task list item support to mdast, the markdown abstract syntax tree. One extension plugs into mdast-util-from-markdown to parse checkbox list items into list item nodes carrying a checked boolean, and the other plugs into mdast-util-to-markdown to serialize those nodes back to markdown.

It handles the [ ] and [x] checkbox markers at the start of list items, keeping the checked state on the tree so it survives a parse-and-stringify round trip. It is typically combined with micromark-extension-gfm-task-list-item for tokenization, and is one of the building blocks used by mdast-util-gfm and remark-gfm.

What You Get

  • A from-markdown extension that parses [ ]/[x] checkboxes into list items with a checked field
  • A to-markdown extension that serializes checked list items back to GFM markdown
  • Preservation of the boolean checked state across parse and stringify
  • Support for the standard GFM task list item syntax
  • TypeScript type definitions for typed pipelines

Common Use Cases

  • Adding task list support to a remark or unified markdown pipeline
  • Parsing GFM checklists into an mdast tree for programmatic transformation
  • Serializing generated task list nodes back into markdown documents
  • Building custom GFM tooling alongside micromark-extension-gfm-task-list-item

Under The Hood

Architecture - The package is implemented in a compact lib/index.js (~141 lines) exporting two objects. The from-markdown extension registers handlers for micromark task list check token events and sets a checked boolean on the enclosing listItem node. The to-markdown extension provides a listItem handler that prepends the [ ] or [x] marker when a checked field is present, along with the necessary unsafe/escape rules.

Tech Stack - Pure ESM JavaScript typed via JSDoc with generated type declarations. It depends on sibling unist/mdast utilities and micromark helper packages, targeting modern Node.js and browsers.

Code Quality - The code adheres to the strict, uniform conventions of the syntax-tree project, with a dedicated test.js suite and full type coverage. The logic is small, declarative, and easy to audit.

API Design - The two-object, from/to naming mirrors every other mdast-util extension, so it integrates with no new concepts. It composes by being passed into from-markdown/to-markdown option arrays alongside its micromark counterpart.

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