From 1c40ea8e00b44065ca4dadd1de2c1c4484e71642 Mon Sep 17 00:00:00 2001 From: kitsunecafe <10284516+kitsunecafe@users.noreply.github.com> Date: Mon, 29 Jan 2024 05:37:08 -0500 Subject: [PATCH] initial commit --- .gitignore | 2 ++ Cargo.toml | 10 ++++++++++ src/lib.rs | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 src/lib.rs 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) + } +} +