termimad 0.3.5

Markdown Renderer for the Terminal
Documentation

MIT Latest Version docs Chat on Miaou

A simple tool to display static or dynamic Markdown snippets in the terminal, with skin isolation.

Based on crossterm so works on most terminals (even on windows).

text

Note that the goal isn't to display any markdown text with its various extensions (a terminal isn't really fit for that). The goal is rather to improve the display of texts in a terminal application when we want both the text and the skin to be easily configured.

Wrapping, table balancing, and scrolling are essential features of Termimad.

A text or a table can be displayed in an a priori unknown part of the screen, scrollable if desired, with a dynamically discovered width.

For example this markdown:

|:-:|:-:|-
|**feature**|**supported**|**details**|
|-:|:-:|-
| tables | yes | pipe based only, with alignments
| italic, bold | yes | star based |
| inline code | yes | `with backquotes` (it works in tables too)
| code bloc | yes |with tabs: Fences not supported
| horizontal rule |  not yet
| crossed text |  not yet | ---this isn't crossed---
| lists | yes|* unordered lists supported
|  | |* ordered lists *not* supported
| quotes |  not yet
| phpbb like links | no | (because it's preferable to show an URL in a terminal)
|-

will give different results depending on the width:

table

table

Usage

[dependencies]
termimad = "0.3"

With the default skin:

termimad::print_inline("**some** *nested **style*** and `some(code)`");

or

print!("{}", termimad.inline("**some** *nested **style*** and `some(code)`"));

Result:

simple example

Inline snippets with a custom skin:

Inline snippets are one line or less.

let mut skin = MadSkin::default();
skin.bold.set_fg(Yellow);
skin.print_inline("*Hey* **World!** Here's `some(code)`");
skin.paragraph.set_fgbg(Magenta, rgb!(30, 30, 40));
skin.italic.add_attr(Underlined);
println!("\nand now {}\n", skin.inline("a little *too much* **style!** (and `some(code)` too)"));

Result:

too much style

Texts

Texts can be several lines. Tables and code blocks are automatically aligned, justified and consistently wrapped.

skin.print_text("# title\n* a list item\n* another item");

Scrollable TextView in a raw terminal:

scrollable

The code for this example is in examples/scrollable. To read the whole text just do

cargo run --example scrollable