Why Nostr? What is Njump?
2024-06-21 22:42:16

npub1ty…xjpy9 on Nostr: commit ea115396fff0ac3db30a16d7f4920e209aabed41 Author: randymcmillan ...

commit ea115396fff0ac3db30a16d7f4920e209aabed41
Author: randymcmillan <[email protected]>
Date: Thu May 16 16:31:43 2024 -0400

display markdown:initial config

diff --git a/Cargo.toml b/Cargo.toml
index 56695eb..f461a40 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,4 +16,6 @@ authors.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
+comrak = "0.23.0"
include_dir = { version = "0.7.3", features = ["glob", "metadata"] }
+markdown2html-converter = "1.1.12"
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644
index 0000000..99acb95
--- /dev/null
+++ b/GNUmakefile
@@ -0,0 +1 @@
+-include cargo.mk
diff --git a/cargo.mk b/cargo.mk
new file mode 120000
index 0000000..09daa8d
--- /dev/null
+++ b/cargo.mk
@@ -0,0 +1 @@
+../cargo.mk
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index add5545..146ddba 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,13 +1,53 @@
-use std::path::Path;
use include_dir::{include_dir, Dir};
+use std::path::Path;
+extern crate comrak;
+use comrak::nodes::NodeValue;
+use comrak::{format_html, parse_document, Arena, Options};
+
+static GIT_REMOTE: &str = "http://github.com/nostr-protocol/nips.git";;
+
static PROJECT_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR");
+
+fn replace_text(document: &str, orig_string: &str, replacement: &str) -> String {
+ // The returned nodes are created in the supplied Arena, and are bound by its lifetime.
+ let arena = Arena::new();
+
+ // Parse the document into a root `AstNode`
+ let root = parse_document(&arena, document, &Options::default());
+
+ // Iterate over all the descendants of root.
+ for node in root.descendants() {
+ if let NodeValue::Text(ref mut text) = node.data.borrow_mut().value {
+ // If the node is a text node, perform the string replacement.
+ *text = text.replace(orig_string, replacement)
+ }
+ }
+
+ let mut html = vec![];
+ format_html(root, &Options::default(), &mut html).unwrap();
+
+ String::from_utf8(html).unwrap()
+}
+
fn main() {
+
+ // let doc = "This is my input.\n\n1. Also [my](#) input.\n2. Certainly *my* input.\n";
+ // let orig = "my";
+ // let repl = "your";
+ // let html = replace_text(&doc, &orig, &repl);
+ // println!("{}", html);
+
print_entries();
}
-//#[cfg(feature = "glob")]
+
fn print_entries() -> () {
let glob = "**/*.md";
for entry in PROJECT_DIR.find(glob).unwrap() {
+
println!("Found {}", entry.path().display());
+
+ let README_MD = PROJECT_DIR.get_file("README.md").unwrap();
+ let readme = README_MD.contents_utf8().unwrap();
+ println!("readme={}", readme);
}
}
Author Public Key
npub1tyy860wj67vw54sk4rzv5fnltwp84hk92h93gxnw6ufy33mtntuq2xjpy9