umark
umark is a Rust Markdown parser workspace with:
umark-lib: the parsing libraryumark: a small CLI wrapper
The default parsing mode is GitHub Flavored Markdown (GFM).
Features
- CommonMark-style core parsing
- GFM extensions: tables, task lists, strikethrough, literal autolinks (
https://...,www..., emails), footnotes, Mermaid fenced chart blocks (```mermaid), reference links ([label]: https://...), and ordered list start values (3. item) - Raw HTML passthrough in regular mode
- Safe parsing mode that rejects script tags and raw HTML
Project Layout
umark-lib/src/lib.rs: parser implementation and public APIumark/src/main.rs: CLI entrypoint
Build
CLI Usage
Examples:
# Default GFM parsing
# CommonMark mode
# Safe mode (rejects raw HTML and script tags)
Library Usage
Parse a Markdown string
use parse;
let html = parse;
assert!;
Choose parsing flavor
use ;
let gfm = parse_with_flavor;
let commonmark = parse_with_flavor;
assert!;
assert!;
Safe parsing
use safe_parse;
assert!;
assert!;
assert!;
Parse from file
use parse_from_file;
parse_from_file?;
# Ok::
Parse from file in safe mode
use safe_parse_from_file;
safe_parse_from_file?;
# Ok::
Mermaid Chart Support
In GFM mode:
```mermaid
flowchart TD
A --> B
```
is rendered as:
flowchart TD
A --> B
When using parse_from_file* in GFM mode and Mermaid blocks are present, a Mermaid runtime script is automatically appended to the output HTML so charts render in a browser.
Safety Notes
safe_parse*rejects any raw HTML and script tags.parse*allows raw HTML passthrough.- Safe mode is stricter by design and may reject content that regular parsing accepts.