An open API service indexing awesome lists of open source software.

https://github.com/jasperdevs/lessmark

Readable markup with typed blocks and a stable JSON AST.
https://github.com/jasperdevs/lessmark

Last synced: about 1 month ago
JSON representation

Readable markup with typed blocks and a stable JSON AST.

Awesome Lists containing this project

README

          


lessmark

lessmark <M

The markdown alternative that agents (and humans) love.


lessmark.org


npm
PyPI
crates.io
VS Code Marketplace

Lessmark is readable markup with typed blocks, canonical formatting, safe rendering, and a stable JSON AST across JavaScript, Python, and Rust.

## Why use Lessmark instead of Markdown?

Markdown is good when a human is the only reader. Lessmark is for documents that humans edit and AI agents need to trust.

In Markdown, the same-looking document can parse differently across engines, raw HTML can change the output, and malformed structure often gets accepted silently. That is fine for notes and comments, but painful for AI agent context files, docs pipelines, renderers, and import/export paths that need one predictable tree.

Lessmark keeps the readable parts and removes the guesswork:

| Markdown | Lessmark |
| --- | --- |
| Many equivalent spellings for the same idea | One canonical format |
| Parser-dependent edge cases | Shared grammar and conformance tests |
| Raw HTML and renderer-specific behavior | Safe rendering with no raw HTML |
| Loose structure that AI agents and parsers have to infer | Typed blocks with explicit attributes |
| Formatting is mostly cosmetic | Formatting produces stable source |
| AST shape depends on the parser | Stable JSON AST across JavaScript, Python, and Rust |

Use Markdown for casual prose. Use Lessmark when the file is part of a build, a parser, a validator, a site, or an agent workflow.

## Install

```sh
npm install lessmark
```

```sh
pip install lessmark
```

```sh
cargo add lessmark
```

CLI

```sh
lessmark parse file.lmk
lessmark parse --positions file.lmk
lessmark parse -
lessmark check file.lmk
lessmark check docs
lessmark check --json file.lmk
lessmark format file.lmk
lessmark format --check file.lmk
lessmark format --check --json docs
lessmark fix --write file.lmk
lessmark fix --write docs
lessmark from-markdown README.md
lessmark from-markdown -
lessmark to-markdown file.lmk
lessmark to-markdown -
lessmark init docs
lessmark render --document file.lmk
lessmark build --strict input public
lessmark info --json
```

Use `-` to read from stdin. `check`, `format --check`, and `fix --write` can also walk a directory recursively. `parse --positions` includes source ranges for tooling. `init` creates a starter `docs/index.lmk` without overwriting. `parse`, `check`, `format`, `fix`, `from-markdown`, `to-markdown`, `init`, and `info` are shared by the JavaScript, Python, and Rust packages. HTML rendering and static-site builds are npm CLI features.

API

```js
import { parseLessmark, validateSource, formatLessmark, renderHtml } from "lessmark";

const source = "# Notes\n\nPlain prose becomes a paragraph.\n";
const ast = parseLessmark(source);
const errors = validateSource(source);
const formatted = formatLessmark(source);
const html = renderHtml(ast, { document: true });
```

```py
from lessmark import parse_lessmark, validate_source, format_lessmark
```

```rust
use lessmark::{parse_lessmark, validate_source, format_lessmark};
```

Language

Lessmark source files use `.lmk`; `.lessmark` is a readable alias. The language includes plain top-level paragraphs, headings, inline functions, typed context blocks, lists, tables, callouts, code, math, diagrams, links, footnotes, and page/navigation metadata.

Conformance is checked across JavaScript, Python, Rust, docs, Markdown conversion, fixtures, schemas, VS Code syntax, and the Tree-sitter starter grammar. See [lessmark.org/docs/conformance](https://lessmark.org/docs/conformance).

## License

MIT