A next-generation Markdown parser built with Rust, combining CommonMark compliance (~75%+), Bootstrap 5 integration, semantic HTML generation, and an extensible plugin system. Maintains backward compatibility with UMD legacy syntax.
Status: Production-ready | Latest Update: 2026-03-03 | License: MIT
-
Semantic-First: Markdown is not just a shorthand for HTML. It is a structured document. Universal Markdown ensures every element is wrapped in semantically correct tags (e.g., using
<figure>for code blocks) to enhance SEO and accessibility. -
Empowerment without Complexity: Inspired by the PukiWiki legacy, we provide rich formatting (alignment, coloring, etc) without forcing users to write raw HTML. We believe in "Expressive Markdown."
-
Universal Media Handling: Redefining the standard image tag as a versatile "Media Tag." Whether it's an image, video, or audio, the parser intelligently determines the best output.
- β CommonMark Compliant (~75%+ specification compliance)
- β GFM Extensions (tables, strikethrough, task lists, footnotes)
- β HTML5 Semantic Tags (optimized for accessibility and SEO)
- β Bootstrap 5 Integration (automatic utility class generation)
- β
Auto-detect Media Files:
intelligently becomes<video>,<audio>,<picture>, or download link based on file extension - β
Semantic HTML Elements:
&badge(),&ruby(),&sup(),&time(), etc. - β
Definition Lists:
:term|definitionsyntax with block-level support - β
Code Blocks with Bootstrap Integration: Class-based language output (
<code class="language-*">) and syntect highlighting - β
Mermaid SSR:
```mermaidblocks are rendered server-side as<figure class="code-block code-block-mermaid mermaid-diagram">...<svg>...</svg></figure>
- β Markdown Tables: Standard GFM tables with sorting capability
- β
UMD Tables: Extended tables with cell spanning (
|>colspan,|^rowspan) - β Cell Decoration: alignment (LEFT/CENTER/RIGHT/JUSTIFY), color, size control
- β Block Decorations: SIZE, COLOR, positioning with Bootstrap prefix syntax
- β
Plugin System: Inline (
&function(args){content};) and block (@function(args){{ content }}) modes - β Frontmatter: YAML/TOML metadata (separate from HTML output)
- β Footnotes: Structured data output (processed server-side by Nuxt/Laravel)
- β
Custom Header IDs:
# Header {#custom-id}syntax
- β UMD Backward Compatibility: Legacy PHP implementation syntax support
- β
Block Quotes: UMD format
> ... <+ Markdown>prefix - β
Discord-style Spoilers:
||hidden text||syntax - β
Underline & Emphasis Variants: Both semantic (
**bold**,*italic*) and visual (''bold'','''italic''')
- β XSS Protection: Input HTML fully escaped, user input never directly embedded
- β
URL Sanitization: Blocks dangerous schemes (
javascript:,data:,vbscript:,file:) - β
Safe Link Handling:
<URL>explicit markup only (bare URLs not auto-linked)
- β
WebAssembly (WASM): Browser-side rendering via
wasm-bindgen - β Server-side Rendering: Rust library for backend integration (Nuxt, Laravel, etc.)
Input:
```mermaid
flowchart TD
A[Start] --> B[End]
```Output (excerpt):
<figure
class="code-block code-block-mermaid mermaid-diagram"
data-mermaid-source="flowchart TD..."
>
<svg><!-- rendered by mermaid-rs-renderer --></svg>
</figure>Input:
```rust
fn main() {
println!("hello");
}
```Output (excerpt):
<pre><code class="language-rust syntect-highlight" data-highlighted="true"><span class="syntect-source syntect-rust">...</span></code></pre>UMD code blocks use a Rust-first hybrid strategy with frontend fallback.
prenever gets alangattribute- Language is represented as
class="language-xxx"on<code> - If Syntect highlights on server side:
class="language-xxx syntect-highlight"data-highlighted="true"is added
- If language is not supported by Syntect:
- Keep
class="language-xxx"and let frontend highlighter process it
- Keep
mermaidis handled separately and rendered as SVG<figure class="... mermaid-diagram">
flowchart TD
A[Fenced code block] --> B[comrak parses code block]
B --> C{Mermaid language}
C -->|Yes| D[Rust renders Mermaid SVG]
D --> E[Output mermaid-diagram figure]
C -->|No| F{Syntect supported}
F -->|Yes| G[Rust applies syntax highlight]
G --> H[code with syntect and highlighted flag]
F -->|No| I[code keeps language class]
H --> J[Skip client rehighlight]
I --> K[Client highlighter can process]
Use selectors that exclude server-highlighted code blocks:
document
.querySelectorAll(
'pre code[class*="language-"]:not([data-highlighted="true"])',
)
.forEach((el) => Prism.highlightElement(el));This prevents double-highlighting and keeps Mermaid processing isolated.
Add to your Cargo.toml:
[dependencies]
umd = { path = "./umd", version = "0.1" }use umd::parse;
fn main() {
let input = "# Hello World\n\nThis is **bold** text.";
let html = parse(input);
println!("{}", html);
// Output: <h1>Hello World</h1><p>This is <strong>bold</strong> text.</p>
}use umd::parse_with_frontmatter;
fn main() {
let input = r#"---
title: My Document
author: Jane Doe
---
# Content starts here"#;
let result = parse_with_frontmatter(input);
println!("Title: {}", result.frontmatter.as_ref().map(|fm| &fm.content).unwrap_or(&"".to_string()));
println!("HTML: {}", result.html);
}Build WASM module:
./build.sh release
# Output: pkg/umd.js, pkg/umd_bg.wasmUse in JavaScript:
import init, { parse_markdown } from "./pkg/umd.js";
async function main() {
await init();
const html = parse_markdown("# Hello from WASM");
console.log(html);
}
main(); β <video controls><source src="demo.mp4" type="video/mp4" />...</video>
 β <audio controls><source src="bg.mp3" type="audio/mpeg" />...</audio>
 β <picture><source srcset="screen.png" type="image/png" /><img src="screen.png" alt="Screenshot" loading="lazy" /></picture>
 β <a href="file.pdf" download>π file.pdf</a>COLOR(red): Error message β <p class="text-danger">Error message</p>
SIZE(1.5): Larger text β <p class="fs-4">Larger text</p>
RIGHT: Right-aligned content β <p class="text-end">Right-aligned content</p>
CENTER: Centered paragraph β <p class="text-center">Centered paragraph</p>&badge(success){Active}; β <span class="badge bg-success">Active</span>
&ruby(reading){ζΌ’ε}; β <ruby>ζΌ’ε<rp>(</rp><rt>reading</rt><rp>)</rp></ruby>
&sup(superscript); β <sup>superscript</sup>
&time(2026-02-25){Today}; β <time datetime="2026-02-25">Today</time>`#ffce44`
`rgb(255,0,0)`
`rgba(0,255,0,0.4)`
`hsl(100, 10%, 10%)`
`hsla(100, 24%, 40%, 0.5)`<code
>#ffce44<span
class="inline-code-color"
style="background-color: #ffce44;"
></span
></code>
<code
>rgb(255,0,0)<span
class="inline-code-color"
style="background-color: rgb(255,0,0);"
></span
></code>
<code
>rgba(0,255,0,0.4)<span
class="inline-code-color"
style="background-color: rgba(0,255,0,0.4);"
></span
></code>
<code
>hsl(100, 10%, 10%)<span
class="inline-code-color"
style="background-color: hsl(100, 10%, 10%);"
></span
></code>
<code
>hsla(100, 24%, 40%, 0.5)<span
class="inline-code-color"
style="background-color: hsla(100, 24%, 40%, 0.5);"
></span
></code>Recommended CSS:
code .inline-code-color {
display: inline-block;
width: 0.75em;
height: 0.75em;
margin-left: 0.4em;
border-radius: 0.2em;
border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.2));
vertical-align: middle;
}&highlight(yellow){Important text}; β <template class="umd-plugin umd-plugin-highlight">
<data value="0">yellow</data>
Important text
</template>
@detail(Click to expand){{Hidden}} β <template class="umd-plugin umd-plugin-detail">
<data value="0">Click to expand</data>
Hidden
</template>
UMD Table (with colspan/rowspan):
| Header1 |> | Header3 |
| Cell1 | Cell2 | Cell3 |
|^ | Cell4 | Cell5 |
RIGHT:
| Left Cell | Right Cell |
CENTER:
| Centered Table |
- docs/README.md - Documentation index (entry point)
- docs/architecture.md - System architecture, processing pipeline, component details, developer guide
- docs/implemented-features.md - Complete reference of implemented features
- docs/planned-features.md - Roadmap for planned features
- PLAN.md - Implementation status and milestone tracking
- .github/copilot-instructions.md - AI agent quick reference for development
- PUBLISHING.md - crates.io publishing checklist and commands
- RELEASE.md - SemVer and release operation guide
- CHANGELOG.md - Project change history
- SECURITY.md - Vulnerability reporting policy
Input Text
β
[Frontmatter Extractor] β Extract YAML/TOML metadata
β
[Nested Blocks Preprocess] β Normalize list-item nested blocks
β
[Tasklist Preprocess] β Convert indeterminate markers
β
[Underline Preprocess] β Protect Discord-style __text__
β
[Conflict Resolver] β Protect UMD syntax with markers
β
[HTML Sanitizer] β Escape user input, preserve entities
β
[comrak Parser] β CommonMark + GFM AST generation
β
[Underline Postprocess] β Restore <u> tags
β
[UMD Extensions] β Apply inline/block decorations, plugins, tables, media
β
[Footnotes Extractor] β Split body HTML and footnotes section
β
Output: HTML + Frontmatter + Footnotes
- src/lib.rs - Main entry point (
parse(),parse_with_frontmatter()) - src/parser.rs - CommonMark + GFM parsing (comrak wrapper)
- src/sanitizer.rs - HTML escaping & XSS protection
- src/frontmatter.rs - YAML/TOML metadata extraction
- src/extensions/ - UMD syntax implementations
conflict_resolver.rs- Marker-based pre/post-processingblock_decorations.rs- COLOR, SIZE, alignment prefixesinline_decorations.rs- Semantic element functionsplugins.rs- Plugin rendering systemtable/- Table parsing & decorationmedia.rs- Media auto-detection
284 tests passing β
196 unit tests (core modules)
24 bootstrap integration tests (CSS class generation)
18 commonmark compliance tests (specification adherence)
13 conflict resolution tests (syntax collision handling)
1 semantic integration test
Run tests:
cargo test --verbose # All tests
cargo test --test bootstrap_integration # Integration tests only- Small documents (1KB): < 1ms
- Medium documents (10KB): < 10ms
- Large documents (100KB): < 100ms
(Benchmarks on modern hardware)
- β Input Sanitization: All user input HTML-escaped before parsing
- β
Scheme Blocklist: Dangerous URL schemes blocked (
javascript:,data:, etc.) - β
Plugin Safety: Plugins output to
<template>for server-side processing (no direct HTML execution) β οΈ XSS Risk Mitigation: Recommend server-side validation of plugin content before rendering
- Rust: 1.93.1+ (Edition 2024)
- WASM: wasm32-unknown-unknown target
- Node.js: Via WASM bindings
- Browser: Chrome, Firefox, Safari, Edge (ES2020+)
- comrak 0.50.0 - CommonMark + GFM parser
- ammonia 4.1.2 - HTML sanitization
- maud 0.27.0 - Type-safe HTML generation
- regex 1.12.2 - Pattern matching
- wasm-bindgen 0.2.108 - WASM integration
Contributions welcome! Please:
- Read docs/architecture.md for system design
- Check PLAN.md for current priorities
- Write tests for new features
- Ensure all tests pass:
cargo test --verbose - Follow Rust conventions and document your changes
MIT License - see LICENSE for details
This template is built with a focus on UI/UX excellence and modern developer experience. Maintaining it involves constant testing and updates to ensure everything works seamlessly.
If you appreciate the attention to detail in this project, a small sponsorship would go a long way in supporting my work across the Vue.js and Metaverse ecosystems.