diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2022-08-25 21:09:25 +1200 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2022-08-25 21:09:25 +1200 |
commit | 54f5e9fd883e207931baa9c87b6181ca724d6bab (patch) | |
tree | 17111a1da036dbc061ae4062ea0716373e16e23d /src/lib.rs | |
download | markdown-54f5e9fd883e207931baa9c87b6181ca724d6bab.zip |
Initial commit
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..c0b8c84 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,33 @@ +#![feature(iter_zip)] + +mod block; +mod parse; +mod parse_heirarchical; +mod table; +mod text; + +pub use block::Block; +pub use parse::parse; +pub use parse_heirarchical::parse_heirarchical; +pub use table::{Alignment, Column, Table}; +pub use text::{Hyperlink, Text}; + +pub type Line = Vec<Text>; + +pub fn line_to_string(line: &[Text]) -> String { + let mut output = String::new(); + for text in line { + match text { + Text::Normal(content) => output.push_str(&content), + Text::Bold(content) => output.push_str(&format!("**{}**", content)), + Text::Italic(content) => output.push_str(&format!("_{}_", content)), + Text::BoldItalic(content) => output.push_str(&format!("**_{}_**", content)), + Text::Code(content) => output.push_str(&format!("`{}`", content)), + Text::WikiLink(content) => output.push_str(&format!("[[{}]]", content)), + Text::Hyperlink(Hyperlink { label, target }) => { + output.push_str(&format!("[{}]({})", label, target)) + } + } + } + return output; +} |