Fixing more errors.

This commit is contained in:
Tom Alexander
2023-09-03 00:27:50 -04:00
parent 15e8d1ab77
commit b54c6d366c
7 changed files with 118 additions and 72 deletions

View File

@@ -12,14 +12,20 @@ use nom::multi::many1;
use nom::multi::many_till;
use nom::sequence::tuple;
use super::object_parser::table_cell_set_object;
use super::org_source::OrgSource;
use super::Context;
use super::util::exit_matcher_parser;
use crate::context::parser_with_context;
use crate::context::ContextElement;
use crate::context::ExitClass;
use crate::context::ExitMatcherNode;
use crate::context::RefContext;
use crate::error::Res;
use crate::parser::greater_element::TableRow;
use crate::parser::lesser_element::TableCell;
use crate::parser::util::get_consumed;
use crate::parser::util::start_of_line;
use crate::parser::Table;
use crate::types::Table;
use crate::types::TableCell;
use crate::types::TableRow;
/// Parse an org-mode-style table
///
@@ -32,13 +38,18 @@ pub fn org_mode_table<'r, 's>(
start_of_line(input)?;
peek(tuple((space0, tag("|"))))(input)?;
let parser_context = context
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(true))
.with_additional_node(ContextElement::Context("table"))
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
let contexts = [
ContextElement::ConsumeTrailingWhitespace(true),
ContextElement::Context("table"),
ContextElement::ExitMatcherNode(ExitMatcherNode {
class: ExitClass::Alpha,
exit_matcher: &table_end,
}));
}),
];
let parser_context = context
.with_additional_node(&contexts[0])
.with_additional_node(&contexts[1])
.with_additional_node(&contexts[2]);
let org_mode_table_row_matcher = parser_with_context!(org_mode_table_row)(&parser_context);
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
@@ -120,11 +131,11 @@ pub fn org_mode_table_cell<'r, 's>(
context: RefContext<'_, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, TableCell<'s>> {
let parser_context =
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
class: ExitClass::Beta,
exit_matcher: &org_mode_table_cell_end,
}));
let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
class: ExitClass::Beta,
exit_matcher: &org_mode_table_cell_end,
});
let parser_context = context.with_additional_node(&parser_context);
let table_cell_set_object_matcher =
parser_with_context!(table_cell_set_object)(&parser_context);
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);