Move in_section to a util module.

This commit is contained in:
Tom Alexander
2022-12-18 03:18:43 -05:00
parent 6404e5f50e
commit 8211e1043f
5 changed files with 19 additions and 16 deletions

15
src/parser/util.rs Normal file
View File

@@ -0,0 +1,15 @@
use super::parser_context::ContextElement;
use super::Context;
pub fn in_section<'s, 'r, 'x>(context: Context<'r, 's>, section_name: &'x str) -> bool {
for thing in context.iter() {
match thing.get_data() {
ContextElement::ExitMatcherNode(_) => {}
ContextElement::PreviousElementNode(_) => {}
ContextElement::Context(name) if *name == section_name => return true,
ContextElement::Context(_) => {}
ContextElement::StartOfParagraph => {} // TODO: If we specialize this to bold then this would be a good spot to stop scanning
}
}
false
}