Remove category from global settings.
This setting does not impact parsing so we can iterate over the final document to find the keywords.
This commit is contained in:
parent
d38b0a84f6
commit
186201a4b5
@ -12,8 +12,6 @@ pub struct GlobalSettings<'g, 's> {
|
|||||||
pub radio_targets: Vec<&'g Vec<Object<'s>>>,
|
pub radio_targets: Vec<&'g Vec<Object<'s>>>,
|
||||||
pub file_access: &'g dyn FileAccessInterface,
|
pub file_access: &'g dyn FileAccessInterface,
|
||||||
pub in_progress_todo_keywords: BTreeSet<String>,
|
pub in_progress_todo_keywords: BTreeSet<String>,
|
||||||
pub category: Option<String>,
|
|
||||||
|
|
||||||
pub complete_todo_keywords: BTreeSet<String>,
|
pub complete_todo_keywords: BTreeSet<String>,
|
||||||
/// Set to true to allow for plain lists using single letters as the bullet in the same way that numbers are used.
|
/// Set to true to allow for plain lists using single letters as the bullet in the same way that numbers are used.
|
||||||
///
|
///
|
||||||
@ -41,7 +39,6 @@ impl<'g, 's> GlobalSettings<'g, 's> {
|
|||||||
working_directory: None,
|
working_directory: None,
|
||||||
},
|
},
|
||||||
in_progress_todo_keywords: BTreeSet::new(),
|
in_progress_todo_keywords: BTreeSet::new(),
|
||||||
category: None,
|
|
||||||
complete_todo_keywords: BTreeSet::new(),
|
complete_todo_keywords: BTreeSet::new(),
|
||||||
list_allow_alphabetical: false,
|
list_allow_alphabetical: false,
|
||||||
tab_width: DEFAULT_TAB_WIDTH,
|
tab_width: DEFAULT_TAB_WIDTH,
|
||||||
|
@ -149,7 +149,7 @@ fn document_org_source<'b, 'g, 'r, 's>(
|
|||||||
let new_context = context.with_global_settings(&new_settings);
|
let new_context = context.with_global_settings(&new_settings);
|
||||||
let context = &new_context;
|
let context = &new_context;
|
||||||
|
|
||||||
let (remaining, document) =
|
let (remaining, mut document) =
|
||||||
_document(context, input).map(|(rem, out)| (Into::<&str>::into(rem), out))?;
|
_document(context, input).map(|(rem, out)| (Into::<&str>::into(rem), out))?;
|
||||||
{
|
{
|
||||||
// If there are radio targets in this document then we need to parse the entire document again with the knowledge of the radio targets.
|
// If there are radio targets in this document then we need to parse the entire document again with the knowledge of the radio targets.
|
||||||
@ -173,6 +173,21 @@ fn document_org_source<'b, 'g, 'r, 's>(
|
|||||||
return Ok((remaining.into(), document));
|
return Ok((remaining.into(), document));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find final in-buffer settings that do not impact parsing
|
||||||
|
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((remaining.into(), document))
|
Ok((remaining.into(), document))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +206,7 @@ fn _document<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Document {
|
Document {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
category: context.get_global_settings().category.clone(),
|
category: None,
|
||||||
path: None,
|
path: None,
|
||||||
zeroth_section,
|
zeroth_section,
|
||||||
children,
|
children,
|
||||||
|
@ -111,14 +111,6 @@ pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Category
|
|
||||||
for kw in keywords
|
|
||||||
.iter()
|
|
||||||
.filter(|kw| kw.key.eq_ignore_ascii_case("category"))
|
|
||||||
{
|
|
||||||
new_settings.category = Some(kw.value.to_owned());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(new_settings)
|
Ok(new_settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user