Add detect element functions for all elements that can be reasonably detected more efficiently than just parsing normally.

This commit is contained in:
Tom Alexander
2023-09-11 12:28:15 -04:00
parent aa5988bc2f
commit f54081437a
6 changed files with 52 additions and 6 deletions

View File

@@ -47,7 +47,7 @@ fn fixed_width_area_line<'b, 'g, 'r, 's>(
) -> Res<OrgSource<'s>, OrgSource<'s>> {
start_of_line(input)?;
let (remaining, _indent) = space0(input)?;
let (remaining, (_hash, _leading_whitespace_and_content, _line_ending)) = tuple((
let (remaining, (_colon, _leading_whitespace_and_content, _line_ending)) = tuple((
tag(":"),
opt(tuple((space1, is_not("\r\n")))),
alt((line_ending, eof)),
@@ -55,3 +55,14 @@ fn fixed_width_area_line<'b, 'g, 'r, 's>(
let source = get_consumed(input, remaining);
Ok((remaining, source))
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
pub fn detect_fixed_width_area<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
tuple((
start_of_line,
space0,
tag(":"),
alt((tag(" "), line_ending, eof)),
))(input)?;
Ok((input, ()))
}