1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use itertools::Itertools;
pub mod ast;
pub use ast::{mdx_elements, MdxAst};
#[derive(Debug, PartialEq, Eq)]
pub struct Mdx<'a> {
pub ast: Vec<MdxAst<'a>>,
}
pub fn parse(
input: &str,
) -> Result<Mdx, nom_supreme::error::ErrorTree<nom_supreme::final_parser::Location>> {
mdx_elements(input).map(|ast| Mdx { ast })
}
pub fn stringify(m: Mdx) -> String {
m.ast
.iter()
.map(|ast| format!("{}", ast))
.intersperse("\n\n".to_string())
.collect::<String>()
}