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,5 +1,4 @@
use nom::branch::alt;
use nom::bytes::complete::is_a;
use nom::character::complete::anychar;
use nom::character::complete::line_ending;
use nom::character::complete::none_of;
@@ -10,11 +9,9 @@ use nom::combinator::not;
use nom::combinator::opt;
use nom::combinator::peek;
use nom::combinator::recognize;
use nom::combinator::verify;
use nom::multi::many0;
use nom::multi::many_till;
use nom::sequence::tuple;
use nom::Slice;
use super::org_source::OrgSource;
use crate::context::parser_with_context;
@@ -246,24 +243,6 @@ pub(crate) fn org_space_or_line_ending<'s>(
alt((recognize(one_of(" \t")), org_line_ending))(input)
}
/// Match as many spaces and tabs as possible. No minimum match.
///
/// In org-mode syntax, spaces and tabs are interchangeable.
pub(crate) fn org_spaces0<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
let found = is_a(" \t")(input);
if found.is_ok() {
return found;
}
Ok((input, input.slice(..0)))
}
/// Match as many spaces and tabs as possible. Minimum 1 character.
///
/// In org-mode syntax, spaces and tabs are interchangeable.
pub(crate) fn org_spaces1<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
verify(is_a(" \t"), |res: &OrgSource<'_>| res.len() > 0)(input)
}
/// Match a line break or the end of the file.
///
/// In org-mode syntax, the end of the file can serve the same purpose as a line break syntactically.