PoiScript / orgize

A Rust library for parsing org-mode files.
https://poiscript.github.io/orgize/
MIT License
289 stars 35 forks source link

Cannot parse empty headlines with tags #17

Closed calmofthestorm closed 4 years ago

calmofthestorm commented 4 years ago

It looks like empty headlines' tags get treated as part of the raw, and the tags not picked up.

fn main() {
    let org = orgize::Org::parse("* :a:");
    assert_eq!(vec!("a"), org.headlines().next().unwrap().title(&org).tags);
}
PoiScript commented 4 years ago

Yes, this is the expected behavior of org-elements api:

Screen Shot 2020-05-06 at 10 22 13 AM
calmofthestorm commented 4 years ago

It looks like org mode itself also has this behavior, so my understanding of the spec was incorrect. Thanks for checking.

PoiScript commented 4 years ago

Actually, the org syntax is quite brief. It doesn't cover every possible edge cases like CommonMark does. So orgize will try to behave the same way as org-elements api (the builtin org-mode parser), and may not follow the org syntax in some situations.

calmofthestorm commented 4 years ago

Thanks for the explanation. I agree it makes sense to try to track org-mode/org-elements as closely as possible, given that if they and the standard disagree, I suspect the standard is more likely to be updated than they are unless it's an important failure mode.