Implement table row rule.

This commit is contained in:
Tom Alexander 2023-04-19 21:28:35 -04:00
parent 093edf5c6e
commit 9747e0ba11
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -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!()
}