mdx2vast
v0.5.0
Published
CLI to convert MDX to HTML while preserving JSX and expressions.
Readme
mdx2vast
mdx2vast is a CLI tool that converts MDX files to HTML while preserving
JSX syntax and components. This format (HTML that retains the structure of
the original file) is used by Vale to provide markup-aware linting.
Installation
Ensure you have Node.js installed on your system.
Install via npm:
npm install -g mdx2vastUsage
Run the CLI tool with the following command:
mdx2vast input.mdxIt also reads a single document from standard input:
mdx2vast < input.mdxBatch mode
Starting the process costs about 160 ms, nearly all of it importing the MDX toolchain, against roughly 4 ms to convert an average document. A caller with thousands of files spends most of its time on imports it has already done.
--batch reads documents until standard input closes and answers each one, so
that cost is paid once. On a 7,500-file corpus this is the difference between
about fifteen minutes and about thirty seconds.
mdx2vast --batch < framesDocuments are length-prefixed rather than delimited, because MDX may contain any byte sequence a delimiter could use:
request <byteLength> LF <bytes>
response "ok " <byteLength> LF <bytes>
"err " <byteLength> LF <message>Lengths count bytes rather than characters, so multi-byte content frames
correctly. A document that fails to convert answers err and the run
continues; one unparseable file does not end the batch.
Output is identical to single-document mode — the test suite asserts this per fixture.
