Set up regular links for adding application.
This commit is contained in:
parent
0c34df159f
commit
7196e10b69
2
org_mode_samples/object/regular_link/search_option.org
Normal file
2
org_mode_samples/object/regular_link/search_option.org
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Does not become a search option because it is inside parenthesis.
|
||||||
|
[[https://en.wikipedia.org/wiki/Shebang_(Uni::x)]]
|
@ -2802,8 +2802,8 @@ fn compare_regular_link<'b, 's>(
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
EmacsField::Required(":application"),
|
EmacsField::Required(":application"),
|
||||||
compare_identity,
|
|r| r.application.as_ref(),
|
||||||
compare_property_always_nil
|
compare_property_quoted_string
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
EmacsField::Required(":search-option"),
|
EmacsField::Required(":search-option"),
|
||||||
|
@ -111,7 +111,7 @@ fn parse_path_plain<'b, 'g, 'r, 's>(
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_file_and_application<'s>(
|
pub(crate) fn parse_file_and_application<'s>(
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> {
|
) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> {
|
||||||
let (remaining, _) = tag("file")(input)?;
|
let (remaining, _) = tag("file")(input)?;
|
||||||
|
@ -69,6 +69,7 @@ fn regular_link_without_description<'b, 'g, 'r, 's>(
|
|||||||
raw_link: path.raw_link,
|
raw_link: path.raw_link,
|
||||||
search_option: path.search_option,
|
search_option: path.search_option,
|
||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
|
application: path.application,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -95,6 +96,7 @@ fn regular_link_with_description<'b, 'g, 'r, 's>(
|
|||||||
raw_link: path.raw_link,
|
raw_link: path.raw_link,
|
||||||
search_option: path.search_option,
|
search_option: path.search_option,
|
||||||
children: description,
|
children: description,
|
||||||
|
application: path.application,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -105,6 +107,7 @@ struct PathReg<'s> {
|
|||||||
path: Cow<'s, str>,
|
path: Cow<'s, str>,
|
||||||
raw_link: Cow<'s, str>,
|
raw_link: Cow<'s, str>,
|
||||||
search_option: Option<Cow<'s, str>>,
|
search_option: Option<Cow<'s, str>>,
|
||||||
|
application: Option<Cow<'s, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[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(),
|
path: link.path.into_owned().into(),
|
||||||
raw_link: link.raw_link.into_owned().into(),
|
raw_link: link.raw_link.into_owned().into(),
|
||||||
search_option: link.search_option.map(|s| s.into_owned().into()),
|
search_option: link.search_option.map(|s| s.into_owned().into()),
|
||||||
|
application: link.application.map(|s| s.into_owned().into()),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
} else {
|
} 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>> {
|
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((
|
let (remaining, (raw_link, (_, path, search_option))) = consumed(tuple((
|
||||||
alt((tag("file:"), peek(tag(".")), peek(tag("/")))),
|
alt((tag("file:"), peek(tag(".")), peek(tag("/")))),
|
||||||
recognize(many_till(anychar, alt((peek(tag("::")), eof)))),
|
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
|
search_option: search_option
|
||||||
.map(Into::<&str>::into)
|
.map(Into::<&str>::into)
|
||||||
.map(Into::<Cow<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(),
|
path: path.into(),
|
||||||
raw_link: raw_link.into(),
|
raw_link: raw_link.into(),
|
||||||
search_option: None,
|
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(),
|
path: path.into(),
|
||||||
raw_link: raw_link.into(),
|
raw_link: raw_link.into(),
|
||||||
search_option: None,
|
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(),
|
path: path.into(),
|
||||||
raw_link: raw_link.into(),
|
raw_link: raw_link.into(),
|
||||||
search_option: None,
|
search_option: None,
|
||||||
|
application: None,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -319,6 +329,7 @@ fn protocol_path_reg<'b, 'g, 'r, 's>(
|
|||||||
path: path.into(),
|
path: path.into(),
|
||||||
raw_link: raw_link.into(),
|
raw_link: raw_link.into(),
|
||||||
search_option: None,
|
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(),
|
path: body.into(),
|
||||||
raw_link: body.into(),
|
raw_link: body.into(),
|
||||||
search_option: None,
|
search_option: None,
|
||||||
|
application: None,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ pub struct RegularLink<'s> {
|
|||||||
pub raw_link: Cow<'s, str>,
|
pub raw_link: Cow<'s, str>,
|
||||||
pub search_option: Option<Cow<'s, str>>,
|
pub search_option: Option<Cow<'s, str>>,
|
||||||
pub children: Vec<Object<'s>>,
|
pub children: Vec<Object<'s>>,
|
||||||
|
pub application: Option<Cow<'s, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
Loading…
Reference in New Issue
Block a user