From 2ff02d2e577188851bf9e84ff2e38df8cad45968 Mon Sep 17 00:00:00 2001 From: Laith Date: Tue, 5 May 2026 03:22:11 -0400 Subject: [PATCH 1/3] fix(parser): handle nested parens in macros --- crates/org-parser/src/object/org_macro.rs | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/org-parser/src/object/org_macro.rs b/crates/org-parser/src/object/org_macro.rs index f89e51e..9f08b3e 100644 --- a/crates/org-parser/src/object/org_macro.rs +++ b/crates/org-parser/src/object/org_macro.rs @@ -52,7 +52,11 @@ impl<'a> Parseable<'a> for MacroCall<'a> { // TODO: handle abc(1\\,) case (escaping backslash used to escape comam) let mut join_prev = false; + // handle nested parens {{{i(things (inside things) other things)}}} + let mut paren_nesting = 0; + loop { + // cursor.next() at the end match cursor.try_curr()? { NEWLINE => { parse_opts.from_paragraph = true; @@ -69,7 +73,16 @@ impl<'a> Parseable<'a> for MacroCall<'a> { return Err(MatchError::InvalidLogic); } } + LPAREN => { + paren_nesting += 1; + } RPAREN => { + if paren_nesting > 0 { + paren_nesting -= 1; + cursor.next(); + continue; + } + if join_prev { if let Cow::Owned(a) = arg_vec.last_mut().unwrap() { a.push_str(cursor.clamp_backwards(prev_ind)); @@ -262,4 +275,19 @@ mod tests { } ) } + + #[test] + fn macro_nested_params() { + let input = r"{{{i(things (inside things) other things)}}}"; + let parsed = parse_org(input); + dbg!(&parsed); + let l = expr_in_pool!(parsed, Macro).unwrap(); + assert_eq!( + l, + &MacroCall { + name: "i", + args: vec![Cow::Borrowed("things (inside things) other things"),] + } + ) + } } From deb435f469262585ba34742a0428befabf3c43f2 Mon Sep 17 00:00:00 2001 From: Laith Date: Tue, 5 May 2026 06:10:55 -0400 Subject: [PATCH 2/3] chore: cleanup .gitignore (and also local dev directory (but that doesn't show up here)) --- .gitignore | 7 +++++++ rustfmt.toml | 1 + 2 files changed, 8 insertions(+) create mode 100644 rustfmt.toml diff --git a/.gitignore b/.gitignore index b925e77..ff3c111 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,10 @@ target/ # explains why Cargo.lock should be ignored for a library # https://doc.rust-lang.org/cargo/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries Cargo.lock + +# directory to do updates +pkg/aur/org-rust +pkg/aur/.SRCINFO + +# dummy dir to test org behaviour +toss/ diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..1749478 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +edition="2024" From 23d7d600454f5cc803a820ddd9f38ee6634806f9 Mon Sep 17 00:00:00 2001 From: Laith Date: Tue, 5 May 2026 06:13:20 -0400 Subject: [PATCH 3/3] chore: Release --- crates/org-cli/Cargo.toml | 4 ++-- crates/org-exporter/Cargo.toml | 2 +- crates/org-parser/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/org-cli/Cargo.toml b/crates/org-cli/Cargo.toml index d133945..60a7551 100644 --- a/crates/org-cli/Cargo.toml +++ b/crates/org-cli/Cargo.toml @@ -19,7 +19,7 @@ clap = { version = "4.3.11", features = ["derive"] } lazy_format = "2.0.0" regex = "1.9.5" org-exporter = { version = "0.1.8", path = "../org-exporter", package = "org-rust-exporter" } -org-parser = { version = "0.1.5", path = "../org-parser", package = "org-rust-parser" } +org-parser = { version = "0.1.7", path = "../org-parser", package = "org-rust-parser" } serde = { version = "1.0.196", features=["derive"]} toml = "0.8.8" anyhow = "1.0.82" @@ -31,7 +31,7 @@ clap_complete = "4.3.2" clap_mangen = "0.2.14" serde = { version = "1.0.196", features=["derive"]} org-exporter = { version = "0.1.9", path = "../org-exporter", package = "org-rust-exporter" } -org-parser = { version = "0.1.6", path = "../org-parser", package = "org-rust-parser" } +org-parser = { version = "0.1.7", path = "../org-parser", package = "org-rust-parser" } # [[bin]] diff --git a/crates/org-exporter/Cargo.toml b/crates/org-exporter/Cargo.toml index 3739620..744114c 100644 --- a/crates/org-exporter/Cargo.toml +++ b/crates/org-exporter/Cargo.toml @@ -14,7 +14,7 @@ rust-version.workspace = true [dependencies] latex2mathml = "0.2.3" memchr = "2.5.0" -org-parser = { version = "0.1.6", path = "../org-parser", package = "org-rust-parser" } +org-parser = { version = "0.1.7", path = "../org-parser", package = "org-rust-parser" } phf = {version = "0.11.1", features = ["macros"]} thiserror = "1.0.63" diff --git a/crates/org-parser/Cargo.toml b/crates/org-parser/Cargo.toml index 235af1a..376042c 100644 --- a/crates/org-parser/Cargo.toml +++ b/crates/org-parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "org-rust-parser" -version = "0.1.6" +version = "0.1.7" description = "parser for org mode documents" homepage.workspace = true