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
6 changes: 5 additions & 1 deletion src/parser/org.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -193,6 +193,10 @@ pub(crate) fn org_plain_link_marker_len(line: &str) -> Option<usize> {
"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://") {
Expand Down
33 changes: 33 additions & 0 deletions tests/org_file_token_punct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",);
Expand Down
Loading