1pub mod parser;
2pub mod translator;
3
4pub type MarkdownText = Vec<MarkdownInline>;
5
6#[derive(Clone, Debug, PartialEq)]
7pub enum Markdown {
8 Heading(usize, MarkdownText),
9 OrderedList(Vec<MarkdownText>),
10 UnorderedList(Vec<MarkdownText>),
11 Line(MarkdownText),
12 Codeblock(String, String),
13}
14
15#[derive(Clone, Debug, PartialEq)]
16pub enum MarkdownInline {
17 Link(String, String),
18 Image(String, String),
19 InlineCode(String),
20 Bold(String),
21 Italic(String),
22 Plaintext(String),
23}
24
25pub fn markdown(md: &str) -> String {
26 match parser::parse_markdown(md) {
27 Ok((_, m)) => translator::translate(m),
28 Err(_) => String::from("Sorry, this did not seem to work! Maybe your markdown was not well formed, have you hit [Enter] after your last line?"),
29 }
30}