Bubble up planning variables to the headline.
This commit is contained in:
@@ -34,6 +34,7 @@ use crate::error::Res;
|
||||
use crate::parser::object_parser::standard_set_object;
|
||||
use crate::parser::util::blank_line;
|
||||
use crate::types::DocumentElement;
|
||||
use crate::types::Element;
|
||||
use crate::types::Heading;
|
||||
use crate::types::HeadlineLevel;
|
||||
use crate::types::Object;
|
||||
@@ -55,6 +56,9 @@ fn _heading<'b, 'g, 'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
parent_star_count: HeadlineLevel,
|
||||
) -> Res<OrgSource<'s>, Heading<'s>> {
|
||||
let mut scheduled = None;
|
||||
let mut deadline = None;
|
||||
let mut closed = None;
|
||||
not(|i| context.check_exit_matcher(i))(input)?;
|
||||
let (remaining, pre_headline) = headline(context, input, parent_star_count)?;
|
||||
let section_matcher = parser_with_context!(section)(context);
|
||||
@@ -65,6 +69,14 @@ fn _heading<'b, 'g, 'r, 's>(
|
||||
let (remaining, mut children) =
|
||||
many0(map(heading_matcher, DocumentElement::Heading))(remaining)?;
|
||||
if let Some(section) = maybe_section {
|
||||
// If the section has a planning then the timestamp values are copied to the heading.
|
||||
if let DocumentElement::Section(inner_section) = §ion {
|
||||
if let Some(Element::Planning(planning)) = inner_section.children.first() {
|
||||
scheduled = planning.scheduled.clone();
|
||||
deadline = planning.deadline.clone();
|
||||
closed = planning.closed.clone();
|
||||
}
|
||||
}
|
||||
children.insert(0, section);
|
||||
}
|
||||
let remaining = if children.is_empty() {
|
||||
@@ -94,6 +106,9 @@ fn _heading<'b, 'g, 'r, 's>(
|
||||
is_comment: pre_headline.comment.is_some(),
|
||||
is_archived,
|
||||
is_footnote_section: pre_headline.is_footnote_section,
|
||||
scheduled,
|
||||
deadline,
|
||||
closed,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user