Remve redundant org_spaces functions.

Turns out the nom space0/space1 parsers accept tab characters already.
This commit is contained in:
Tom Alexander
2023-09-15 21:28:40 -04:00
parent 85454a0a27
commit c9ce32c881
4 changed files with 15 additions and 42 deletions

View File

@@ -1,6 +1,7 @@
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::anychar;
use nom::character::complete::space0;
use nom::character::complete::space1;
use nom::combinator::map;
use nom::combinator::not;
@@ -20,8 +21,6 @@ use super::util::get_consumed;
use super::util::org_line_ending;
use super::util::org_space;
use super::util::org_space_or_line_ending;
use super::util::org_spaces0;
use super::util::org_spaces1;
use super::util::start_of_line;
use crate::context::parser_with_context;
use crate::context::ContextElement;
@@ -134,27 +133,27 @@ fn headline<'b, 'g, 'r, 's>(
))(input)?;
let (remaining, maybe_todo_keyword) = opt(tuple((
org_spaces1,
space1,
parser_with_context!(heading_keyword)(&parser_context),
peek(org_space_or_line_ending),
)))(remaining)?;
let (remaining, maybe_priority) = opt(tuple((org_spaces1, priority_cookie)))(remaining)?;
let (remaining, maybe_priority) = opt(tuple((space1, priority_cookie)))(remaining)?;
let (remaining, maybe_comment) = opt(tuple((
org_spaces1,
space1,
tag("COMMENT"),
peek(org_space_or_line_ending),
)))(remaining)?;
let (remaining, maybe_title) = opt(tuple((
org_spaces1,
space1,
many1(parser_with_context!(standard_set_object)(&parser_context)),
)))(remaining)?;
let (remaining, maybe_tags) = opt(tuple((org_spaces0, tags)))(remaining)?;
let (remaining, maybe_tags) = opt(tuple((space0, tags)))(remaining)?;
let (remaining, _) = tuple((org_spaces0, org_line_ending))(remaining)?;
let (remaining, _) = tuple((space0, org_line_ending))(remaining)?;
Ok((
remaining,
@@ -180,11 +179,7 @@ fn headline_title_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
recognize(tuple((
org_spaces0,
opt(tuple((tags, org_spaces0))),
org_line_ending,
)))(input)
recognize(tuple((space0, opt(tuple((tags, space0))), org_line_ending)))(input)
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]