Only allow a single section under a heading.
This commit is contained in:
@@ -283,10 +283,14 @@ fn _heading<'r, 's>(
|
||||
headline(context, input, parent_stars)?;
|
||||
let section_matcher = parser_with_context!(section)(context);
|
||||
let heading_matcher = parser_with_context!(heading(star_count))(context);
|
||||
let (remaining, children) = many0(alt((
|
||||
map(heading_matcher, DocumentElement::Heading),
|
||||
map(section_matcher, DocumentElement::Section),
|
||||
)))(remaining)?;
|
||||
let (remaining, maybe_section) =
|
||||
opt(map(section_matcher, DocumentElement::Section))(remaining)?;
|
||||
let (remaining, mut children) =
|
||||
many0(map(heading_matcher, DocumentElement::Heading))(remaining)?;
|
||||
if let Some(section) = maybe_section {
|
||||
children.insert(0, section);
|
||||
}
|
||||
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((
|
||||
remaining,
|
||||
|
||||
Reference in New Issue
Block a user