fix: newline in not allowed in property name

This commit is contained in:
PoiScript 2024-06-11 15:16:11 +08:00
parent 13ebef05d2
commit 5bc15d80ff
No known key found for this signature in database
GPG key ID: 22C2B1249D99985E
4 changed files with 23 additions and 8 deletions

View file

@ -2,7 +2,7 @@ use rowan::ast::AstNode;
use crate::Org;
use super::{Document, Keyword};
use super::{Document, Keyword, PropertyDrawer};
impl Document {
/// Returns an iterator of keywords in zeroth section
@ -55,6 +55,24 @@ impl Document {
Some(s)
})
}
/// Returns top-level properties drawer
///
/// ```rust
/// use orgize::{Org, ast::Document};
///
/// let org = Org::parse(r#":PROPERTIES:
/// :ID: 20220718T085035.042592
/// :END:
/// #+TITLE: Complete Computing"#);
///
/// let properties = org.document().properties().unwrap();
/// assert_eq!(properties.to_hash_map().len(), 1);
/// assert_eq!(properties.get("ID").unwrap(), "20220718T085035.042592");
/// ```
pub fn properties(&self) -> Option<PropertyDrawer> {
rowan::ast::support::child(&self.syntax)
}
}
impl Org {