diff --git a/src/parser/org.rs b/src/parser/org.rs index 5c24580..2af4f41 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://` / `eww:` / `irc:` / `mailto:` / +/// `https://` / `eww:` / `irc:` / `bbdb:` / `gnus:` / `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. @@ -193,6 +193,10 @@ pub(crate) fn org_plain_link_marker_len(line: &str) -> Option { "eww:" } else if t.starts_with("irc:") { "irc:" + } else if t.starts_with("bbdb:") { + "bbdb:" + } else if t.starts_with("gnus:") { + "gnus:" } 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 92524e7..70c6e43 100644 --- a/tests/org_file_token_punct.rs +++ b/tests/org_file_token_punct.rs @@ -196,6 +196,39 @@ fn leftover_irc_plain_link_after_path_hangs_and_splits() { assert_eq!(format_text(&out, &org_cfg()).unwrap(), out); } +#[test] +fn leftover_bbdb_plain_link_after_path_hangs_and_splits() { + let input = concat!("bbdb:Smith leftover. Next.\n", "After. Next.\n",); + let out = format_text(input, &org_cfg()).unwrap(); + assert!( + !out.contains("bbdb:Smith leftover. Next."), + "leftover after bbdb 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_gnus_plain_link_after_path_hangs_and_splits() { + let input = concat!( + "gnus:nntp+news.gmane.io leftover. Next.\n", + "After. Next.\n", + ); + let out = format_text(input, &org_cfg()).unwrap(); + assert!( + !out.contains("gnus:nntp+news.gmane.io leftover. Next."), + "leftover after gnus 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",);