fix: newline in not allowed in property name
This commit is contained in:
parent
13ebef05d2
commit
5bc15d80ff
4 changed files with 23 additions and 8 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ const nodes = [
|
|||
first_child: [
|
||||
["section", "Section"],
|
||||
["first_headline", "Headline"],
|
||||
["properties", "PropertyDrawer"],
|
||||
],
|
||||
last_child: [["last_headline", "Headline"]],
|
||||
children: [["headlines", "Headline"]],
|
||||
|
|
|
|||
|
|
@ -57,9 +57,6 @@ impl Document {
|
|||
pub fn first_headline(&self) -> Option<Headline> {
|
||||
support::child(&self.syntax)
|
||||
}
|
||||
pub fn properties(&self) -> Option<PropertyDrawer> {
|
||||
support::child(&self.syntax)
|
||||
}
|
||||
pub fn last_headline(&self) -> Option<Headline> {
|
||||
super::last_child(&self.syntax)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,9 +109,10 @@ fn node_property_node(input: Input) -> IResult<Input, GreenElement, ()> {
|
|||
let (input, ws1) = space0(input)?;
|
||||
let (input, colon1) = colon_token(input)?;
|
||||
let (input, (colon2, name)) = map(
|
||||
verify(take_while1(|c| c != ' ' && c != '\t'), |i: &Input| {
|
||||
i.ends_with(':')
|
||||
}),
|
||||
verify(
|
||||
take_while1(|c| c != ' ' && c != '\t' && c != '\n' && c != '\r'),
|
||||
|i: &Input| i.ends_with(':'),
|
||||
),
|
||||
|input: Input| input.take_split(input.len() - 1),
|
||||
)(input)?;
|
||||
let (input, ws2) = space1(input)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue