diff --git a/org_mode_samples/greater_element/greater_block/special_block.org b/org_mode_samples/greater_element/greater_block/special_block.org new file mode 100644 index 00000000..d3b6df10 --- /dev/null +++ b/org_mode_samples/greater_element/greater_block/special_block.org @@ -0,0 +1,5 @@ +#+begin_defun +foo + +{{{bar(baz)}}} +#+end_defun diff --git a/src/parser/greater_block.rs b/src/parser/greater_block.rs index 85dc7e35..ff7f59c8 100644 --- a/src/parser/greater_block.rs +++ b/src/parser/greater_block.rs @@ -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,