markdown_that/parser/mod.rs
1//! Parser itself and stuff that allows you to extend it.
2//!
3//! To understand how this parser works, you need to understand the concept
4//! of Rule Chains. "Rule Chain" is an ordered set of functions that get executed
5//! sequentially. This is an example of a Rule Chain:
6//!
7//! ```rust
8//! let rules : Vec<fn(&mut String)> = vec![
9//! |s| { s.push_str("hello"); },
10//! |s| { s.push(','); },
11//! |s| { s.push(' '); },
12//! |s| { s.push_str("world"); },
13//! |s| { s.push('!'); },
14//! ];
15//! dbg!(rules.iter().fold(String::new(), |mut s, f| { f(&mut s); s }));
16//! ```
17//!
18//! The example above builds a string using 5 independent functions. You can extend
19//! it by pushing your own function in that vector that manipulates the state (String)
20//! in any way you like.
21//!
22//! MarkdownThat parser consists of three Rule Chains:
23//! - [inline] (where functions get executed on every character)
24//! - [block] (where functions get executed on every line)
25//! - [core] (where functions get executed once per document)
26//!
27//! You can extend each one of these chains by using
28//! [md.inline.add_rule](inline::InlineParser::add_rule),
29//! [md.block.add_rule](block::BlockParser::add_rule) or
30//! [md.add_rule](crate::MarkdownThat::add_rule) respectively.
31//!
32//! These are examples of the rules in each chain (view the source to see implementation):
33//! - [inline rule](crate::plugins::cmark::inline::autolink) - autolink
34//! - [block rule](crate::plugins::cmark::block::hr) - thematic break
35//! - [core rule](crate::plugins::sourcepos) - source mapping
36//!
37pub mod block;
38pub mod core;
39pub mod extset;
40pub mod inline;
41pub mod linkfmt;
42
43pub(super) mod main;
44pub(super) mod node;
45pub(super) mod renderer;