From f426e32798740d8ed1b386a7d6d50e73f4c03027 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 29 Aug 2023 17:35:04 -0400 Subject: [PATCH] Do not include trailing punctuation or whitespace in plain links. --- .../object/plain_link/end_with_punctuation.org | 2 ++ src/parser/plain_link.rs | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/org_mode_samples/object/plain_link/end_with_punctuation.org b/org_mode_samples/object/plain_link/end_with_punctuation.org index 92df33d..5a23491 100644 --- a/org_mode_samples/object/plain_link/end_with_punctuation.org +++ b/org_mode_samples/object/plain_link/end_with_punctuation.org @@ -1 +1,3 @@ mailto:foo@bar.baz. + +mailto:foo@bar.baz.... diff --git a/src/parser/plain_link.rs b/src/parser/plain_link.rs index 8518ae6..387f788 100644 --- a/src/parser/plain_link.rs +++ b/src/parser/plain_link.rs @@ -134,6 +134,7 @@ fn path_plain<'r, 's>( many_till(anychar, peek(exit_matcher)), |(children, _exit_contents)| !children.is_empty(), ))(input)?; + Ok((remaining, path)) } @@ -142,5 +143,10 @@ fn path_plain_end<'r, 's>( _context: Context<'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { - recognize(one_of(" \t\r\n()[]<>"))(input) + recognize(many_till( + verify(anychar, |c| { + *c != '/' && (c.is_ascii_punctuation() || c.is_whitespace()) + }), + one_of(" \t\r\n()[]<>"), + ))(input) }