orgize icon indicating copy to clipboard operation
orgize copied to clipboard

:PROPERTIES: takes precedence over headlines

Open calmofthestorm opened this issue 4 years ago • 0 comments

This one is interesting, and from what I remember of parser generators, may be tricky to resolve. Currently, it seems that Orgize will fail to parse headlines "inside" a :PROPERTIES: drawer. This occurs only when the headline inside the drawer is at a greater level, and only in properties drawers. Additionally, the properties drawer must immediately follow the headline and planning (this is required by the Org spec to be a valid properties drawer, but you may have a different drawer named :PROPERTIES: elsewhere in the node).

Note that this is arguably a broken org file -- all org files are valid strings, but, e.g., org-lint would catch this case. But I do think that properly parsing headlines should work even in the presence of broken drawers.

fn main() {
    // Passes -- drawer other than PROPERTIES.
    let org = orgize::Org::parse("* Hello\n:MYDRAWER:\n** World\n:END:");
    assert_eq!(org.headlines().count(), 2);

    // Passes -- both headlines at same depth.
    let org = orgize::Org::parse("* Hello\n:PROPERTIES:\n* World\n:END:");
    assert_eq!(org.headlines().count(), 2);

    // Passes -- in order to be the special "properties" drawer, the drawer must
    // immediately follow the headline and planning..
    let org = orgize::Org::parse("* Hello\nSpacer\n:PROPERTIES:\n** World\n:END:");
    assert_eq!(org.headlines().count(), 2);

    // Fails
    let org = orgize::Org::parse("* Hello\n:PROPERTIES:\n** World\n:END:");
    assert_eq!(org.headlines().count(), 2);
}

calmofthestorm avatar May 10 '20 00:05 calmofthestorm