diff --git a/org_mode_samples/object/inline_source_block/simple.org b/org_mode_samples/object/inline_source_block/simple.org index 1be62f1..6269c61 100644 --- a/org_mode_samples/object/inline_source_block/simple.org +++ b/org_mode_samples/object/inline_source_block/simple.org @@ -1,2 +1,3 @@ -before src_foo{ipsum} after -src_bar[lorem]{ipsum} +src_foo{} +before src_bar{lorem} after +src_baz[ipsum]{dolar} diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 5cead57..efdc3d3 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -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, Box> { - 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, } diff --git a/src/parser/inline_source_block.rs b/src/parser/inline_source_block.rs index cf41e2e..07969c3 100644 --- a/src/parser/inline_source_block.rs +++ b/src/parser/inline_source_block.rs @@ -36,9 +36,9 @@ pub(crate) fn inline_source_block<'b, 'g, 'r, 's>( input: OrgSource<'s>, ) -> Res, 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(), }, )) } diff --git a/src/types/object.rs b/src/types/object.rs index 004abdf..b35803f 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -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)]