Fix comparing key and mark prefix/suffix as optional.
This commit is contained in:
parent
f6155ecf93
commit
8a0f9d4540
@ -14,7 +14,6 @@ use crate::types::AstNode;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) enum EmacsField<'s> {
|
pub(crate) enum EmacsField<'s> {
|
||||||
Required(&'s str),
|
Required(&'s str),
|
||||||
#[allow(dead_code)]
|
|
||||||
Optional(&'s str),
|
Optional(&'s str),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3492,13 +3492,21 @@ fn compare_citation<'b, 's>(
|
|||||||
compare_property_quoted_string
|
compare_property_quoted_string
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
EmacsField::Required(":prefix"),
|
EmacsField::Optional(":prefix"),
|
||||||
|r| Some(r.prefix.iter()),
|
|r| if r.prefix.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(r.prefix.iter())
|
||||||
|
},
|
||||||
compare_property_list_of_ast_nodes
|
compare_property_list_of_ast_nodes
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
EmacsField::Required(":suffix"),
|
EmacsField::Optional(":suffix"),
|
||||||
|r| Some(r.suffix.iter()),
|
|r| if r.suffix.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(r.suffix.iter())
|
||||||
|
},
|
||||||
compare_property_list_of_ast_nodes
|
compare_property_list_of_ast_nodes
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@ -3544,13 +3552,21 @@ fn compare_citation_reference<'b, 's>(
|
|||||||
compare_property_quoted_string
|
compare_property_quoted_string
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
EmacsField::Required(":prefix"),
|
EmacsField::Optional(":prefix"),
|
||||||
|r| Some(r.prefix.iter()),
|
|r| if r.prefix.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(r.prefix.iter())
|
||||||
|
},
|
||||||
compare_property_list_of_ast_nodes
|
compare_property_list_of_ast_nodes
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
EmacsField::Required(":suffix"),
|
EmacsField::Optional(":suffix"),
|
||||||
|r| Some(r.suffix.iter()),
|
|r| if r.suffix.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(r.suffix.iter())
|
||||||
|
},
|
||||||
compare_property_list_of_ast_nodes
|
compare_property_list_of_ast_nodes
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
use nom::character::complete::anychar;
|
use nom::character::complete::anychar;
|
||||||
|
use nom::combinator::map;
|
||||||
use nom::combinator::not;
|
use nom::combinator::not;
|
||||||
use nom::combinator::opt;
|
use nom::combinator::opt;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
@ -56,18 +57,22 @@ pub(crate) fn citation_reference_key<'b, 'g, 'r, 's>(
|
|||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||||
let (remaining, source) = recognize(tuple((
|
let (remaining, source) = map(
|
||||||
tag("@"),
|
tuple((
|
||||||
many1(verify(
|
tag("@"),
|
||||||
preceded(
|
recognize(many1(verify(
|
||||||
not(parser_with_context!(exit_matcher_parser)(context)),
|
preceded(
|
||||||
anychar,
|
not(parser_with_context!(exit_matcher_parser)(context)),
|
||||||
),
|
anychar,
|
||||||
|c| {
|
),
|
||||||
WORD_CONSTITUENT_CHARACTERS.contains(*c) || "-.:?~`'/*@+|(){}<>&_^$#%~".contains(*c)
|
|c| {
|
||||||
},
|
WORD_CONSTITUENT_CHARACTERS.contains(*c)
|
||||||
|
|| "-.:?~`'/*@+|(){}<>&_^$#%~".contains(*c)
|
||||||
|
},
|
||||||
|
))),
|
||||||
)),
|
)),
|
||||||
)))(input)?;
|
|(_, key)| key,
|
||||||
|
)(input)?;
|
||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user