|
|
|
|
@@ -57,7 +57,7 @@ pub(crate) fn detect_plain_list<'b, 'g, 'r, 's>(
|
|
|
|
|
parser_with_context!(bullet)(context),
|
|
|
|
|
alt((space1, line_ending, eof)),
|
|
|
|
|
)),
|
|
|
|
|
|(_start, indent, bull, _after_whitespace)| {
|
|
|
|
|
|(_start, indent, (_bullet_type, bull), _after_whitespace)| {
|
|
|
|
|
Into::<&str>::into(bull) != "*" || indent.len() > 0
|
|
|
|
|
},
|
|
|
|
|
)(input)
|
|
|
|
|
@@ -151,9 +151,9 @@ fn plain_list_item<'b, 'g, 'r, 's>(
|
|
|
|
|
) -> Res<OrgSource<'s>, PlainListItem<'s>> {
|
|
|
|
|
start_of_line(input)?;
|
|
|
|
|
let (remaining, (indent_level, _leading_whitespace)) = indentation_level(context, input)?;
|
|
|
|
|
let (remaining, bull) = verify(
|
|
|
|
|
let (remaining, (bullet_type, bull)) = verify(
|
|
|
|
|
parser_with_context!(bullet)(context),
|
|
|
|
|
|bull: &OrgSource<'_>| Into::<&str>::into(bull) != "*" || indent_level > 0,
|
|
|
|
|
|(_bullet_type, bull)| Into::<&str>::into(bull) != "*" || indent_level > 0,
|
|
|
|
|
)(remaining)?;
|
|
|
|
|
|
|
|
|
|
let (remaining, _maybe_counter_set) = opt(tuple((
|
|
|
|
|
@@ -165,8 +165,11 @@ fn plain_list_item<'b, 'g, 'r, 's>(
|
|
|
|
|
|
|
|
|
|
let (remaining, maybe_checkbox) = opt(tuple((space1, item_checkbox)))(remaining)?;
|
|
|
|
|
|
|
|
|
|
let (remaining, maybe_tag) =
|
|
|
|
|
opt(tuple((space1, parser_with_context!(item_tag)(context))))(remaining)?;
|
|
|
|
|
let (remaining, maybe_tag) = if let BulletType::Unordered = bullet_type {
|
|
|
|
|
opt(tuple((space1, parser_with_context!(item_tag)(context))))(remaining)?
|
|
|
|
|
} else {
|
|
|
|
|
(remaining, None)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let exit_matcher = plain_list_item_end(indent_level);
|
|
|
|
|
let contexts = [
|
|
|
|
|
@@ -242,19 +245,27 @@ fn plain_list_item<'b, 'g, 'r, 's>(
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum BulletType {
|
|
|
|
|
Ordered,
|
|
|
|
|
Unordered,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
|
|
|
|
fn bullet<'b, 'g, 'r, 's>(
|
|
|
|
|
context: RefContext<'b, 'g, 'r, 's>,
|
|
|
|
|
input: OrgSource<'s>,
|
|
|
|
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
|
|
|
|
) -> Res<OrgSource<'s>, (BulletType, OrgSource<'s>)> {
|
|
|
|
|
alt((
|
|
|
|
|
tag("*"),
|
|
|
|
|
tag("-"),
|
|
|
|
|
tag("+"),
|
|
|
|
|
recognize(tuple((
|
|
|
|
|
parser_with_context!(counter)(context),
|
|
|
|
|
alt((tag("."), tag(")"))),
|
|
|
|
|
))),
|
|
|
|
|
map(tag("*"), |bull| (BulletType::Unordered, bull)),
|
|
|
|
|
map(tag("-"), |bull| (BulletType::Unordered, bull)),
|
|
|
|
|
map(tag("+"), |bull| (BulletType::Unordered, bull)),
|
|
|
|
|
map(
|
|
|
|
|
recognize(tuple((
|
|
|
|
|
parser_with_context!(counter)(context),
|
|
|
|
|
alt((tag("."), tag(")"))),
|
|
|
|
|
))),
|
|
|
|
|
|bull| (BulletType::Ordered, bull),
|
|
|
|
|
),
|
|
|
|
|
))(input)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|