Compare inline source block properties.
This commit is contained in:
parent
69500837f2
commit
4bc2f48738
@ -1,2 +1,3 @@
|
||||
before src_foo{ipsum} after
|
||||
src_bar[lorem]{ipsum}
|
||||
src_foo{}
|
||||
before src_bar{lorem} after
|
||||
src_baz[ipsum]{dolar}
|
||||
|
@ -3654,20 +3654,51 @@ fn compare_inline_babel_call<'b, 's>(
|
||||
}
|
||||
|
||||
fn compare_inline_source_block<'b, 's>(
|
||||
_source: &'s str,
|
||||
source: &'s str,
|
||||
emacs: &'b Token<'s>,
|
||||
rust: &'b InlineSourceBlock<'s>,
|
||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||
let this_status = DiffStatus::Good;
|
||||
let message = None;
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut child_status = Vec::new();
|
||||
let mut message = None;
|
||||
|
||||
// TODO: Compare :language :value :parameters
|
||||
assert_no_children(emacs, &mut this_status, &mut message)?;
|
||||
|
||||
for diff in compare_properties!(
|
||||
source,
|
||||
emacs,
|
||||
rust,
|
||||
(
|
||||
EmacsField::Required(":language"),
|
||||
|r| Some(r.language),
|
||||
compare_property_quoted_string
|
||||
),
|
||||
(
|
||||
EmacsField::Required(":value"),
|
||||
|r| Some(r.value),
|
||||
compare_property_quoted_string
|
||||
),
|
||||
(
|
||||
EmacsField::Required(":parameters"),
|
||||
|r| r.parameters,
|
||||
compare_property_quoted_string
|
||||
)
|
||||
) {
|
||||
match diff {
|
||||
ComparePropertiesResult::NoChange => {}
|
||||
ComparePropertiesResult::SelfChange(new_status, new_message) => {
|
||||
this_status = new_status;
|
||||
message = new_message
|
||||
}
|
||||
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
|
||||
}
|
||||
}
|
||||
|
||||
Ok(DiffResult {
|
||||
status: this_status,
|
||||
name: rust.get_elisp_name(),
|
||||
message,
|
||||
children: Vec::new(),
|
||||
children: child_status,
|
||||
rust_source: rust.get_source(),
|
||||
emacs_token: emacs,
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ pub(crate) fn inline_source_block<'b, 'g, 'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, InlineSourceBlock<'s>> {
|
||||
let (remaining, _) = tag_no_case("src_")(input)?;
|
||||
let (remaining, _) = lang(context, remaining)?;
|
||||
let (remaining, _header1) = opt(parser_with_context!(header)(context))(remaining)?;
|
||||
let (remaining, _body) = body(context, remaining)?;
|
||||
let (remaining, language) = lang(context, remaining)?;
|
||||
let (remaining, parameters) = opt(parser_with_context!(header)(context))(remaining)?;
|
||||
let (remaining, value) = body(context, remaining)?;
|
||||
let (remaining, _trailing_whitespace) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
@ -46,6 +46,9 @@ pub(crate) fn inline_source_block<'b, 'g, 'r, 's>(
|
||||
remaining,
|
||||
InlineSourceBlock {
|
||||
source: source.into(),
|
||||
language: language.into(),
|
||||
parameters: parameters.map(Into::<&str>::into),
|
||||
value: value.into(),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -227,6 +227,9 @@ pub struct InlineBabelCall<'s> {
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct InlineSourceBlock<'s> {
|
||||
pub source: &'s str,
|
||||
pub language: &'s str,
|
||||
pub parameters: Option<&'s str>,
|
||||
pub value: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
Loading…
Reference in New Issue
Block a user