Implement the new fields for section.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use nom::combinator::consumed;
|
||||
use nom::combinator::opt;
|
||||
use nom::combinator::recognize;
|
||||
use nom::combinator::verify;
|
||||
@@ -58,12 +59,12 @@ pub(crate) fn zeroth_section<'b, 'g, 'r, 's>(
|
||||
many0(blank_line),
|
||||
)))(input)?;
|
||||
|
||||
let (remaining, (mut children, _exit_contents)) = verify(
|
||||
let (remaining, (contents, (mut children, _exit_contents))) = consumed(verify(
|
||||
many_till(element_matcher, exit_matcher),
|
||||
|(children, _exit_contents)| {
|
||||
!children.is_empty() || comment_and_property_drawer_element.is_some()
|
||||
},
|
||||
)(remaining)?;
|
||||
))(remaining)?;
|
||||
|
||||
if let Some((comment, property_drawer, _ws)) = comment_and_property_drawer_element {
|
||||
children.insert(0, Element::PropertyDrawer(property_drawer));
|
||||
@@ -72,7 +73,7 @@ pub(crate) fn zeroth_section<'b, 'g, 'r, 's>(
|
||||
}
|
||||
}
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
|
||||
let source = get_consumed(input, remaining);
|
||||
@@ -80,6 +81,8 @@ pub(crate) fn zeroth_section<'b, 'g, 'r, 's>(
|
||||
remaining,
|
||||
Section {
|
||||
source: source.into(),
|
||||
contents: Some(contents.into()),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
children,
|
||||
},
|
||||
))
|
||||
@@ -115,12 +118,12 @@ pub(crate) fn section<'b, 'g, 'r, 's>(
|
||||
remaining = remain;
|
||||
input = remain;
|
||||
}
|
||||
let (remaining, (mut children, _exit_contents)) = verify(
|
||||
let (remaining, (contents, (mut children, _exit_contents))) = consumed(verify(
|
||||
many_till(element_matcher, exit_matcher),
|
||||
|(children, _exit_contents)| {
|
||||
!children.is_empty() || property_drawer_element.is_some() || planning_element.is_some()
|
||||
},
|
||||
)(remaining)?;
|
||||
))(remaining)?;
|
||||
if let Some(ele) = property_drawer_element.map(Element::PropertyDrawer) {
|
||||
children.insert(0, ele);
|
||||
}
|
||||
@@ -128,7 +131,7 @@ pub(crate) fn section<'b, 'g, 'r, 's>(
|
||||
children.insert(0, ele)
|
||||
}
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
|
||||
let source = get_consumed(input, remaining);
|
||||
@@ -136,6 +139,8 @@ pub(crate) fn section<'b, 'g, 'r, 's>(
|
||||
remaining,
|
||||
Section {
|
||||
source: source.into(),
|
||||
contents: Some(contents.into()),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
children,
|
||||
},
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user