diff --git a/src/parser/table.rs b/src/parser/table.rs index baf1873..89fe042 100644 --- a/src/parser/table.rs +++ b/src/parser/table.rs @@ -1,4 +1,7 @@ +use nom::branch::alt; +use nom::bytes::complete::is_not; use nom::bytes::complete::tag; +use nom::character::complete::line_ending; use nom::character::complete::space0; use nom::combinator::not; use nom::combinator::peek; @@ -46,13 +49,7 @@ pub fn org_mode_table<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<& maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?; let source = get_consumed(input, remaining); - Ok(( - remaining, - Table { - source, - children - } - )) + Ok((remaining, Table { source, children })) } #[tracing::instrument(ret, level = "debug")] @@ -65,6 +62,28 @@ fn table_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, & pub fn org_mode_table_row<'r, 's>( context: Context<'r, 's>, input: &'s str, +) -> Res<&'s str, TableRow<'s>> { + alt(( + parser_with_context!(org_mode_table_row_rule)(context), + parser_with_context!(org_mode_table_row_regular)(context), + ))(input) +} + +#[tracing::instrument(ret, level = "debug")] +pub fn org_mode_table_row_rule<'r, 's>( + context: Context<'r, 's>, + input: &'s str, +) -> Res<&'s str, TableRow<'s>> { + start_of_line(context, input)?; + let (remaining, _) = tuple((space0, tag("|-"), is_not("\r\n"), line_ending))(input)?; + let source = get_consumed(input, remaining); + Ok((remaining, TableRow { source })) +} + +#[tracing::instrument(ret, level = "debug")] +pub fn org_mode_table_row_regular<'r, 's>( + context: Context<'r, 's>, + input: &'s str, ) -> Res<&'s str, TableRow<'s>> { todo!() }