commit 1c40ea8e00b44065ca4dadd1de2c1c4484e71642 Author: kitsunecafe <10284516+kitsunecafe@users.noreply.github.com> Date: Mon Jan 29 05:37:08 2024 -0500 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fffb2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f18027d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "roxy_markdown_parser" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +roxy_core = { git = "https://github.com/kitsunecafe/roxy-core.git" } +pulldown-cmark = "0.9.3" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..ae34de5 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,19 @@ +use roxy_core::roxy::Parse; + +#[derive(Debug)] +pub struct MarkdownParser; + +impl MarkdownParser { + pub fn new() -> Self { + Self + } +} + +impl Parse for MarkdownParser { + fn parse(&mut self, _path: &str, src: &[u8], dst: &mut Vec) -> std::io::Result<()> { + let src = String::from_utf8_lossy(src).to_string(); + let parser = pulldown_cmark::Parser::new(src.as_str()); + pulldown_cmark::html::write_html(dst, parser) + } +} +