diff --git a/Cargo.lock b/Cargo.lock
index e74337f..92c83a0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -840,9 +840,9 @@ checksum = "47f142fe24a9c9944451e8349de0a56af5f3e7226dc46f3ed4d4ecc0b85af75e"
[[package]]
name = "js-sys"
-version = "0.3.92"
+version = "0.3.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc4c90f45aa2e6eacbe8645f77fdea542ac97a494bcd117a67df9ff4d611f995"
+checksum = "797146bb2677299a1eb6b7b50a890f4c361b29ef967addf5b2fa45dae1bb6d7d"
dependencies = [
"once_cell",
"wasm-bindgen",
@@ -1176,7 +1176,7 @@ dependencies = [
[[package]]
name = "orgize"
version = "0.10.0-alpha.10"
-source = "git+https://github.com/PoiScript/orgize.git?branch=v0.10#5f26c94dcec2a33b37b1c880ace053b29b5d021e"
+source = "git+https://git.tfcconnection.org/chris/orgize?branch=v0.11#8f6969ea1ee4e7c66dcb09a9ce89935832c3b68f"
dependencies = [
"bytecount",
"cfg-if",
@@ -2002,9 +2002,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen"
-version = "0.2.115"
+version = "0.2.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6523d69017b7633e396a89c5efab138161ed5aafcbc8d3e5c5a42ae38f50495a"
+checksum = "7dc0882f7b5bb01ae8c5215a1230832694481c1a4be062fd410e12ea3da5b631"
dependencies = [
"cfg-if",
"once_cell",
@@ -2015,9 +2015,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.115"
+version = "0.2.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4e3a6c758eb2f701ed3d052ff5737f5bfe6614326ea7f3bbac7156192dc32e67"
+checksum = "75973d3066e01d035dbedaad2864c398df42f8dd7b1ea057c35b8407c015b537"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -2025,9 +2025,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.115"
+version = "0.2.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "921de2737904886b52bcbb237301552d05969a6f9c40d261eb0533c8b055fedf"
+checksum = "91af5e4be765819e0bcfee7322c14374dc821e35e72fa663a830bbc7dc199eac"
dependencies = [
"bumpalo",
"proc-macro2",
@@ -2038,9 +2038,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.115"
+version = "0.2.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a93e946af942b58934c604527337bad9ae33ba1d5c6900bbb41c2c07c2364a93"
+checksum = "c9bf0406a78f02f336bf1e451799cca198e8acde4ffa278f0fb20487b150a633"
dependencies = [
"unicode-ident",
]
diff --git a/Cargo.toml b/Cargo.toml
index 3f2ce2a..44415e1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,7 @@ serde = { version = "1.0.213", features = ["derive"] }
tracing = "0.1.40"
tracing-log = "0.2.0"
tracing-subscriber = { version = "0.3.18", features = ["fmt", "std", "chrono", "time", "local-time", "env-filter"] }
-orgize = { git="https://github.com/PoiScript/orgize.git", branch = "v0.10", features = ["chrono", "indexmap", "tracing"] }
+orgize = { git="https://git.tfcconnection.org/chris/orgize", branch = "v0.11", features = ["chrono", "indexmap", "tracing"] }
steel-core = { git="https://github.com/mattwparas/steel.git", branch = "master" }
chrono = "0.4.44"
notify = "8.2.0"
diff --git a/src/org/exporter.rs b/src/org/exporter.rs
index b58564b..53d2e62 100644
--- a/src/org/exporter.rs
+++ b/src/org/exporter.rs
@@ -1,5 +1,3 @@
-use orgize::ast::Token;
-use rowan::NodeOrToken;
use slugify::slugify;
use std::cmp::min;
use std::fmt;
@@ -94,8 +92,8 @@ impl OrgHtmlExporter {
impl Traverser for OrgHtmlExporter {
fn event(&mut self, event: Event, ctx: &mut TraversalContext) {
match event {
- Event::Enter(Container::Document(_)) => self.output += "",
- Event::Leave(Container::Document(_)) => self.output += "",
+ Event::Enter(Container::Document(_)) => self.output += "\n",
+ Event::Leave(Container::Document(_)) => self.output += "\n",
Event::Enter(Container::Headline(headline)) => {
let level = min(headline.level() + 1, 6);
@@ -114,11 +112,11 @@ impl Traverser for OrgHtmlExporter {
}
Event::Leave(Container::Headline(_)) => {}
- Event::Enter(Container::Paragraph(_)) => self.output += "
",
- Event::Leave(Container::Paragraph(_)) => self.output += "
",
+ Event::Enter(Container::Paragraph(_)) => self.output += "\n",
+ Event::Leave(Container::Paragraph(_)) => self.output += "
\n",
- Event::Enter(Container::Section(_)) => self.output += "",
- Event::Leave(Container::Section(_)) => self.output += "",
+ Event::Enter(Container::Section(_)) => self.output += "\n",
+ Event::Leave(Container::Section(_)) => self.output += "\n",
Event::Enter(Container::Italic(_)) => self.output += "",
Event::Leave(Container::Italic(_)) => self.output += "",
@@ -151,8 +149,8 @@ impl Traverser for OrgHtmlExporter {
}
Event::Leave(Container::SourceBlock(_)) => self.output += "",
- Event::Enter(Container::QuoteBlock(_)) => self.output += "",
- Event::Leave(Container::QuoteBlock(_)) => self.output += "
",
+ Event::Enter(Container::QuoteBlock(_)) => self.output += "\n",
+ Event::Leave(Container::QuoteBlock(_)) => self.output += "
\n",
Event::Enter(Container::VerseBlock(_)) => self.output += "",
Event::Leave(Container::VerseBlock(_)) => self.output += "
",
@@ -178,41 +176,41 @@ impl Traverser for OrgHtmlExporter {
Event::Enter(Container::List(list)) => {
self.output += if list.is_ordered() {
self.in_descriptive_list.push(false);
- ""
+ "\n"
} else if list.is_descriptive() {
self.in_descriptive_list.push(true);
- ""
+ "\n"
} else {
self.in_descriptive_list.push(false);
- ""
+ "\n"
};
}
Event::Leave(Container::List(list)) => {
self.output += if list.is_ordered() {
- "
"
+ "
\n"
} else if let Some(true) = self.in_descriptive_list.last() {
- ""
+ "\n"
} else {
- ""
+ "\n"
};
self.in_descriptive_list.pop();
}
Event::Enter(Container::ListItem(list_item)) => {
if let Some(&true) = self.in_descriptive_list.last() {
- self.output += "";
+ self.output += "\n";
for elem in list_item.tag() {
self.element(elem, ctx);
}
- self.output += "";
+ self.output += "\n";
} else {
- self.output += "";
+ self.output += "\n";
}
}
Event::Leave(Container::ListItem(_)) => {
if let Some(&true) = self.in_descriptive_list.last() {
- self.output += "";
+ self.output += "\n";
} else {
- self.output += "";
+ self.output += "\n";
}
}
@@ -285,6 +283,13 @@ impl Traverser for OrgHtmlExporter {
Event::Enter(Container::Link(link)) => {
let path = link.path();
let path = path.trim_start_matches("file:");
+ let path = if let Some(path) = path.strip_suffix("org") {
+ let mut path = path.to_string();
+ path.push_str("html");
+ path
+ } else {
+ path.to_string()
+ };
if link.is_image() {
let _ = write!(&mut self.output, r#"
"#, HtmlEscape(&path));
@@ -301,7 +306,23 @@ impl Traverser for OrgHtmlExporter {
Event::Leave(Container::Link(_)) => self.output += "",
Event::Text(text) => {
- let _ = write!(&mut self.output, "{}", HtmlEscape(text));
+ if text
+ .syntax()
+ .parent()
+ .is_some_and(|parent| match parent.kind() {
+ SyntaxKind::KEYWORD
+ | SyntaxKind::DYN_BLOCK
+ | SyntaxKind::DRAWER
+ | SyntaxKind::DRAWER_END
+ | SyntaxKind::BLOCK_END
+ | SyntaxKind::DYN_BLOCK_END => true,
+ _ => false,
+ })
+ {
+ ()
+ } else {
+ let _ = write!(&mut self.output, "{}", HtmlEscape(text));
+ }
}
Event::LineBreak(_) => self.output += "
",
@@ -315,19 +336,11 @@ impl Traverser for OrgHtmlExporter {
Event::Rule(_) => self.output += "
",
Event::Timestamp(timestamp) => {
- self.output += r#""#;
- // for e in timestamp.syntax.children_with_tokens() {
- // match e {
- // NodeOrToken::Token(t) if t.kind() == SyntaxKind::MINUS2 => {
- // self.output += "–";
- // }
- // NodeOrToken::Token(t) => {
- // self.output += t.text();
- // }
- // _ => {}
- // }
- // }
- self.output += r#""#;
+ if let Some(datetime) = timestamp.start_to_chrono() {
+ self.output += r#""#;
+ self.output += &datetime.to_string();
+ self.output += r#""#;
+ }
}
Event::LatexFragment(latex) => {
@@ -340,12 +353,18 @@ impl Traverser for OrgHtmlExporter {
Event::Enter(Container::Keyword(keyword)) => {
if keyword.key().to_uppercase() == "TITLE" {
self.output += r#""#;
- self.output += &keyword.value();
+ self.output += &keyword.value().trim();
self.output += r#"
"#;
}
}
- Event::Entity(entity) => self.output += entity.html(),
+ Event::Leave(Container::Keyword(keyword)) => {
+ // idk
+ }
+
+ Event::Entity(entity) => {
+ self.output += entity.html();
+ }
_ => {}
}
diff --git a/src/publish/publish.rs b/src/publish/publish.rs
index cf64de2..af480ce 100644
--- a/src/publish/publish.rs
+++ b/src/publish/publish.rs
@@ -126,27 +126,35 @@ fn build_html(inner_html: String, keywords: HashMap) -> String {
.to_string();
let time_comment = format!("", build_time);
let doctype_html = "
-";
+\n";
let charset = r#""#;
- let style = r#""#;
+ let style = r#""#;
let viewport = r#""#;
let generator = r#""#;
- let mut head = format!("{}\n", doctype_html);
+ let mut head = format!("{}\n", doctype_html);
head.push_str(&time_comment);
+ head.push_str("\n");
head.push_str(&charset);
+ head.push_str("\n");
head.push_str(&viewport);
+ head.push_str("\n");
head.push_str(&title);
+ head.push_str("\n");
head.push_str(&description);
+ head.push_str("\n");
head.push_str(&generator);
+ head.push_str("\n");
head.push_str(&author);
+ head.push_str("\n");
head.push_str(&style);
- head.push_str("");
+ head.push_str("\n");
+ head.push_str("\n");
let other_style = r#""#;
- format!("{}\n\n{}\n", head, inner_html)
+ format!("{head}\n{inner_html}\n")
}
fn extract_keywords(keywords: &mut I) -> HashMap
diff --git a/src/watcher/mod.rs b/src/watcher/mod.rs
index 6627562..c073df8 100644
--- a/src/watcher/mod.rs
+++ b/src/watcher/mod.rs
@@ -6,22 +6,24 @@ use tracing::{debug, info};
use crate::publish::publish::{Error, build_site};
pub fn watch(event: Event, path: impl AsRef) -> Result<(), Error> {
- if event
+ if !event
.paths
.clone()
.into_iter()
.filter(|e| {
- if let Some(base_name) = e.file_name() {
- let name = base_name.to_os_string().into_string().unwrap_or("".into());
- // Let's filter out emacs changes and lockfiles
- !(name.starts_with(".#") | name.ends_with("~"))
- } else {
- false
- }
+ e.strip_prefix(&path).is_ok_and(|inner_path| {
+ if inner_path.starts_with("public") {
+ false
+ } else {
+ e.file_name().is_some_and(|base_name| {
+ let name = base_name.to_os_string().into_string().unwrap_or("".into());
+ !(name.starts_with(".#") | name.ends_with("~"))
+ })
+ }
+ })
})
.collect::>()
- .len()
- > 0
+ .is_empty()
{
match event.kind {
EventKind::Create(_) | EventKind::Modify(_) | EventKind::Remove(_) => {