Switches are not stored for comment blocks, but they are allowed to appear.

This commit is contained in:
Tom Alexander 2023-10-04 09:51:28 -04:00
parent 2eaef82fdb
commit 4cdf88a632
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
5 changed files with 24 additions and 10 deletions

View File

@ -0,0 +1,3 @@
#+begin_comment -n 20
foo
#+end_comment

View File

@ -0,0 +1,7 @@
#+begin_example -n 5
foo
#+end_example
#+begin_example +n 10
foo
#+end_example

View File

@ -1542,10 +1542,20 @@ fn compare_example_block<'b, 's>(
emacs: &'b Token<'s>,
rust: &'b ExampleBlock<'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 message = None;
// TODO: Compare :value :switches :number-lines :preserve-indent :retain-labels :use-labels :label-fmt
// TODO: Compare :switches :number-lines :preserve-indent :retain-labels :use-labels :label-fmt
// 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
));
}
Ok(DiffResult {
status: this_status,

View File

@ -95,7 +95,7 @@ pub(crate) fn comment_block<'b, 'g, 'r, 's>(
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, CommentBlock<'s>> {
let (remaining, name) = lesser_block_begin("comment")(context, input)?;
let (remaining, parameters) = opt(tuple((space1, data)))(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("comment");
let contexts = [
@ -109,10 +109,6 @@ pub(crate) fn comment_block<'b, 'g, 'r, 's>(
let parser_context = context.with_additional_node(&contexts[0]);
let parser_context = parser_context.with_additional_node(&contexts[1]);
let parser_context = parser_context.with_additional_node(&contexts[2]);
let parameters = match parameters {
Some((_ws, parameters)) => Some(parameters),
None => None,
};
let (remaining, contents) = parser_with_context!(text_until_exit)(&parser_context)(remaining)?;
let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?;
@ -123,7 +119,6 @@ pub(crate) fn comment_block<'b, 'g, 'r, 's>(
CommentBlock {
source: source.into(),
name: name.into(),
data: parameters.map(|parameters| Into::<&str>::into(parameters)),
contents: contents.into(),
},
))

View File

@ -33,7 +33,6 @@ pub struct VerseBlock<'s> {
pub struct CommentBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub data: Option<&'s str>,
pub contents: &'s str,
}