Fix greater blocks by preventing nesting even if they are not the immediate parent.

This commit is contained in:
Tom Alexander 2023-08-31 19:17:46 -04:00
parent 949d0989f4
commit 510985e97c
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -12,6 +12,7 @@ use nom::multi::many_till;
use nom::sequence::tuple; use nom::sequence::tuple;
use super::org_source::OrgSource; use super::org_source::OrgSource;
use super::util::in_section;
use super::Context; use super::Context;
use crate::error::CustomError; use crate::error::CustomError;
use crate::error::MyError; use crate::error::MyError;
@ -26,7 +27,6 @@ use crate::parser::source::SetSource;
use crate::parser::util::blank_line; use crate::parser::util::blank_line;
use crate::parser::util::exit_matcher_parser; use crate::parser::util::exit_matcher_parser;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::parser::util::immediate_in_section;
use crate::parser::util::start_of_line; use crate::parser::util::start_of_line;
use crate::parser::Element; use crate::parser::Element;
use crate::parser::Paragraph; use crate::parser::Paragraph;
@ -53,7 +53,7 @@ pub fn greater_block<'r, 's>(
"quote" => "quote block".to_owned(), "quote" => "quote block".to_owned(),
name @ _ => format!("special block {}", name), name @ _ => format!("special block {}", name),
}; };
if immediate_in_section(context, context_name.as_str()) { if in_section(context, context_name.as_str()) {
return Err(nom::Err::Error(CustomError::MyError(MyError( return Err(nom::Err::Error(CustomError::MyError(MyError(
"Cannot nest objects of the same element".into(), "Cannot nest objects of the same element".into(),
)))); ))));