npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gmb/bitmark-parser

v3.0.3

Published

A parser for bitmark text, powered by WebAssembly.

Downloads

522

Readme

@gmb/bitmark-parser

A high-performance parser for bitmark, powered by WebAssembly. Provides both a programmatic API and a CLI for converting between bitmark markup and JSON.

Installation

npm install @gmb/bitmark-parser

Programmatic API (Node.js)

import { convert, parse, lex, breakscapeText, unbreakscapeText, info, version } from "@gmb/bitmark-parser";

// Convert bitmark to JSON (auto-detects input format)
const json = convert("[.article]\nHello **bold**", { warnings: true });
const parsedJson = JSON.parse(json);
console.log(parsedJson[0].bit.type);
console.log(parsedJson[0].parser.warnings);
console.log(parsedJson[0].bitmark);

// Parse bitmark to JSON (same as convert for bitmark input)
const parsed = parse("[.article]\nHello **bold**", { mode: "full" });

// Lex bitmark to token dump
const tokens = lex("[.article]\nHello **bold**");

// Lex with a specific stage
const tokenJson = lex("[.article]\nHello **bold**", { stage: "lex-json" });

// Breakscape / unbreakscape text
const escaped = breakscapeText("[!example]", "bitmark++", "body");
const unescaped = unbreakscapeText(escaped, "bitmark++", "body");

// Query supported bit types
const bitInfo = info({ infoType: "list", format: "text" });

// Get library version
console.log(version());

API

convert(input: string, options?: ConvertOptions): string

Auto-detect input format and convert between bitmark and JSON.

Options (passed as a JSON string):

  • mode"optimized" (default) or "full"
  • warnings — include validation warnings (default: false)
  • plainText — output text as plain text (default: false)
  • pretty — prettify JSON output (default: false)
  • indent — indent size for pretty JSON (default: 2)

For bitmark input, output is a JSON array of entries with:

  • bit — serialized bit payload
  • parser — parser metadata and warnings
  • bitmark — source bitmark text

parse(input: string, options?: ParseOptions): string

Parse bitmark text and return structured JSON entries (bit, parser, bitmark).

lex(input: string, stage?: string): string

Lex bitmark text and return one token per line.

Stages:

  • "lex" — Unified lexer token stream (default)
  • "lex-json" — Unified lexer token stream as JSON

breakscapeText(input: string, options?: BreakscapeOptions): string

Breakscape text (escape bitmark special characters).

  • format"bitmark++" (default) or "plainText"
  • location"body" (default) or "tag"

unbreakscapeText(input: string, options?: BreakscapeOptions): string

Unbreakscape text (unescape bitmark special characters).

  • format"bitmark++" (default) or "plainText"
  • location"body" (default) or "tag"

info(options?: InfoOptions): string

Query information about supported bit types.

  • infoType"list" (default), "bit", "all", or "deprecated"
  • format"text" (default) or "json"
  • bit — filter to a specific bit type (when infoType is "bit")
  • pretty — prettify JSON output (default: false)
  • indent — indent size for pretty JSON (default: 2)

version(): string

Return the library version string.

generate(json: string): string

Generate bitmark text from JSON. Not yet implemented — throws an error.

CLI

The CLI binary is bitmark-parser-wasm.

# Convert bitmark to JSON (auto-detects format)
bitmark-parser-wasm convert input.bitmark
bitmark-parser-wasm convert input.bitmark -o output.json

# Convert JSON to bitmark
bitmark-parser-wasm convert input.json -o output.bitmark

# Convert with options
bitmark-parser-wasm convert input.bitmark --mode full --pretty --warnings

# Parse a bitmark file to JSON
bitmark-parser-wasm parse input.bitmark
bitmark-parser-wasm parse input.bitmark -o output.json
bitmark-parser-wasm parse input.bitmark --mode full

# Lex instead of parse
bitmark-parser-wasm parse --stage=lex input.bitmark

# Available stages: all (default), lex
bitmark-parser-wasm parse --stage=lex input.bitmark

# Breakscape / unbreakscape text
bitmark-parser-wasm breakscape input.txt
bitmark-parser-wasm breakscape input.txt --format plainText --location tag
bitmark-parser-wasm unbreakscape input.txt

# Query bit type information
bitmark-parser-wasm info
bitmark-parser-wasm info all -f json --pretty
bitmark-parser-wasm info bit --bit article

# Generate bitmark from JSON (not yet implemented)
bitmark-parser-wasm generate input.json output.bitmark

All commands support -o, --output <file> and -a, --append flags. Commands that accept input support file paths, literal strings, or stdin (when no arguments are given).

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.