Create a test for special blocks.

This commit is contained in:
Tom Alexander 2023-08-31 19:02:18 -04:00
parent 67f79aeb51
commit 5171326d63
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 10 additions and 5 deletions

View File

@ -0,0 +1,5 @@
#+begin_defun
foo
{{{bar(baz)}}}
#+end_defun

View File

@ -49,11 +49,11 @@ pub fn greater_block<'r, 's>(
}),
))(remaining)?;
let context_name = match Into::<&str>::into(name).to_lowercase().as_str() {
"center" => "center block",
"quote" => "quote block",
_ => "greater block",
"center" => "center block".to_owned(),
"quote" => "quote block".to_owned(),
name @ _ => format!("special block {}", name),
};
if immediate_in_section(context, context_name) {
if immediate_in_section(context, context_name.as_str()) {
return Err(nom::Err::Error(CustomError::MyError(MyError(
"Cannot nest objects of the same element".into(),
))));
@ -63,7 +63,7 @@ pub fn greater_block<'r, 's>(
let (remaining, _nl) = line_ending(remaining)?;
let parser_context = context
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(true))
.with_additional_node(ContextElement::Context(context_name))
.with_additional_node(ContextElement::Context(context_name.as_str()))
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
class: ExitClass::Alpha,
exit_matcher: &exit_with_name,