ferris/
main.rs

1// Adds three custom plugins and runs them.
2mod block_rule;
3mod core_rule;
4mod inline_rule;
5
6fn main() {
7    // create markdown parser
8    let md = &mut markdown_that::MarkdownThat::new();
9
10    // add commonmark syntax, you almost always want to do that
11    markdown_that::plugins::cmark::add(md);
12
13    // add custom three rules described above
14    inline_rule::add(md);
15    block_rule::add(md);
16    core_rule::add(md);
17
18    // and now you can use it
19    let html = md
20        .parse(
21            r#"
22(\/) hello world (\/)
23(\/)-------------(\/)
24    "#,
25        )
26        .render();
27
28    print!("{html}");
29
30    assert_eq!(html.trim(), r#"
31<p><span class="ferris-inline">🦀</span> hello world <span class="ferris-inline">🦀</span></p>
32<div class="ferris-block"><img src="https://upload.wikimedia.org/wikipedia/commons/0/0f/Original_Ferris.svg"></div>
33<footer class="ferris-counter">There are 3 crabs lurking in this document.</footer>
34    "#.trim());
35}