orgize icon indicating copy to clipboard operation
orgize copied to clipboard

support for top-level properties drawer

Open rrix opened this issue 9 months ago • 1 comments

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>

rrix avatar May 08 '24 16:05 rrix

supported in 9b8aec0:

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

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

PoiScript avatar May 09 '24 08:05 PoiScript

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!:

[src/extract.rs:18] doc.document() = Document {
    syntax: [email protected]
      [email protected]
        [email protected]
          [email protected]
            [email protected] ":"
            [email protected] "PROPERTIES"
            [email protected] ":"
            [email protected] "\n"
          [email protected]
            [email protected]
              [email protected] ":ID:       20220718T0 ..."
          [email protected]
            [email protected] ":"
            [email protected] "END"
            [email protected] ":"
            [email protected] "\n"
        [email protected]
          [email protected] "#+"
          [email protected] "TITLE"
          [email protected] ":"
          [email protected] " Complete Computing"
          [email protected] "\n"
        [email protected]
          [email protected] "#+"
          [email protected] "ARCOLOGY_KEY"
          [email protected] ":"
          [email protected] " cce/index"
          [email protected] "\n"
        [email protected]
          [email protected] "#+"
          [email protected] "ARCOLOGY_ALLOW_CRAWL"
          [email protected] ":"
          [email protected] " t"
          [email protected] "\n"
          [email protected] "\n"

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

rrix avatar May 20 '24 19:05 rrix

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 5bc15d80ffdf11b87cc5344f6c8ad24673551e2c 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");

PoiScript avatar Jun 11 '24 08:06 PoiScript

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

rrix avatar Jun 12 '24 19:06 rrix