smart-markdown 0.3.0

Parse and render Markdown to ANSI-styled terminal output with live in-place refresh
Documentation

smart-markdown

Crates.io Docs License

Parse and render Markdown to ANSI-styled terminal output with live in-place refresh.

Features

  • Full CommonMark — headings, paragraphs, code blocks, blockquotes, lists, tables, horizontal rules
  • GFM extensions — tables, task lists, strikethrough, autolinks
  • Inline formatting — bold, italic, strikethrough, inline code, links, images
  • Unicode heading prefixes · per level
  • Syntax highlighting — optional via syntax-highlight feature (7 bundled themes)
  • Terminal-aware — auto-detects width, wraps text, uses ANSI escape sequences
  • Live streaming — in-place re-render for dashboards and pipelines
  • Reference links, backslash escapes, indented code blocks, HTML blocks, nested lists
  • Extras — highlight (==text==), sub/superscript, math ($...$), emoji shortcodes (:rocket:), footnotes, definition lists

Quick start

use smart_markdown::Markdown;

let mut md = Markdown::parse("# Hello\n\n**Bold** and *italic*\n");
md.render();

Streaming example

use smart_markdown::Markdown;

let mut md = Markdown::parse(
    "## Build\n\n| Task | Status |\n|------|--------|\n| compile | pending |\n"
);
md.render();

// Update cells and re-render in place
md.set_cell_content(0, 1, "done");
md.append_to_cell(0, 1, " (1.2s)");
md.render();

Run the examples:

cargo run --example simple      # All features demo
cargo run --example streaming   # Live dashboard demo

Markdown support

Block elements

Element Syntax
Headings # through ######
Paragraphs plain text
Fenced code blocks ```lang / ~~~
Indented code blocks 4 spaces or tab
Blockquotes >
Unordered lists -, *, +
Ordered lists 1., 2.
Nested lists 4-space indented
Task lists - [ ], - [x]
Tables pipe-delimited
Definition lists term / : definition
HTML blocks <div>, <pre>, etc.
Horizontal rules ---, ***, ___

Inline elements

Element Syntax
Bold **text** or __text__
Italic *text* or _text_
Strikethrough ~~text~~
Inline code `code`
Links [text](url)
Reference links [text][ref] + [ref]: url
Autolinks <https://url>
Images ![alt](url)
Highlight ==text==
Subscript ~text~
Superscript ^text^
Math $...$
Emoji :smile:, :rocket:
Footnotes [^1]
Backslash escapes \*, \_, etc.

Options

Markdown::parse(text)
    .theme_mode(ThemeMode::Dark)   // Auto, Dark, or Light
    .code_theme("base16-ocean")    // Custom syntax theme
    .render();

License

Apache-2.0