diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 9c82f01..cef815e 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -1845,9 +1845,19 @@ fn compare_export_block<'b, 's>( let mut this_status = DiffStatus::Good; let mut message = None; - // TODO: Compare :type // TODO: Compare :caption + // Compare type + let export_type = get_property_quoted_string(emacs, ":type")?; + let rust_export_type = rust.get_export_type(); + if export_type != rust_export_type { + this_status = DiffStatus::Bad; + message = Some(format!( + "Export type mismatch (emacs != rust) {:?} != {:?}", + export_type, rust.export_type + )); + } + // Compare value let contents = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new()); if contents != rust.contents { diff --git a/src/parser/lesser_block.rs b/src/parser/lesser_block.rs index 994f4f7..fe987cb 100644 --- a/src/parser/lesser_block.rs +++ b/src/parser/lesser_block.rs @@ -208,6 +208,9 @@ pub(crate) fn export_block<'b, 'g, 'r, 's>( let (input, affiliated_keywords) = many0(affiliated_keyword)(input)?; let (remaining, _) = lesser_block_begin("export")(context, input)?; // https://orgmode.org/worg/org-syntax.html#Blocks claims that export blocks must have a single word for data but testing shows no data and multi-word data still parses as an export block. + let (remaining, export_type) = opt(map(tuple((space1, switch_word)), |(_, export_type)| { + export_type + }))(remaining)?; let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?; let (remaining, _nl) = recognize(tuple((space0, line_ending)))(remaining)?; let lesser_block_end_specialized = lesser_block_end("export"); @@ -236,6 +239,7 @@ pub(crate) fn export_block<'b, 'g, 'r, 's>( ExportBlock { source: source.into(), name: get_name(&affiliated_keywords), + export_type: export_type.map(Into::<&str>::into), data: parameters.map(|parameters| Into::<&str>::into(parameters)), contents, }, diff --git a/src/types/lesser_element.rs b/src/types/lesser_element.rs index b62f61c..4b41a56 100644 --- a/src/types/lesser_element.rs +++ b/src/types/lesser_element.rs @@ -64,6 +64,7 @@ pub struct ExampleBlock<'s> { pub struct ExportBlock<'s> { pub source: &'s str, pub name: Option<&'s str>, + pub export_type: Option<&'s str>, pub data: Option<&'s str>, pub contents: String, } @@ -266,3 +267,9 @@ impl<'s> Comment<'s> { ret } } + +impl<'s> ExportBlock<'s> { + pub fn get_export_type(&self) -> Option { + self.export_type.map(|s| s.to_uppercase()) + } +}