Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
4 changes: 2 additions & 2 deletions crates/org-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]]
Expand Down
2 changes: 1 addition & 1 deletion crates/org-exporter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion crates/org-parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 28 additions & 0 deletions crates/org-parser/src/object/org_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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"),]
}
)
}
}
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
edition="2024"
Loading