Apply a similar optimization to the detect element parser but also unify detection of affiliated keywords.

This commit is contained in:
Tom Alexander
2023-10-16 14:55:40 -04:00
parent 0020d71089
commit 7833a58461
6 changed files with 108 additions and 39 deletions

View File

@@ -53,13 +53,17 @@ use crate::types::PlainListType;
#[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
tracing::instrument(ret, level = "debug", skip(context, affiliated_keywords))
)]
pub(crate) fn detect_plain_list<'b, 'g, 'r, 's>(
pub(crate) fn detect_plain_list<'b, 'g, 'r, 's, AK>(
affiliated_keywords: AK,
remaining: OrgSource<'s>,
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> {
let (input, _) = many0(parser_with_context!(affiliated_keyword)(context))(input)?;
) -> Res<OrgSource<'s>, ()>
where
AK: IntoIterator<Item = Keyword<'s>>,
{
if verify(
tuple((
start_of_line,
@@ -70,7 +74,7 @@ pub(crate) fn detect_plain_list<'b, 'g, 'r, 's>(
|(_start, (indent_level, _), (_bullet_type, bull), _after_whitespace)| {
!Into::<&str>::into(bull).starts_with("*") || *indent_level > 0
},
)(input)
)(remaining)
.is_ok()
{
return Ok((input, ()));