Fixing more errors.
This commit is contained in:
parent
3bdb24ad88
commit
0b009511ff
@ -118,10 +118,9 @@ fn zeroth_section<'r, 's>(
|
||||
exit_matcher: §ion_end,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let without_consuming_whitespace_context = ContextElement::ConsumeTrailingWhitespace(false);
|
||||
let without_consuming_whitespace_context =
|
||||
parser_context.with_additional_node(&without_consuming_whitespace_context);
|
||||
@ -178,10 +177,9 @@ fn section<'r, 's>(
|
||||
exit_matcher: §ion_end,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let element_matcher = parser_with_context!(element(true))(&parser_context);
|
||||
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
|
||||
let (mut remaining, (planning_element, property_drawer_element)) = tuple((
|
||||
|
@ -58,10 +58,9 @@ pub fn drawer<'r, 's>(
|
||||
exit_matcher: &drawer_end,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
|
||||
let element_matcher = parser_with_context!(element(true))(&parser_context);
|
||||
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
|
||||
|
@ -58,10 +58,9 @@ pub fn dynamic_block<'r, 's>(
|
||||
exit_matcher: &dynamic_block_end,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
|
@ -51,10 +51,9 @@ pub fn footnote_definition<'r, 's>(
|
||||
exit_matcher: &footnote_definition_end,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
// TODO: The problem is we are not accounting for trailing whitespace like we do in section. Maybe it would be easier if we passed down whether or not to parse trailing whitespace into the element matcher similar to how tag takes in parameters.
|
||||
let element_matcher = parser_with_context!(element(true))(&parser_context);
|
||||
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
|
||||
@ -113,6 +112,7 @@ mod tests {
|
||||
use crate::context::Context;
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::context::List;
|
||||
use crate::types::Source;
|
||||
|
||||
#[test]
|
||||
fn two_paragraphs() {
|
||||
|
@ -70,10 +70,9 @@ pub fn greater_block<'r, 's>(
|
||||
exit_matcher: &exit_with_name,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
|
@ -12,9 +12,9 @@ use nom::multi::many_till;
|
||||
use nom::sequence::tuple;
|
||||
|
||||
use super::org_source::OrgSource;
|
||||
use crate::context::ContextMatcher;
|
||||
use crate::context::parser_with_context;
|
||||
use crate::context::ContextElement;
|
||||
use crate::context::ContextMatcher;
|
||||
use crate::context::ExitClass;
|
||||
use crate::context::ExitMatcherNode;
|
||||
use crate::context::RefContext;
|
||||
@ -50,10 +50,9 @@ pub fn verse_block<'r, 's>(
|
||||
exit_matcher: &lesser_block_end_specialized,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
@ -106,10 +105,9 @@ pub fn comment_block<'r, 's>(
|
||||
exit_matcher: &lesser_block_end_specialized,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
@ -139,14 +137,17 @@ pub fn example_block<'r, 's>(
|
||||
let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?;
|
||||
let (remaining, _nl) = line_ending(remaining)?;
|
||||
let lesser_block_end_specialized = lesser_block_end("example");
|
||||
let contexts = [ContextElement::ConsumeTrailingWhitespace(true), ContextElement::Context("lesser block"), ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
let contexts = [
|
||||
ContextElement::ConsumeTrailingWhitespace(true),
|
||||
ContextElement::Context("lesser block"),
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Beta,
|
||||
exit_matcher: &lesser_block_end_specialized,
|
||||
})];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
}),
|
||||
];
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
@ -177,14 +178,17 @@ pub fn export_block<'r, 's>(
|
||||
let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?;
|
||||
let (remaining, _nl) = line_ending(remaining)?;
|
||||
let lesser_block_end_specialized = lesser_block_end("export");
|
||||
let contexts = [ContextElement::ConsumeTrailingWhitespace(true), ContextElement::Context("lesser block"), ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
let contexts = [
|
||||
ContextElement::ConsumeTrailingWhitespace(true),
|
||||
ContextElement::Context("lesser block"),
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Beta,
|
||||
exit_matcher: &lesser_block_end_specialized,
|
||||
})];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
}),
|
||||
];
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
@ -215,14 +219,17 @@ pub fn src_block<'r, 's>(
|
||||
let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?;
|
||||
let (remaining, _nl) = line_ending(remaining)?;
|
||||
let lesser_block_end_specialized = lesser_block_end("src");
|
||||
let contexts = [ContextElement::ConsumeTrailingWhitespace(true), ContextElement::Context("lesser block"), ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
let contexts = [
|
||||
ContextElement::ConsumeTrailingWhitespace(true),
|
||||
ContextElement::Context("lesser block"),
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Alpha,
|
||||
exit_matcher: &lesser_block_end_specialized,
|
||||
})];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
}),
|
||||
];
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
@ -253,9 +260,7 @@ fn data<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
is_not("\r\n")(input)
|
||||
}
|
||||
|
||||
fn lesser_block_end(
|
||||
current_name: &str,
|
||||
) -> impl ContextMatcher {
|
||||
fn lesser_block_end(current_name: &str) -> impl ContextMatcher {
|
||||
let current_name_lower = current_name.to_lowercase();
|
||||
move |context, input: OrgSource<'_>| {
|
||||
_lesser_block_end(context, input, current_name_lower.as_str())
|
||||
@ -282,9 +287,7 @@ fn _lesser_block_end<'r, 's, 'x>(
|
||||
/// Parser for the beginning of a lesser block
|
||||
///
|
||||
/// current_name MUST be lowercase. We do not do the conversion ourselves because it is not allowed in a const fn.
|
||||
const fn lesser_block_begin<'c>(
|
||||
current_name: &'c str,
|
||||
) -> impl ContextMatcher + 'c {
|
||||
const fn lesser_block_begin<'c>(current_name: &'c str) -> impl ContextMatcher + 'c {
|
||||
// TODO: Since this is a const fn, is there ANY way to "generate" functions at compile time?
|
||||
move |context, input: OrgSource<'_>| _lesser_block_begin(context, input, current_name)
|
||||
}
|
||||
|
@ -73,10 +73,9 @@ pub fn plain_list<'r, 's>(
|
||||
}),
|
||||
];
|
||||
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
// children stores tuple of (input string, parsed object) so we can re-parse the final item
|
||||
let mut children = Vec::new();
|
||||
let mut first_item_indentation: Option<usize> = None;
|
||||
@ -182,9 +181,8 @@ pub fn plain_list_item<'r, 's>(
|
||||
exit_matcher: &exit_matcher,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
|
||||
let (mut remaining, (mut children, _exit_contents)) = many_till(
|
||||
include_input(parser_with_context!(element(true))(&parser_context)),
|
||||
|
@ -59,10 +59,9 @@ pub fn property_drawer<'r, 's>(
|
||||
exit_matcher: &property_drawer_end,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
|
||||
let node_property_matcher = parser_with_context!(node_property)(&parser_context);
|
||||
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
|
||||
|
@ -46,10 +46,9 @@ pub fn org_mode_table<'r, 's>(
|
||||
exit_matcher: &table_end,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.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);
|
||||
|
Loading…
Reference in New Issue
Block a user