From 5171326d63dc94d2737d015dd94fe31383bb6182 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 31 Aug 2023 19:02:18 -0400 Subject: [PATCH] Create a test for special blocks. --- .../greater_element/greater_block/special_block.org | 5 +++++ src/parser/greater_block.rs | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 org_mode_samples/greater_element/greater_block/special_block.org 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,