feat: permit customisation of tag characters
Org-mode frontends such as [Orgzly](https://www.orgzly.com/) are more lenient in their tag parsing, this allows us to parse org-mode files generated by such frontends.
This commit is contained in:
parent
5f26c94dce
commit
dfa1a8a203
2 changed files with 7 additions and 1 deletions
|
|
@ -45,6 +45,11 @@ pub struct ParseConfig {
|
|||
///
|
||||
/// Equivalent to [`org-element-affiliated-keywords`](https://git.sr.ht/~bzg/org-mode/tree/6f960f3c6a4dfe137fbd33fef9f7dadfd229600c/item/lisp/org-element.el#L331)
|
||||
pub affiliated_keywords: Vec<String>,
|
||||
|
||||
/// Control tag parsing
|
||||
///
|
||||
/// Defaults to org-mode's permitted characters: alphanumeric and `_@#%`.
|
||||
pub is_tag_char: fn(char) -> bool,
|
||||
}
|
||||
|
||||
impl ParseConfig {
|
||||
|
|
@ -82,6 +87,7 @@ impl Default for ParseConfig {
|
|||
"SRCNAME".into(),
|
||||
"TBLNAME".into(),
|
||||
],
|
||||
is_tag_char: |c| c.is_alphanumeric() || c == '_' || c == '@' || c == '#' || c == '%',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ fn headline_tags_node(input: Input) -> IResult<Input, GreenElement, ()> {
|
|||
} else if String::from_utf8_lossy(item)
|
||||
.chars()
|
||||
// https://github.com/yyr/org-mode/blob/d8494b5668ad4d4e68e83228ae8451eaa01d2220/lisp/org-element.el#L922C25-L922C32
|
||||
.all(|c| c.is_alphanumeric() || c == '_' || c == '@' || c == '#' || c == '%')
|
||||
.all(input.c.is_tag_char)
|
||||
{
|
||||
children.push(input.slice(ii + 1..i).text_token());
|
||||
children.push(token(COLON, ":"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue