Allow :: to end links regardless of parenthesis.
This commit is contained in:
parent
8bc79f9ef3
commit
b64c1c944b
@ -3002,10 +3002,55 @@ fn compare_angle_link<'b, 's>(
|
|||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b AngleLink<'s>,
|
rust: &'b AngleLink<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :type :path :format :raw-link :application :search-option
|
if let Some((new_status, new_message)) = compare_properties!(
|
||||||
|
emacs,
|
||||||
|
rust,
|
||||||
|
(
|
||||||
|
EmacsField::Required(":type"),
|
||||||
|
|r| {
|
||||||
|
match &r.link_type {
|
||||||
|
LinkType::File => Some(Cow::Borrowed("file")),
|
||||||
|
LinkType::Protocol(protocol) => Some(protocol.clone()),
|
||||||
|
LinkType::Id => Some(Cow::Borrowed("id")),
|
||||||
|
LinkType::CustomId => Some(Cow::Borrowed("custom-id")),
|
||||||
|
LinkType::CodeRef => Some(Cow::Borrowed("coderef")),
|
||||||
|
LinkType::Fuzzy => Some(Cow::Borrowed("fuzzy")),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":path"),
|
||||||
|
|r| Some(r.path),
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":format"),
|
||||||
|
|_| Some("plain"),
|
||||||
|
compare_property_unquoted_atom
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":raw-link"),
|
||||||
|
|r| Some(r.raw_link),
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":application"),
|
||||||
|
|r| r.application,
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":search-option"),
|
||||||
|
|r| r.search_option,
|
||||||
|
compare_property_quoted_string
|
||||||
|
)
|
||||||
|
)? {
|
||||||
|
this_status = new_status;
|
||||||
|
message = new_message;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
|
@ -34,8 +34,11 @@ pub(crate) fn angle_link<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
AngleLink {
|
AngleLink {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
link_type: proto.into(),
|
link_type: todo!(),
|
||||||
path: path.into(),
|
path: path.into(),
|
||||||
|
raw_link: todo!(),
|
||||||
|
search_option: todo!(),
|
||||||
|
application: todo!(),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ fn impl_path_plain_end<'b, 'g, 'r, 's>(
|
|||||||
enable_search_option: bool,
|
enable_search_option: bool,
|
||||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||||
let current_depth = input.get_parenthesis_depth() - starting_parenthesis_depth;
|
let current_depth = input.get_parenthesis_depth() - starting_parenthesis_depth;
|
||||||
if enable_search_option && current_depth == 0 {
|
if enable_search_option {
|
||||||
let search_option = peek(tag("::"))(input);
|
let search_option = peek(tag("::"))(input);
|
||||||
if search_option.is_ok() {
|
if search_option.is_ok() {
|
||||||
return search_option;
|
return search_option;
|
||||||
|
@ -285,17 +285,9 @@ fn file_path_reg<'b, 'g, 'r, 's>(
|
|||||||
take,
|
take,
|
||||||
)),
|
)),
|
||||||
parser_with_context!(text_until_exit)(&parser_context),
|
parser_with_context!(text_until_exit)(&parser_context),
|
||||||
opt(map(
|
opt(map(tuple((tag("::"), rest)), |(_, search_option)| {
|
||||||
tuple((
|
search_option
|
||||||
tag("::"),
|
})),
|
||||||
verify(rest, |search_option| {
|
|
||||||
Into::<&str>::into(search_option)
|
|
||||||
.chars()
|
|
||||||
.any(char::is_alphanumeric)
|
|
||||||
}),
|
|
||||||
)),
|
|
||||||
|(_, search_option)| search_option,
|
|
||||||
)),
|
|
||||||
)))(input)?;
|
)))(input)?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
@ -447,11 +439,10 @@ fn path_reg_end(
|
|||||||
fn impl_path_reg_end<'b, 'g, 'r, 's>(
|
fn impl_path_reg_end<'b, 'g, 'r, 's>(
|
||||||
_context: RefContext<'b, 'g, 'r, 's>,
|
_context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
starting_parenthesis_depth: BracketDepth,
|
_starting_parenthesis_depth: BracketDepth,
|
||||||
enable_search_option: bool,
|
enable_search_option: bool,
|
||||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||||
let current_depth = input.get_parenthesis_depth() - starting_parenthesis_depth;
|
if enable_search_option {
|
||||||
if enable_search_option && current_depth == 0 {
|
|
||||||
let search_option = peek(tag("::"))(input);
|
let search_option = peek(tag("::"))(input);
|
||||||
if search_option.is_ok() {
|
if search_option.is_ok() {
|
||||||
return search_option;
|
return search_option;
|
||||||
|
@ -115,8 +115,11 @@ pub struct PlainLink<'s> {
|
|||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct AngleLink<'s> {
|
pub struct AngleLink<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
pub link_type: &'s str,
|
pub link_type: LinkType<'s>,
|
||||||
pub path: &'s str,
|
pub path: &'s str,
|
||||||
|
pub raw_link: &'s str,
|
||||||
|
pub search_option: Option<&'s str>,
|
||||||
|
pub application: Option<&'s str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
Loading…
Reference in New Issue
Block a user