Populate citation reference properties.
This commit is contained in:
parent
1ecc3ecf9d
commit
c077d34933
@ -3347,14 +3347,45 @@ fn compare_footnote_reference<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_citation<'b, 's>(
|
fn compare_citation<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Citation<'s>,
|
rust: &'b Citation<'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 child_status = Vec::new();
|
||||||
let message = None;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :style :prefix :suffix
|
compare_children(
|
||||||
|
source,
|
||||||
|
emacs,
|
||||||
|
&rust.children,
|
||||||
|
&mut child_status,
|
||||||
|
&mut this_status,
|
||||||
|
&mut message,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
if let Some((new_status, new_message)) = compare_properties!(
|
||||||
|
emacs,
|
||||||
|
rust,
|
||||||
|
(
|
||||||
|
EmacsField::Required(":style"),
|
||||||
|
|r| r.style,
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":prefix"),
|
||||||
|
|r| r.prefix,
|
||||||
|
compare_property_unquoted_atom
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":suffix"),
|
||||||
|
|r| r.suffix,
|
||||||
|
compare_property_unquoted_atom
|
||||||
|
)
|
||||||
|
)? {
|
||||||
|
this_status = new_status;
|
||||||
|
message = new_message;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
@ -3375,7 +3406,30 @@ fn compare_citation_reference<'b, 's>(
|
|||||||
let this_status = DiffStatus::Good;
|
let this_status = DiffStatus::Good;
|
||||||
let message = None;
|
let message = None;
|
||||||
|
|
||||||
// TODO: Compare :key :prefix :suffix
|
assert_no_children(emacs, &mut this_status, &mut message)?;
|
||||||
|
|
||||||
|
if let Some((new_status, new_message)) = compare_properties!(
|
||||||
|
emacs,
|
||||||
|
rust,
|
||||||
|
(
|
||||||
|
EmacsField::Required(":key"),
|
||||||
|
|r| Some(r.key),
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":prefix"),
|
||||||
|
|r| r.prefix,
|
||||||
|
compare_property_unquoted_atom
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":suffix"),
|
||||||
|
|r| r.suffix,
|
||||||
|
compare_property_unquoted_atom
|
||||||
|
)
|
||||||
|
)? {
|
||||||
|
this_status = new_status;
|
||||||
|
message = new_message;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
|
@ -33,10 +33,10 @@ pub(crate) fn citation_reference<'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>, CitationReference<'s>> {
|
) -> Res<OrgSource<'s>, CitationReference<'s>> {
|
||||||
let (remaining, _prefix) =
|
let (remaining, prefix) =
|
||||||
must_balance_bracket(opt(parser_with_context!(key_prefix)(context)))(input)?;
|
must_balance_bracket(opt(parser_with_context!(key_prefix)(context)))(input)?;
|
||||||
let (remaining, _key) = parser_with_context!(citation_reference_key)(context)(remaining)?;
|
let (remaining, key) = parser_with_context!(citation_reference_key)(context)(remaining)?;
|
||||||
let (remaining, _suffix) =
|
let (remaining, suffix) =
|
||||||
must_balance_bracket(opt(parser_with_context!(key_suffix)(context)))(remaining)?;
|
must_balance_bracket(opt(parser_with_context!(key_suffix)(context)))(remaining)?;
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
|
|
||||||
@ -44,6 +44,9 @@ pub(crate) fn citation_reference<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
CitationReference {
|
CitationReference {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
key: key.into(),
|
||||||
|
prefix: prefix.unwrap_or(Vec::new()),
|
||||||
|
suffix: suffix.unwrap_or(Vec::new()),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,9 @@ pub struct Citation<'s> {
|
|||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CitationReference<'s> {
|
pub struct CitationReference<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub key: &'s str,
|
||||||
|
pub prefix: Vec<Object<'s>>,
|
||||||
|
pub suffix: Vec<Object<'s>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user