A minimalist toolchain for working with legal and structured documents in XML format. CML is a specialized markup language designed for legal documents like constitutions, laws, and regulations, featuring structured metadata, hierarchical organization, and cross-reference capabilities.
- Structured Legal Documents: XML-based format with hierarchical elements (articles, sections, paragraphs)
- Cross-Reference System: ID-based linking with
<ref target="">elements and go-to-definition support - Multi-Format Output: Build system generates JSON, Markdown, HTML, and plain text from CML sources
- VS Code Integration: Full language server support with syntax highlighting, diagnostics, and IntelliSense
- Schema Validation: XSD schema definitions ensure document structure compliance
- Document Profiles: Support for different document types (doc, person, place, event)
- Clone the repository:
git clone https://github.com/magnus-trent/continuity-markup-language.git
cd continuity-markup-language- Build all CML documents:
deno task build- Or validate documents without generating output:
deno task check- Navigate to the extension directory:
cd extensions/vscode-cml
npm install
npm run compile- Package the extension:
npm run package- Install the
.vsixfile in VS Code or press F5 to launch a development instance.
├── documents/ # CML source documents
│ └── us/federal/constitution/current/
│ ├── en-us.cml # US Constitution in CML format
│ └── build/ # Generated output files
├── extensions/vscode-cml/ # VS Code language extension
│ ├── client/ # Language client
│ ├── server/ # Language server
│ └── syntaxes/ # Syntax highlighting grammar
├── schemas/ # XSD schema definitions
│ └── 1.0/ # Version 1.0 schemas
├── scripts/ # Build tooling
│ ├── build.ts # Main build script
│ └── lib/emitters.ts # Output format generators
└── deno.json # Deno configuration and tasks
CML documents follow this hierarchical structure:
<document xmlns="https://continuity.dev/ns/cml/1.0"
id="document.id"
profile="doc">
<head>
<title>Document Title</title>
<meta name="source" content="Source Information" />
</head>
<body>
<preamble>Introductory text...</preamble>
<article num="I" title="Article Title" id="doc.id:art.1">
<section num="1" id="doc.id:art.1.sec.1">
<paragraph num="1" id="doc.id:art.1.sec.1.par.1">
Document content with <ref target="other.id">cross-references</ref>.
</paragraph>
</section>
</article>
</body>
</document><document>: Root element with profile, ID, and language attributes<head>: Document metadata (title, meta tags, links)<body>: Main content with structured elements:<preamble>: Introductory text<article>: Major sections with numbered subsections<section>: Subdivisions within articles<paragraph>: Individual paragraphs with unique IDs
<ref target="">: Cross-references to other document elements
The build system processes CML files and generates multiple output formats:
deno task build- Build all CML documents in thedocuments/directorydeno task check- Validate CML documents without generating output filesdeno run -A scripts/build.ts- Direct build script execution
For each en-us.cml file, the build system generates:
en-us.json- Structured JSON representationen-us.md- Markdown formaten-us.txt- Plain text versionen-us.html- HTML rendering
All output files are created in a build/ subdirectory next to the source file.
The CML language extension provides comprehensive IDE support:
- Syntax Highlighting: Custom TextMate grammar for CML elements and attributes
- Language Server: Cross-file indexing of
id=values and<ref target="">elements - Go to Definition: Navigate from
<ref target="">to target elements - Hover Information: Display target titles on hover
- Diagnostics: Real-time validation of unresolved references
- Icon Themes: Custom file icons for
.cmlfiles - Schema Integration: XML validation via Red Hat XML extension
npm run compile- Compile TypeScript for the extensionnpm run watch- Watch mode compilationnpm run package- Package extension as.vsixfilenpm run publish- Publish to VS Code marketplace
- Clone and install dependencies:
git clone https://github.com/magnus-trent/continuity-markup-language.git
cd continuity-markup-language- For the build system (Deno):
# No installation needed - Deno handles dependencies automatically
deno task build- For the VS Code extension:
cd extensions/vscode-cml
npm install
npm run compile- Launch VS Code extension development:
- Open
extensions/vscode-cmlin VS Code - Press F5 to launch Extension Development Host
- Open a
.cmlfile to test language features
- Open
- Create CML files in the
documents/directory following the existing structure - Ensure proper
id=attributes for cross-referencing - Run
deno task buildto generate output formats - Update schemas in
schemas/1.0/if adding new elements
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes following the existing code style
- Test the build system:
deno task build - Test the VS Code extension: compile and run in development mode
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Created by Magnus Trent
For more detailed development information, see CLAUDE.md.