Compare value for export block.

This commit is contained in:
Tom Alexander 2023-10-05 02:06:26 -04:00
parent 386ad5091d
commit 1da521b08a
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
8 changed files with 38 additions and 5 deletions

View File

@ -0,0 +1,10 @@
#+begin_comment
,* foo
,,,** bar
,*** baz
lorem
, ipsum
,#+begin_src dolar
,#+end_src
#+end_comment

View File

@ -0,0 +1,10 @@
#+begin_export html
,* foo
,,,** bar
,*** baz
lorem
, ipsum
,#+begin_src dolar
,#+end_src
#+end_export

View File

@ -0,0 +1,3 @@
#+begin_export latex
This would be LaTeX code.
#+end_export

View File

@ -1845,9 +1845,19 @@ fn compare_export_block<'b, 's>(
let mut this_status = DiffStatus::Good;
let mut message = None;
// TODO: Compare :type :value
// TODO: Compare :type
// TODO: Compare :caption
// Compare value
let contents = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new());
if contents != rust.contents {
this_status = DiffStatus::Bad;
message = Some(format!(
"Value mismatch (emacs != rust) {:?} != {:?}",
contents, rust.contents
));
}
// Compare name
let name = get_property_quoted_string(emacs, ":name")?;
if name.as_ref().map(String::as_str) != rust.name {

View File

@ -227,7 +227,7 @@ pub(crate) fn export_block<'b, 'g, 'r, 's>(
None => None,
};
let (remaining, contents) = parser_with_context!(text_until_exit)(&parser_context)(remaining)?;
let (remaining, contents) = content(&parser_context, remaining)?;
let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?;
let source = get_consumed(input, remaining);
@ -237,7 +237,7 @@ pub(crate) fn export_block<'b, 'g, 'r, 's>(
source: source.into(),
name: get_name(&affiliated_keywords),
data: parameters.map(|parameters| Into::<&str>::into(parameters)),
contents: contents.into(),
contents,
},
))
}

View File

@ -65,7 +65,7 @@ pub struct ExportBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub data: Option<&'s str>,
pub contents: &'s str,
pub contents: String,
}
#[derive(Debug)]