diff --git a/org_mode_samples/object/plain_link/with_parenthesis.org b/org_mode_samples/object/plain_link/with_parenthesis.org index 064f905..e141c66 100644 --- a/org_mode_samples/object/plain_link/with_parenthesis.org +++ b/org_mode_samples/object/plain_link/with_parenthesis.org @@ -6,3 +6,6 @@ https://en.wikipedia.org/wiki/Shebang_(Unix # Parenthesis only allowed to depth of 2 so link ends at underscore. https://en.wikipedia.org/wiki/Shebang_(((Unix))) + +# Even though they eventually become balanced, we hit negative parenthesis depth so link ends at ) +https://en.wikipedia.org/wiki/Shebang)Unix( diff --git a/src/parser/plain_link.rs b/src/parser/plain_link.rs index 1827fc3..2ab6d6c 100644 --- a/src/parser/plain_link.rs +++ b/src/parser/plain_link.rs @@ -10,10 +10,12 @@ use nom::combinator::recognize; use nom::combinator::verify; use nom::multi::many_till; +use super::org_source::BracketDepth; use super::org_source::OrgSource; use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting; use crate::context::parser_with_context; use crate::context::ContextElement; +use crate::context::ContextMatcher; use crate::context::ExitClass; use crate::context::ExitMatcherNode; use crate::context::RefContext; @@ -140,7 +142,7 @@ fn path_plain<'b, 'g, 'r, 's>( let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context); let (remaining, path) = recognize(verify( - many_till(anychar, peek(exit_matcher)), + many_till(anychar, exit_matcher), |(children, _exit_contents)| !children.is_empty(), ))(input)?;