Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent handling of edge case headlines lacking space #19

Closed
calmofthestorm opened this issue May 7, 2020 · 2 comments
Closed

Comments

@calmofthestorm
Copy link
Contributor

I wanted to mention a few edge cases I found involving headlines that don't have a space after the stars. Per the spec, none of these are headlines.

The first two are treated as headlines by org-element, but not org-agenda tags, org mode font lock, or orgize.

The second two are treated as headlines by org-element and orgize, but not org mode font lock.

It's fine if you want to just close this -- I'm not even entirely sure what the correct behavior should be. I just wanted to mention it since I found it when testing something. I could also send a PR for adding a errata/quirks documentation if you like.

fn main() {
    // Org mode: Treats it as not a headline (both font lock and agenda tag view)
    // Orgize 0.8.3: Not a headline
    // (with-temp-buffer (insert "*a\n")(org-element-parse-buffer (point-max))) --> title "a", level 1
    let org = orgize::Org::parse("*a :foo:\n");
    assert_eq!(0, org.headlines().count());

    // Org mode: Treats it as not a headline (both font lock and agenda tag view)
    // Orgize 0.8.3: Not a headline
    // (with-temp-buffer (insert "*a")(org-element-parse-buffer (point-max))) --> title "a", level 1
    let org = orgize::Org::parse("*a :foo:");
    assert_eq!(0, org.headlines().count());

    // Org mode: Treats it as not a headline (font lock)
    // Orgize 0.8.3: Headline with level 3 and title ""
    // (with-temp-buffer (insert "***")(org-element-parse-buffer (point-max))) --> title "", level 3
    let org = orgize::Org::parse("***");
    assert_eq!(1, org.headlines().count());
    assert_eq!(3, org.headlines().next().unwrap().level());
    assert_eq!("", org.headlines().next().unwrap().title(&org).raw);

    // Org mode: Treats it as not a headline (font lock)
    // Orgize 0.8.3: Headline with level 1 and title ""
    // (with-temp-buffer (insert "*\n")(org-element-parse-buffer (point-max))) --> title "", level 1
    let org = orgize::Org::parse("*\n");
    assert_eq!(1, org.headlines().count());
    assert_eq!(1, org.headlines().next().unwrap().level());
    assert_eq!("", org.headlines().next().unwrap().title(&org).raw);
}
@PoiScript
Copy link
Owner

I'm quite surprised that org-elements api will treat *a as a valid headline. In this case, I think we can just leave it as it is...

I could also send a PR for adding a errata/quirks documentation if you like.

PR is welcome! You can create a docs/ directly at root for documents.

@calmofthestorm
Copy link
Contributor Author

calmofthestorm commented May 9, 2020

A few more cases like this I should document when I write the PR.

 (with-temp-buffer (insert "*")(org-element-parse-buffer (point-max))) 
 (with-temp-buffer (insert "*\r")(org-element-parse-buffer (point-max))) 
 (with-temp-buffer (insert "*\t")(org-element-parse-buffer (point-max))) 

    let org = orgize::Org::parse("* \tTODO");
    // org-element gets nil for this.
    assert_eq!(org.headlines().next().unwrap().title(&org).keyword, None);

    let org = orgize::Org::parse("* \t TODO");
    // org-element gets nil for this.
    assert_eq!(org.headlines().next().unwrap().title(&org).keyword, None);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants