markup_engine 0.1.0

Zero-dependency, trait-based, ultra-lightweight markup renderer (Markdown + HTML + HTML + pluggable). Born from LeadSheetML, useful anywhere.
Documentation
  • Coverage
  • 0%
    0 out of 17 items documented0 out of 13 items with examples
  • Size
  • Source code size: 9.74 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.8 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • omnomchomsky/markup_engine
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • omnomchomsky

Markup Engine

markup_engine is a minimal, pluggable Rust trait for rendering structured content into various output formats like Markdown, HTML, or custom markup languages. It was originally developed to power LeadSheetML, but is fully general and can be used in any context that requires formatting content for multiple output formats.

Features

Define a common interface for rendering:

  • Titles
  • Headers (various levels)
  • Paragraphs
  • Italic, bold, and other inline formatting
  • Line breaks

Write one rendering logic, and plug in multiple output styles Easily extended for any other output format

Usage

Add to your Cargo.toml (Local Dev) If you’re developing locally:

markup_engine = { path = "../markup_engine" }

Or from GitHub:

markup_engine = { git = "https://github.com/yourname/markup_engine", branch = "main" }

Eventually:

markup_engine = "0.1"

Example

use markup_engine::{MarkupEngine, MarkdownEngine, HtmlEngine};

fn render_example<T: MarkupEngine>(engine: &T) -> String {
    [
        engine.header1("Welcome to MarkupEngine"),
        engine.italic("Pluggable rendering in Rust"),
        engine.line_break(),
        engine.header2("Features"),
        engine.paragraph("• Clean trait-based design\n• Output to multiple formats\n• Easy to extend"),
    ]
    .join("\n")
}


fn main() {
    let md = MarkdownEngine;
    println!("{}", render_example(&md));

    let html = HtmlEngine;
    println!("{}", render_example(&html));
}

Implementations

  • MarkdownEngine — renders markdown-formatted output
  • HtmlEngine — renders HTML-formatted output

Philosophy

The goal of markup_engine is to separate rendering logic from content structure, making it easier to write one logic for rendering and plug in any output format you need.

Contributing

Open to contributions, suggestions, and new format implementations! PRs welcome.

Security Warning

This engine does not sanitize or escape input. If you're rendering user-provided strings (e.g., lyrics, titles, or section names) to HTML, you are at risk of HTML injection. You are responsible for escaping content appropriately when using HtmlEngine. Consider using a crate like ammonia or html_escape.