diff --git a/org_mode_samples/greater_element/plain_list/description_list.org b/org_mode_samples/greater_element/plain_list/description_list.org index 7fbdd8f..c6aec5c 100644 --- a/org_mode_samples/greater_element/plain_list/description_list.org +++ b/org_mode_samples/greater_element/plain_list/description_list.org @@ -1,5 +1,7 @@ - foo :: bar -- cat :: +- cat :: dog - lorem :: ipsum +- + lorem :: ipsum diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 41c64f4..c46bb8c 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -1,12 +1,15 @@ use nom::branch::alt; use nom::bytes::complete::tag; +use nom::character::complete::anychar; use nom::character::complete::digit1; use nom::character::complete::line_ending; +use nom::character::complete::multispace1; use nom::character::complete::one_of; use nom::character::complete::space0; use nom::character::complete::space1; use nom::combinator::eof; use nom::combinator::opt; +use nom::combinator::peek; use nom::combinator::recognize; use nom::combinator::verify; use nom::multi::many1; @@ -138,7 +141,6 @@ pub fn plain_list_item<'r, 's>( Into::<&str>::into(bull) != "*" || indent_level > 0 })(remaining)?; - // TODO: This isn't taking into account items that immediately line break and then have contents let maybe_contentless_item: Res, OrgSource<'_>> = eof(remaining); match maybe_contentless_item { Ok((rem, _ws)) => { @@ -156,6 +158,7 @@ pub fn plain_list_item<'r, 's>( Err(_) => {} }; + let (remaining, _maybe_tag) = opt(tuple((space1, item_tag, tag(" ::"))))(remaining)?; let (remaining, _ws) = alt((space1, line_ending))(remaining)?; let exit_matcher = plain_list_item_end(indent_level); let parser_context = context @@ -262,6 +265,18 @@ fn _line_indented_lte<'r, 's>( Ok(matched) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] +fn item_tag<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { + recognize(many_till( + anychar, + peek(alt(( + line_ending, + tag(" :: "), + recognize(tuple((tag(" ::"), alt((line_ending, eof))))), + ))), + ))(input) +} + #[cfg(test)] mod tests { use super::*;