Do not allow elements to immediately nest inside themselves.
Plain list is omitted because they can nest.
This commit is contained in:
@@ -2,6 +2,8 @@ use super::error::Res;
|
||||
use super::util::WORD_CONSTITUENT_CHARACTERS;
|
||||
use super::Context;
|
||||
use crate::parser::element::element;
|
||||
use crate::parser::error::CustomError;
|
||||
use crate::parser::error::MyError;
|
||||
use crate::parser::exiting::ExitClass;
|
||||
use crate::parser::greater_element::FootnoteDefinition;
|
||||
use crate::parser::parser_context::ContextElement;
|
||||
@@ -10,6 +12,7 @@ use crate::parser::parser_with_context::parser_with_context;
|
||||
use crate::parser::util::blank_line;
|
||||
use crate::parser::util::exit_matcher_parser;
|
||||
use crate::parser::util::get_consumed;
|
||||
use crate::parser::util::immediate_in_section;
|
||||
use crate::parser::util::maybe_consume_trailing_whitespace;
|
||||
use crate::parser::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||
use crate::parser::util::start_of_line;
|
||||
@@ -30,12 +33,18 @@ pub fn footnote_definition<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, FootnoteDefinition<'s>> {
|
||||
if immediate_in_section(context, "footnote definition") {
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"Cannot nest objects of the same element",
|
||||
))));
|
||||
}
|
||||
start_of_line(context, input)?;
|
||||
// Cannot be indented.
|
||||
let (remaining, (_lead_in, lbl, _lead_out, _ws)) =
|
||||
tuple((tag_no_case("[fn:"), label, tag("]"), space0))(input)?;
|
||||
let parser_context = context
|
||||
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(true))
|
||||
.with_additional_node(ContextElement::Context("footnote definition"))
|
||||
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Alpha,
|
||||
exit_matcher: &footnote_definition_end,
|
||||
|
||||
Reference in New Issue
Block a user