Skip to main content

render_markdown

Function render_markdown 

Source
pub fn render_markdown(md: &str, term: &Term) -> Vec<String>
Expand description

Renders CommonMark to terminal lines, term.width columns wide.

Every line is at most term.width visible columns wide, with one exception: lines of code blocks are never wrapped, so they can be wider (a Panel folds them). With term.color off the lines contain no escape sequences; with it on each line is self-contained.

use shellgame::ui::{Term, render_markdown};

let md = "Přejděte\ndo adresáře `start`\n\n- první\n- druhá\n";
assert_eq!(
    render_markdown(md, &Term::plain(40)),
    ["Přejděte do adresáře start", "", " • první", " • druhá"],
);