From de97d44395f5511ff2571668c0c7a3832ab912f4 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Tue, 15 Sep 2026 14:29:04 -0500 Subject: [PATCH] fix(org): leftover eww and irc plain links org-element leftover walkers for eww: and irc: at column 0. Leftover after the path hangs as Prose and still splits. --- src/parser/org.rs | 6 +++++- tests/org_file_token_punct.rs | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/parser/org.rs b/src/parser/org.rs index d5ae880..5c24580 100644 --- a/src/parser/org.rs +++ b/src/parser/org.rs @@ -168,7 +168,7 @@ struct OpenGreater { /// or Unicode word characters (letters and digits). `:END:` is the closer. /// org-element plain link at column 0: `file+emacs:` / `file+sys:` / /// `file:` / `shell:` / `elisp:` / `help:` / `info:` / `http://` / -/// `https://` / `mailto:` / +/// `https://` / `eww:` / `irc:` / `mailto:` / /// `news:` / `doi:` / `ftp://` / `attachment:` / `id:` plus the path. /// Leftover after the path is hung Prose. `file+emacs:` / `file+sys:` /// must be matched before `file:` or the `+…` is eaten as the path. @@ -189,6 +189,10 @@ pub(crate) fn org_plain_link_marker_len(line: &str) -> Option { "help:" } else if t.starts_with("info:") { "info:" + } else if t.starts_with("eww:") { + "eww:" + } else if t.starts_with("irc:") { + "irc:" } else if t.starts_with("https://") { "https://" } else if t.starts_with("http://") { diff --git a/tests/org_file_token_punct.rs b/tests/org_file_token_punct.rs index 484f3d5..92524e7 100644 --- a/tests/org_file_token_punct.rs +++ b/tests/org_file_token_punct.rs @@ -160,6 +160,42 @@ fn leftover_info_plain_link_after_path_hangs_and_splits() { assert_eq!(format_text(&out, &org_cfg()).unwrap(), out); } +#[test] +fn leftover_eww_plain_link_after_path_hangs_and_splits() { + let input = concat!( + "eww:https://example.org leftover. Next.\n", + "After. Next.\n", + ); + let out = format_text(input, &org_cfg()).unwrap(); + assert!( + !out.contains("eww:https://example.org leftover. Next."), + "leftover after eww path must still split, got:\n{out}" + ); + assert!( + out.contains("After.\nNext."), + "following prose must still split, got:\n{out}" + ); + assert_eq!(format_text(&out, &org_cfg()).unwrap(), out); +} + +#[test] +fn leftover_irc_plain_link_after_path_hangs_and_splits() { + let input = concat!( + "irc:/irc.libera.chat/#org leftover. Next.\n", + "After. Next.\n", + ); + let out = format_text(input, &org_cfg()).unwrap(); + assert!( + !out.contains("irc:/irc.libera.chat/#org leftover. Next."), + "leftover after irc path must still split, got:\n{out}" + ); + assert!( + out.contains("After.\nNext."), + "following prose must still split, got:\n{out}" + ); + assert_eq!(format_text(&out, &org_cfg()).unwrap(), out); +} + #[test] fn leftover_attachment_plain_link_after_path_hangs_and_splits() { let input = concat!("attachment:plot.png leftover. Next.\n", "After. Next.\n",);