Implement a function to read the name from the affiliated keywords.
This commit is contained in:
parent
ab4a0c1224
commit
5b308ea76f
8
org_mode_samples/affiliated_keyword/case_insensitive.org
Normal file
8
org_mode_samples/affiliated_keyword/case_insensitive.org
Normal file
@ -0,0 +1,8 @@
|
||||
#+NAME: foo
|
||||
bar
|
||||
|
||||
#+NaMe: baz
|
||||
cat
|
||||
|
||||
#+name: lorem
|
||||
ipsum
|
@ -22,6 +22,7 @@ use crate::error::CustomError;
|
||||
use crate::error::MyError;
|
||||
use crate::error::Res;
|
||||
use crate::types::IndentationLevel;
|
||||
use crate::types::Keyword;
|
||||
|
||||
pub(crate) const WORD_CONSTITUENT_CHARACTERS: &str =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
@ -275,3 +276,14 @@ pub(crate) fn indentation_level<'b, 'g, 'r, 's>(
|
||||
.sum();
|
||||
Ok((remaining, (indentation_level, leading_whitespace)))
|
||||
}
|
||||
|
||||
pub(crate) fn get_name<'s>(affiliated_keywords: &Vec<Keyword<'s>>) -> Option<&'s str> {
|
||||
let name_keyword = affiliated_keywords
|
||||
.iter()
|
||||
.filter(|kw| match kw.name {
|
||||
Some(name) if name.eq_ignore_ascii_case("name") => true,
|
||||
_ => false,
|
||||
})
|
||||
.last();
|
||||
name_keyword.map(|kw| kw.value)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user