npm run build— generate dist filesnpm test— run testsnpm test -- --coverage— run tests with coverage report
The compiler has two stages:
- parser (
src/parser.ts) — regex-based recursive descent parser, produces AST - htmlRenderer (
src/html.ts) — produces HTML string from the AST
AST node shapes live in src/ast.ts. Every node has a type field. Block nodes use body (for inline content) or doc (for nested blocks). Text content uses txt. AST is plain JSON-serializable data — no classes, functions, or circular references.
Parser and renderer are both stateless and side-effect free.
Parser uses two rule types:
SimpleRule— single regex matchLookaheadRule— pre-match regex determines the main regex (used for lists)
Rules are matched in priority order; first match wins.
transformBlock and transformInline hooks allow AST modification without forking the parser. See EXTENDING.md for usage and conventions.
See LiteMarkup-syntax.lm for the syntax description. It should be kept in sync with this reference implementation.
regex101.com is great for developing the regexes.
Avoid backtracking — match as little as possible, but not too little.
- Snapshot tests — verify output for various inputs
- Fuzzy tests — random input to catch parser failures
Add a failing test first for parser/renderer changes. Re-run the suite after changes.
- Update CHANGELOG.md
npm run testnpm run buildnpm version patch|minor|majorgit push --tagsnpm publish- Make release in GitHub
- Update demopage to use the new release