Skip to content

Blackfall-Labs/content-markup-language

Repository files navigation

Content Markup Language (CML)

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.

Features

  • 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)

Quick Start

Prerequisites

  • Deno runtime for the build system
  • VS Code for the language extension (optional)

Building Documents

  1. Clone the repository:
git clone https://github.com/magnus-trent/continuity-markup-language.git
cd continuity-markup-language
  1. Build all CML documents:
deno task build
  1. Or validate documents without generating output:
deno task check

Installing the VS Code Extension

  1. Navigate to the extension directory:
cd extensions/vscode-cml
npm install
npm run compile
  1. Package the extension:
npm run package
  1. Install the .vsix file in VS Code or press F5 to launch a development instance.

Project Structure

├── 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 Document Structure

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>

Key Elements

  • <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

Build System

The build system processes CML files and generates multiple output formats:

Commands

  • deno task build - Build all CML documents in the documents/ directory
  • deno task check - Validate CML documents without generating output files
  • deno run -A scripts/build.ts - Direct build script execution

Output Formats

For each en-us.cml file, the build system generates:

  • en-us.json - Structured JSON representation
  • en-us.md - Markdown format
  • en-us.txt - Plain text version
  • en-us.html - HTML rendering

All output files are created in a build/ subdirectory next to the source file.

VS Code Extension

The CML language extension provides comprehensive IDE support:

Features

  • 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 .cml files
  • Schema Integration: XML validation via Red Hat XML extension

Development Commands

  • npm run compile - Compile TypeScript for the extension
  • npm run watch - Watch mode compilation
  • npm run package - Package extension as .vsix file
  • npm run publish - Publish to VS Code marketplace

Development

Setting Up the Development Environment

  1. Clone and install dependencies:
git clone https://github.com/magnus-trent/continuity-markup-language.git
cd continuity-markup-language
  1. For the build system (Deno):
# No installation needed - Deno handles dependencies automatically
deno task build
  1. For the VS Code extension:
cd extensions/vscode-cml
npm install
npm run compile
  1. Launch VS Code extension development:
    • Open extensions/vscode-cml in VS Code
    • Press F5 to launch Extension Development Host
    • Open a .cml file to test language features

Adding New Document Types

  1. Create CML files in the documents/ directory following the existing structure
  2. Ensure proper id= attributes for cross-referencing
  3. Run deno task build to generate output formats
  4. Update schemas in schemas/1.0/ if adding new elements

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes following the existing code style
  4. Test the build system: deno task build
  5. Test the VS Code extension: compile and run in development mode
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Created by Magnus Trent


For more detailed development information, see CLAUDE.md.

About

Profile-driven markup language for structured knowledge. CML (inspired by XML) for legal documents, API docs, and narrative content. Deterministic transforms to JSON/MD/HTML/TXT, VS Code integration, schema validation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

 
 
 

Contributors