Apply category even if there are radio targets.
This commit is contained in:
@@ -11,7 +11,9 @@ use super::OrgSource;
|
||||
use crate::context::HeadlineLevelFilter;
|
||||
use crate::error::CustomError;
|
||||
use crate::error::Res;
|
||||
use crate::iter::AstNode;
|
||||
use crate::settings::GlobalSettings;
|
||||
use crate::types::Document;
|
||||
use crate::types::Keyword;
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
@@ -114,6 +116,25 @@ pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>(
|
||||
Ok(new_settings)
|
||||
}
|
||||
|
||||
/// Apply in-buffer settings that do not impact parsing and therefore can be applied after parsing.
|
||||
pub(crate) fn apply_post_parse_in_buffer_settings<'g, 's, 'sf>(
|
||||
document: &mut Document<'s>,
|
||||
) -> Result<(), &'static str> {
|
||||
document.category = Into::<AstNode>::into(&*document)
|
||||
.into_iter()
|
||||
.filter_map(|ast_node| {
|
||||
if let AstNode::Keyword(ast_node) = ast_node {
|
||||
if ast_node.key.eq_ignore_ascii_case("category") {
|
||||
return Some(ast_node);
|
||||
}
|
||||
}
|
||||
None
|
||||
})
|
||||
.last()
|
||||
.map(|kw| kw.value.to_owned());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user