npx mdsl <command> <definition.js> [input] [options]| Command | Description |
|---|---|
parse |
Markdown → ParseResult JSON on stdout |
validate |
JSON → ParseResult on stdout |
serialize |
JSON → canonical markdown on stdout |
The definition must be a compiled JavaScript module exporting a default MdslDocument:
# Compile your definition (example)
npx tsc examples/spec-doc.ts --module esnext --target es2022 --moduleResolution bundler
mdsl parse ./examples/spec-doc.js ./tests/fixtures/spec-doc.mdTypeScript source files (.ts) are rejected with a clear error.
Compile examples/spec-doc.ts (imports @rghenderson/mdsl and zod), then:
npm run build
mdsl parse ./examples/spec-doc.js ./tests/fixtures/spec-doc.mdUse - as the input path:
cat document.md | mdsl parse ./spec-doc.js -
cat document.json | mdsl serialize ./spec-doc.js -On failure, formatted diagnostics are printed to stderr in addition to the JSON ParseResult.
mdsl parse ./spec-doc.js ./bad.md
# stderr: 1:1 [MISSING_HEADING] Missing # heading ...