LegalMark is a markup language designed for structured legal and regulatory documents such as policies, regulatory business plans, contracts, and procedures. It enforces explicit document hierarchy, supports automatic numbering, and separates content from presentation.
  • C 43.5%
  • Python 42%
  • C++ 7%
  • Vim Script 3%
  • Tree-sitter Query 2.5%
  • Other 2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Toby Bryans 8e0d4ad6af Spec: header and footer spacing, list marker indent
- 19.5: spacing, the gap between a header or footer and the body text
- 19.8: marker-indent, the bullet or number position; say what indent
  measures

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c0b4c-6be3-71bd-98e6-f2fa23d2b5d7
2026-11-06 18:41:39 +00:00
editors Point the Zed extension at the grammar commit 2026-11-06 13:37:01 +00:00
src/legalmark Add header and footer spacing and list marker indents 2026-11-06 18:41:39 +00:00
tests Add header and footer spacing and list marker indents 2026-11-06 18:41:39 +00:00
.gitignore Add Python reference parser and conformance suite 2026-11-06 11:03:06 +00:00
pyproject.toml Add style files, HTML and PDF rendering 2026-11-06 13:00:30 +00:00
README.md Add editor support for Helix, Zed, VS Code and Vim 2026-11-06 13:37:01 +00:00
REVIEW-v0.2.1.md Add review of spec v0.2.1 with decisions 2026-11-06 10:18:10 +00:00
SPECIFICATION.md Spec: header and footer spacing, list marker indent 2026-11-06 18:41:39 +00:00
uv.lock Add style files, HTML and PDF rendering 2026-11-06 13:00:30 +00:00

LegalMark

A markup language for structured legal and regulatory documents. See SPECIFICATION.md.

This repository also contains the Python reference implementation, and syntax highlighting for Helix, Zed, VS Code, and Vim in editors/.

Development

uv sync
uv run pytest
uv run legalmark check path/to/document.lm    # validate and print the numbered outline
uv run legalmark html path/to/document.lm     # write document.html (self-contained, images embedded)
uv run legalmark pdf path/to/document.lm      # write document.pdf
uv run legalmark parse path/to/document.lm    # print the parsed tree as JSON (--resolved to number it)

html and pdf refuse to write output when the document has errors; --force overrides this. PDF output uses WeasyPrint, which is installed with the pdf extra (pip install legalmark[pdf]) and in the development environment.

Conformance tests

tests/conformance/ holds the language-independent conformance suite. Each NAME.lm file is paired with its expected outcome:

  • NAME.ast.json: the document parses without errors and produces this tree.
  • NAME.resolved.json: the document compiles without diagnostics, and its numbering, references and terms match this summary.
  • NAME.diagnostics: the document produces exactly these diagnostics, one per line, as LINE SEVERITY CODE (for example 4 error unknown-element).

See specification Section 21.2 for the details.