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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
use crate::NotedownAST; #[allow(unused_imports)] use std::collections::HashMap; #[macro_export] macro_rules! dict ( {$($key:expr => $value:expr),+} => { { let mut map = HashMap::new(); $( map.insert($key.to_string(), $value.to_string()); )+ map } }; ); pub trait ToAST { fn to_ast(&self) -> NotedownAST; } pub trait ToHTML { fn to_html(&self, cfg: HTMLConfig) -> String; fn to_html_default(&self) -> String { self.to_html(HTMLConfig::default()) } } pub trait ToMarkdown { fn to_md(&self, cfg: MarkdownConfig) -> String; fn to_md_default(&self) -> String { self.to_md(MarkdownConfig::default()) } } #[derive(Debug, Copy, Clone)] pub struct HTMLConfig {} impl Default for HTMLConfig { fn default() -> Self { HTMLConfig {} } } #[derive(Debug, Copy, Clone)] pub struct MarkdownConfig {} impl Default for MarkdownConfig { fn default() -> Self { MarkdownConfig {} } }