From 1bbe8fc6889d6b607f6e6ec2a11c9304fa8cce29 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 8 Oct 2023 09:28:09 -0400 Subject: [PATCH] Do not strip "//" from plain link path. --- src/parser/plain_link.rs | 9 ++++++--- src/parser/regular_link.rs | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/parser/plain_link.rs b/src/parser/plain_link.rs index 84a54624..1d0bda6d 100644 --- a/src/parser/plain_link.rs +++ b/src/parser/plain_link.rs @@ -101,6 +101,7 @@ fn post<'b, 'g, 'r, 's>( Ok((remaining, ())) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn parse_path_plain<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, @@ -111,6 +112,7 @@ fn parse_path_plain<'b, 'g, 'r, 's>( ))(input) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] pub(crate) fn parse_file_and_application<'s>( input: OrgSource<'s>, ) -> Res, Option>> { @@ -122,6 +124,7 @@ pub(crate) fn parse_file_and_application<'s>( Ok((remaining, application)) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn file_path_plain<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, @@ -132,15 +135,14 @@ fn file_path_plain<'b, 'g, 'r, 's>( exit_matcher: &path_plain_end, }); let parser_context = context.with_additional_node(&parser_context); - let (remaining, (raw_link, (_, application, _, _, path, search_option))) = consumed(tuple(( + let (remaining, (raw_link, (_, application, _, path, search_option))) = consumed(tuple(( peek(tag("file")), map_parser( parser_with_context!(protocol)(&parser_context), parse_file_and_application, ), tag(":"), - opt(tag("//")), - parser_with_context!(path_plain)(&parser_context), + recognize(opt(parser_with_context!(path_plain)(&parser_context))), opt(map( tuple(( tag("::"), @@ -165,6 +167,7 @@ fn file_path_plain<'b, 'g, 'r, 's>( )) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn protocol_path_plain<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, diff --git a/src/parser/regular_link.rs b/src/parser/regular_link.rs index b80e5cc0..fdb7fae9 100644 --- a/src/parser/regular_link.rs +++ b/src/parser/regular_link.rs @@ -133,6 +133,7 @@ fn pathreg<'b, 'g, 'r, 's>( Ok((remaining, path)) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn parse_path_reg<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, @@ -188,6 +189,7 @@ enum ParserState { Percent, } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn apply_link_templates<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, @@ -247,6 +249,7 @@ fn apply_link_templates<'b, 'g, 'r, 's>( Some(ret) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn file_path_reg<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, @@ -305,6 +308,7 @@ fn file_path_reg<'b, 'g, 'r, 's>( )) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn id_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s>> { let (remaining, (raw_link, (_, path))) = consumed(tuple((tag("id:"), rest)))(input)?; Ok(( @@ -319,6 +323,7 @@ fn id_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s>> { )) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn custom_id_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s>> { let (remaining, (raw_link, (_, path))) = consumed(tuple((tag("#"), rest)))(input)?; Ok(( @@ -333,6 +338,7 @@ fn custom_id_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s )) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn code_ref_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s>> { let (remaining, (raw_link, (_, path, _))) = consumed(tuple(( tag("("), @@ -351,6 +357,7 @@ fn code_ref_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s> )) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn protocol_path_reg<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, @@ -372,6 +379,7 @@ fn protocol_path_reg<'b, 'g, 'r, 's>( )) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn fuzzy_path_reg<'s>(input: OrgSource<'s>) -> Res, PathReg<'s>> { let (remaining, body) = rest(input)?; Ok((