@gmb/bitmark-parser
A high-performance parser for bitmark text, powered by WebAssembly. Provides both a programmatic API and a CLI for parsing bitmark markup to JSON.
Installation
npm install @gmb/bitmark-parser
Programmatic API (Node.js)
import { parse, lex } from "@gmb/bitmark-parser";
const json = parse("[.article]\nHello **bold**");
console.log(json);
const tokens = lex("[.article]\nHello **bold**");
console.log(tokens);
const bitmarkTokens = lex(input, "lex-bitmark");
const textTokens = lex(input, "lex-text");
API
parse(input: string): string
Parse bitmark text and return the AST as a JSON string.
lex(input: string, stage?: string): string
Lex bitmark text and return one token per line.
Stages:
"lex" — Combined two-level lexer (default)
"lex-bitmark" — Bitmark structural tokens only
"lex-text" — Text formatting tokens only
generate(json: string): string
Generate bitmark text from JSON. Not yet implemented — throws an error.
CLI
bitmark-parser parse input.bitmark
bitmark-parser parse input.bitmark output.json
bitmark-parser parse --stage=lex input.bitmark
bitmark-parser parse --stage=lex-bitmark input.bitmark
Browser Usage
The package includes pre-built browser bundles with the WASM module.
CDN (jsdelivr / unpkg)
<script type="module">
import init, { parse } from "https://cdn.jsdelivr.net/npm/@gmb/bitmark-parser@latest/dist/browser/bitmark-parser.min.js";
await init();
const json = parse("[.article]\nHello **bold**");
console.log(json);
</script>
Bundler (webpack / vite)
import init, { parse, lex } from "@gmb/bitmark-parser/browser";
await init();
const json = parse("[.article]\nHello");
License
ISC — © 2023–2026 Get More Brain Ltd.