use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::line_ending; use nom::character::complete::space0; use nom::combinator::eof; use nom::combinator::recognize; use nom::combinator::verify; use nom::multi::many0; use nom::multi::many1_count; use nom::sequence::tuple; use super::keyword::affiliated_keyword; use super::org_source::OrgSource; use crate::context::parser_with_context; use crate::context::RefContext; use crate::error::Res; use crate::parser::util::start_of_line; use crate::types::HorizontalRule; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] pub(crate) fn horizontal_rule<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, HorizontalRule<'s>> { let (input, affiliated_keywords) = many0(parser_with_context!(affiliated_keyword)(context))(input)?; start_of_line(input)?; let (remaining, rule) = recognize(tuple(( space0, verify(many1_count(tag("-")), |dashes| *dashes >= 5), space0, alt((line_ending, eof)), )))(input)?; Ok(( remaining, HorizontalRule { source: rule.into(), name: None, // TODO }, )) }