# smart-markdown
[](https://crates.io/crates/smart-markdown)
[](https://docs.rs/smart-markdown)
[](https://github.com/cloudflavor/smart-markdown/blob/main/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
```rust
use smart_markdown::Markdown;
let mut md = Markdown::parse("# Hello\n\n**Bold** and *italic*\n");
md.render();
```
### Streaming example
```rust
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:
```bash
cargo run --example simple # All features demo
cargo run --example streaming # Live dashboard demo
```
## Markdown support
### Block elements
| 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
| 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 | `` |
| Highlight | `==text==` |
| Subscript | `~text~` |
| Superscript | `^text^` |
| Math | `$...$` |
| Emoji | `:smile:`, `:rocket:` |
| Footnotes | `[^1]` |
| Backslash escapes | `\*`, `\_`, etc. |
## Options
```rust
Markdown::parse(text)
.theme_mode(ThemeMode::Dark) // Auto, Dark, or Light
.code_theme("base16-ocean") // Custom syntax theme
.render();
```
## License
Apache-2.0