use std::collections::HashMap; pub mod parser; pub mod renderer; pub struct MarkdownAST { pub root: Layer, } pub type Level = u8; pub type Lang = String; pub type Title = String; pub type Url = String; pub struct Layer { pub range_row_begin: u32, pub range_row_end: u32, pub lines: Vec, } pub struct Line { pub row: u32, pub tokens: Vec, } pub struct Token { pub begin_row: u32, pub begin_col: u16, pub end_row: u32, pub end_col: u16, pub token: TokenData, } pub enum TokenData { Normal(Fragment), Newline, Newlayer(Layer), // Headings Heading(Level, Line, Layer), // Emphasis Emphasis(Vec, EmphasisStyle), // Lists UnorderedList(Line, UnorderedListPrefix), OrderedList(Line, u32), // Links Link(Vec, Url, Option, LinkType), // Code InlineCode(Vec<Fragment>), CodeBlock(Vec<Line>, Option<Lang>), // Blockquotes Blockquotes(Layer), // HorizontalRule HorizontalRule(HorizontalRuleType), // Table Table(Table), } pub struct Fragment { pub str: String, } pub struct EmphasisStyle { pub bold: bool, pub italic: bool, pub strikethrough: bool, } pub enum UnorderedListPrefix { Star, Dash, Plus, } pub enum LinkType { Image, Url, } pub enum HorizontalRuleType { Stars, Dashes, Underscores, } pub struct Table { pub contents: HashMap<(u32, u32), Vec<Fragment>>, }