aboutsummaryrefslogtreecommitdiffstats
path: root/markdown-tool
diff options
context:
space:
mode:
Diffstat (limited to 'markdown-tool')
-rw-r--r--markdown-tool/Cargo.lock62
-rw-r--r--markdown-tool/Cargo.toml14
-rw-r--r--markdown-tool/rustfmt.toml1
-rw-r--r--markdown-tool/src/main.rs26
4 files changed, 103 insertions, 0 deletions
diff --git a/markdown-tool/Cargo.lock b/markdown-tool/Cargo.lock
new file mode 100644
index 0000000..fd19dc8
--- /dev/null
+++ b/markdown-tool/Cargo.lock
@@ -0,0 +1,62 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "bitflags"
+version = "2.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
+
+[[package]]
+name = "getopts"
+version = "0.2.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
+dependencies = [
+ "unicode-width",
+]
+
+[[package]]
+name = "markdown-tool"
+version = "0.1.0"
+dependencies = [
+ "pulldown-cmark",
+]
+
+[[package]]
+name = "memchr"
+version = "2.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
+
+[[package]]
+name = "pulldown-cmark"
+version = "0.12.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f86ba2052aebccc42cbbb3ed234b8b13ce76f75c3551a303cb2bcffcff12bb14"
+dependencies = [
+ "bitflags",
+ "getopts",
+ "memchr",
+ "pulldown-cmark-escape",
+ "unicase",
+]
+
+[[package]]
+name = "pulldown-cmark-escape"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae"
+
+[[package]]
+name = "unicase"
+version = "2.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
+
+[[package]]
+name = "unicode-width"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
diff --git a/markdown-tool/Cargo.toml b/markdown-tool/Cargo.toml
new file mode 100644
index 0000000..e8becf2
--- /dev/null
+++ b/markdown-tool/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+name = "markdown-tool"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+pulldown-cmark = "0.12.2"
+
+[profile.release]
+strip = true
+opt-level = 3
+lto = true
+codegen-units = 1
+panic = "abort"
diff --git a/markdown-tool/rustfmt.toml b/markdown-tool/rustfmt.toml
new file mode 100644
index 0000000..b196eaa
--- /dev/null
+++ b/markdown-tool/rustfmt.toml
@@ -0,0 +1 @@
+tab_spaces = 2
diff --git a/markdown-tool/src/main.rs b/markdown-tool/src/main.rs
new file mode 100644
index 0000000..f321c63
--- /dev/null
+++ b/markdown-tool/src/main.rs
@@ -0,0 +1,26 @@
+use std::io::BufRead;
+
+use pulldown_cmark::{html, Options, Parser};
+
+fn main() {
+ let stdin = std::io::stdin();
+ let mut markdown_input = format!("");
+ for line in stdin.lock().lines() {
+ markdown_input = format!("{markdown_input}{}\n", line.unwrap())
+ }
+
+ let mut options = Options::empty();
+ options.insert(Options::ENABLE_STRIKETHROUGH);
+ options.insert(Options::ENABLE_FOOTNOTES);
+ options.insert(Options::ENABLE_TABLES);
+ options.insert(Options::ENABLE_TASKLISTS);
+ options.insert(Options::ENABLE_YAML_STYLE_METADATA_BLOCKS);
+ options.insert(Options::ENABLE_GFM);
+ let parser = Parser::new_ext(&markdown_input, options);
+ let mut html_output: String = String::with_capacity(markdown_input.len() * 3 / 2);
+ html::push_html(&mut html_output, parser);
+ println!(
+ "<style>@import url(\"/assets/md.css\")</style>
+{html_output}"
+ )
+}