Set up regular links for adding application.

This commit is contained in:
Tom Alexander
2023-10-07 03:14:16 -04:00
parent 0c34df159f
commit 7196e10b69
5 changed files with 18 additions and 3 deletions

View File

@@ -69,6 +69,7 @@ fn regular_link_without_description<'b, 'g, 'r, 's>(
raw_link: path.raw_link,
search_option: path.search_option,
children: Vec::new(),
application: path.application,
},
))
}
@@ -95,6 +96,7 @@ fn regular_link_with_description<'b, 'g, 'r, 's>(
raw_link: path.raw_link,
search_option: path.search_option,
children: description,
application: path.application,
},
))
}
@@ -105,6 +107,7 @@ struct PathReg<'s> {
path: Cow<'s, str>,
raw_link: Cow<'s, str>,
search_option: Option<Cow<'s, str>>,
application: Option<Cow<'s, str>>,
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
@@ -161,6 +164,7 @@ fn parse_path_reg<'b, 'g, 'r, 's>(
path: link.path.into_owned().into(),
raw_link: link.raw_link.into_owned().into(),
search_option: link.search_option.map(|s| s.into_owned().into()),
application: link.application.map(|s| s.into_owned().into()),
},
))
} else {
@@ -240,6 +244,8 @@ fn apply_link_templates<'b, 'g, 'r, 's>(
}
fn file_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
// TODO: Update this to parse out the application like plain link does.
// TODO: Handle parenthesis like plain link does.
let (remaining, (raw_link, (_, path, search_option))) = consumed(tuple((
alt((tag("file:"), peek(tag(".")), peek(tag("/")))),
recognize(many_till(anychar, alt((peek(tag("::")), eof)))),
@@ -256,6 +262,7 @@ fn file_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
search_option: search_option
.map(Into::<&str>::into)
.map(Into::<Cow<str>>::into),
application: todo!(),
},
))
}
@@ -269,6 +276,7 @@ fn id_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
path: path.into(),
raw_link: raw_link.into(),
search_option: None,
application: None,
},
))
}
@@ -282,6 +290,7 @@ fn custom_id_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s
path: path.into(),
raw_link: raw_link.into(),
search_option: None,
application: None,
},
))
}
@@ -299,6 +308,7 @@ fn code_ref_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>
path: path.into(),
raw_link: raw_link.into(),
search_option: None,
application: None,
},
))
}
@@ -319,6 +329,7 @@ fn protocol_path_reg<'b, 'g, 'r, 's>(
path: path.into(),
raw_link: raw_link.into(),
search_option: None,
application: None,
},
))
}
@@ -332,6 +343,7 @@ fn fuzzy_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
path: body.into(),
raw_link: body.into(),
search_option: None,
application: None,
},
))
}