Fix handling of whitespace.
This commit is contained in:
@@ -2,3 +2,4 @@ mod error;
|
||||
mod parse;
|
||||
mod sexp;
|
||||
pub use parse::emacs_parse_org_document;
|
||||
pub use sexp::sexp;
|
||||
|
||||
@@ -3,7 +3,10 @@ use nom::bytes::complete::tag;
|
||||
use nom::bytes::complete::take_till1;
|
||||
use nom::character::complete::multispace0;
|
||||
use nom::character::complete::multispace1;
|
||||
use nom::combinator::not;
|
||||
use nom::combinator::peek;
|
||||
use nom::multi::separated_list1;
|
||||
use nom::sequence::delimited;
|
||||
|
||||
use super::error::Res;
|
||||
|
||||
@@ -29,13 +32,14 @@ fn token<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
fn list<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||
let (remaining, opening_paren) = tag("(")(input)?;
|
||||
let (remaining, children) = separated_list1(multispace1, token)(remaining)?;
|
||||
let (remaining, children) = delimited(multispace0, separated_list1(multispace1, token), multispace0)(remaining)?;
|
||||
let (remaining, closing_paren) = tag(")")(remaining)?;
|
||||
Ok((remaining, Token::List(children)))
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
fn atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||
not(peek(tag(")")))(input)?;
|
||||
unquoted_atom(input)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user