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 @@ -169,7 +169,7 @@ struct OpenGreater {
/// org-element plain link at column 0: `file+emacs:` / `file+sys:` /
/// `file:` / `shell:` / `elisp:` / `help:` / `info:` / `http://` /
/// `https://` / `eww:` / `irc:` / `bbdb:` / `gnus:` / `rmail:` /
/// `mhe:` / `mailto:` /
/// `mhe:` / `vm:` / `wl:` / `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 Down Expand Up @@ -202,6 +202,10 @@ pub(crate) fn org_plain_link_marker_len(line: &str) -> Option<usize> {
"rmail:"
} else if t.starts_with("mhe:") {
"mhe:"
} else if t.starts_with("vm:") {
"vm:"
} else if t.starts_with("wl:") {
"wl:"
} else if t.starts_with("https://") {
"https://"
} else if t.starts_with("http://") {
Expand Down
30 changes: 30 additions & 0 deletions tests/org_file_token_punct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,36 @@ fn leftover_mhe_plain_link_after_path_hangs_and_splits() {
assert_eq!(format_text(&out, &org_cfg()).unwrap(), out);
}

#[test]
fn leftover_vm_plain_link_after_path_hangs_and_splits() {
let input = concat!("vm:folder leftover. Next.\n", "After. Next.\n",);
let out = format_text(input, &org_cfg()).unwrap();
assert!(
!out.contains("vm:folder leftover. Next."),
"leftover after vm 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_wl_plain_link_after_path_hangs_and_splits() {
let input = concat!("wl:folder leftover. Next.\n", "After. Next.\n",);
let out = format_text(input, &org_cfg()).unwrap();
assert!(
!out.contains("wl:folder leftover. Next."),
"leftover after wl 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