From 270ba53150dcba392d9fdb0a5e9c8190abb95f98 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 2 Oct 2023 11:20:43 -0400 Subject: [PATCH] Set is_footnote_section during parsing. --- src/parser/headline.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/parser/headline.rs b/src/parser/headline.rs index 6b51f2be..753c72de 100644 --- a/src/parser/headline.rs +++ b/src/parser/headline.rs @@ -93,7 +93,7 @@ fn _heading<'b, 'g, 'r, 's>( children, is_comment: pre_headline.comment.is_some(), is_archived, - is_footnote_section: false, // TODO + is_footnote_section: pre_headline.is_footnote_section, }, )) } @@ -115,6 +115,7 @@ struct PreHeadline<'s> { comment: Option>, title: Vec>, tags: Vec<&'s str>, + is_footnote_section: bool, } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] @@ -163,6 +164,14 @@ fn headline<'b, 'g, 'r, 's>( let (remaining, _) = tuple((space0, org_line_ending))(remaining)?; + let is_footnote_section = maybe_title + .as_ref() + .map(|(_, (raw_title, _))| raw_title) + .map(|raw_title| { + Into::<&str>::into(raw_title) == context.get_global_settings().footnote_section + }) + .unwrap_or(false); + Ok(( remaining, PreHeadline { @@ -181,6 +190,7 @@ fn headline<'b, 'g, 'r, 's>( .collect() }) .unwrap_or(Vec::new()), + is_footnote_section, }, )) }