Registry / serialization / mdast-builder

mdast-builder

JSON →
library1.1.1jsnpmunverified

mdast-builder provides a set of composable functions designed to programmatically construct Markdown Abstract Syntax Tree (MDAST) structures. It simplifies the creation of complex MDAST nodes like headings, paragraphs, lists, and text, offering a more declarative way to build ASTs compared to direct object manipulation. The current stable version is 1.1.1, released in July 2019. The package appears to have an inactive release cadence, with no updates since mid-2019, suggesting it is no longer actively maintained. Its key differentiator is its functional, builder-pattern approach to MDAST generation, which can be particularly useful for generating Markdown content dynamically or within content management systems that utilize MDAST.

npm install mdast-builder
INSTALL
IMPORT
SIG · MDAST-BUILDER
M
mdast-builder
serializationjavascriptv1.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

root
import { root } from 'mdast-builder';
const root = require('mdast-builder').root;
mdast-builder ships TypeScript types and is primarily used with ES Modules.
paragraph
import { paragraph } from 'mdast-builder';
const { paragraph } = require('mdast-builder');
CommonJS require syntax is discouraged for modern TypeScript/ESM projects.
heading
import { heading, text } from 'mdast-builder';
import heading from 'mdast-builder/heading';
All builder functions are named exports from the main package entry point.

Demonstrates building a simple MDAST tree with a heading, paragraph, and unordered list, then converting it to a Markdown string using `unified` and `remark-stringify`.

import { root, paragraph, text, heading, list, listItem, brk } from 'mdast-builder'; import * as stringify from 'remark-stringify'; import * as unified from 'unified'; const processor = unified().use(stringify, { bullet: '-', fence: '`', fences: true, incrementListMarker: false }); const output = processor.stringify( root([ heading(2, text('Begin')), paragraph([ paragraph(text('these are the starting instructions')), brk, brk, list('unordered', [ listItem(text('one')), listItem(text('two')), listItem(text('three')) ]) ]) ]) ); console.log(output); /* Expected output: ## Begin these are the starting instructions - one - two - three */
Debug
Known issues
gotchaThe mdast-builder package has not received updates since July 2019. While it may still function, it is likely unmaintained and may not be compatible with newer versions of MDAST specifications or related tools. Consider potential long-term maintenance and security implications.
fix
Evaluate alternatives like manually creating MDAST nodes or exploring more actively maintained AST manipulation libraries if active development or adherence to the latest specifications is crucial. For existing projects, consider vendoring the code if critical fixes are needed.
affects: >=1.1.1
gotchaThe `table` align type was corrected in v1.1.1. Older versions might have incorrect typings or behavior when constructing table nodes.
fix
Update to version 1.1.1 or newer to ensure correct `table` alignment typing and functionality.
affects: <1.1.1
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
mdast-builder — npm install mdast-builder · libregistry