orgize
orgize copied to clipboard
support for top-level properties drawer
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>
supported in 9b8aec0:
let org = Org::parse(
r#":PROPERTIES:
:key: value
:END:
"#,
);
assert_eq!(
org.document().properties().unwrap().get("key").unwrap(),
"value"
);
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 :)
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");
cheers @PoiScript , i really appreciate your work on this parser!