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

support for top-level properties drawer #78

Closed
rrix opened this issue May 8, 2024 · 4 comments
Closed

support for top-level properties drawer #78

rrix opened this issue May 8, 2024 · 4 comments

Comments

@rrix
Copy link

rrix commented May 8, 2024

as of org 9.5, properties drawers are allowed before the first-level heading

Org mode is moving more towards making things before the first headline behave just as if it was at outline level 0. Inheritance for properties will work also for this level. In other words: defining things in a property drawer before the first headline will make them "inheritable" for all headlines.

org-roam uses this in the org-roam-capture template and parses the level 0 heading as if it were a regular org-roam node/org-mode heading. It would be nice if there was a Document::properties() which returns an Option<PropertyDrawer>

@PoiScript
Copy link
Owner

supported in 9b8aec0:

    let org = Org::parse(
        r#":PROPERTIES:
:key: value
:END:
"#,
    );

    assert_eq!(
        org.document().properties().unwrap().get("key").unwrap(),
        "value"
    );

@rrix
Copy link
Author

rrix commented May 20, 2024

I can't seem to get this one to work.

:PROPERTIES:
:ID:       20220718T085035.042592
:END:
#+TITLE: Complete Computing
#+ARCOLOGY_KEY: cce/index
#+ARCOLOGY_ALLOW_CRAWL: t

dumps the following syntax on dbg!:

and org.document().properties() is_none, can you hit me with a cluebat :)

@PoiScript
Copy link
Owner

sorry for the late reply. it seems to be a potential bug where the parser incorrectly interprets a keyword as a property node. it issue was fixed in commit 5bc15d8 and included in the latest release:

    use orgize::{ast::Document, Org};

    let org = Org::parse(
        r#":PROPERTIES:
:ID:       20220718T085035.042592
:END:
#+TITLE: Complete Computing"#,
    );

    let properties = org.document().properties().unwrap();

    assert_eq!(properties.iter().count(), 1);
    assert_eq!(properties.get("ID").unwrap(), "20220718T085035.042592");

@rrix
Copy link
Author

rrix commented Jun 12, 2024

cheers @PoiScript , i really appreciate your work on this parser!

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