Do not strip "//" from plain link path.

This commit is contained in:
Tom Alexander 2023-10-08 09:28:09 -04:00
parent ba8115c648
commit 1bbe8fc688
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 14 additions and 3 deletions

View File

@ -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<OrgSource<'s>, Option<OrgSource<'s>>> {
@ -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>,

View File

@ -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<OrgSource<'s>, 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<OrgSource<'s>, PathReg<'s>> {
))
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn custom_id_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, 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<OrgSource<'s>, PathReg<'s
))
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn code_ref_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
let (remaining, (raw_link, (_, path, _))) = consumed(tuple((
tag("("),
@ -351,6 +357,7 @@ fn code_ref_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, 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<OrgSource<'s>, PathReg<'s>> {
let (remaining, body) = rest(input)?;
Ok((