Handle orgifying text in regular link path and raw-link.

This commit is contained in:
Tom Alexander
2023-10-06 18:30:08 -04:00
parent 51748afd41
commit d126488891
10 changed files with 151 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ use nom::branch::alt;
use nom::bytes::complete::escaped;
use nom::bytes::complete::tag;
use nom::bytes::complete::take_till1;
use nom::bytes::complete::take_until;
use nom::character::complete::anychar;
use nom::combinator::consumed;
use nom::combinator::eof;
@@ -116,6 +117,7 @@ fn parse_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
id_path_reg,
custom_id_path_reg,
code_ref_path_reg,
protocol_path_reg,
fuzzy_path_reg,
))(input)
}
@@ -172,6 +174,19 @@ fn code_ref_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>
))
}
fn protocol_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
let (remaining, (raw_link, (protocol, _, path))) =
consumed(tuple((take_until(":"), tag(":"), rest)))(input)?;
Ok((
remaining,
PathReg {
link_type: LinkType::Protocol(protocol.into()),
path: path.into(),
raw_link: raw_link.into(),
},
))
}
fn fuzzy_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
let (remaining, body) = rest(input)?;
Ok((