diff --git a/src/parser/parser_with_context.rs b/src/parser/parser_with_context.rs index 9b6063f2..e5d60862 100644 --- a/src/parser/parser_with_context.rs +++ b/src/parser/parser_with_context.rs @@ -1,6 +1,6 @@ macro_rules! parser_with_context { ($target:ident) => { - move |context| move |i| $target(i, context) + move |context| move |i| $target(context, i) }; } pub(crate) use parser_with_context; diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index 4ce04a6c..12ba53aa 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -35,6 +35,10 @@ use nom::IResult; use tracing::instrument; use tracing::trace; +fn context_many_till() { + todo!() +} + pub fn document(input: &str) -> Res<&str, Vec<(Vec, &str)>> { let initial_context = ContextTree::new(); let ret = many1(parser_with_context!(paragraph)(&initial_context))(input); @@ -42,8 +46,8 @@ pub fn document(input: &str) -> Res<&str, Vec<(Vec, &str)>> { } pub fn paragraph<'s, 'r>( - i: &'s str, context: &'r OrgModeContextNode<'r>, + i: &'s str, ) -> Res<&'s str, (Vec>, &'s str)> { // Add a not(eof) check because many_till cannot match a zero-length string not(eof)(i)?; @@ -54,8 +58,8 @@ pub fn paragraph<'s, 'r>( } fn flat_text_element<'s, 'r>( - i: &'s str, context: &'r OrgModeContextNode<'r>, + i: &'s str, ) -> Res<&'s str, TextElement<'s>> { not(|i| context.match_fail(i))(i)?; @@ -78,7 +82,7 @@ fn recognize_bold_end(input: &str) -> Res<&str, &str> { recognize(bold_end)(input) } -fn flat_bold<'s, 'r>(i: &'s str, context: &'r OrgModeContextNode<'r>) -> Res<&'s str, Bold<'s>> { +fn flat_bold<'s, 'r>(context: &'r OrgModeContextNode<'r>, i: &'s str) -> Res<&'s str, Bold<'s>> { let new_context = context.with_additional_fail_matcher(&recognize_bold_end); let text_element_parser = parser_with_context!(flat_text_element)(&new_context); let (remaining, captured) = recognize(tuple(( @@ -93,7 +97,7 @@ fn recognize_link_end(input: &str) -> Res<&str, &str> { recognize(link_end)(input) } -fn flat_link<'s, 'r>(i: &'s str, context: &'r OrgModeContextNode<'r>) -> Res<&'s str, Link<'s>> { +fn flat_link<'s, 'r>(context: &'r OrgModeContextNode<'r>, i: &'s str) -> Res<&'s str, Link<'s>> { let new_context = context.with_additional_fail_matcher(&recognize_link_end); let text_element_parser = parser_with_context!(flat_text_element)(&new_context); let (remaining, captured) = recognize(tuple((