Passing the context around.
This commit is contained in:
@@ -5,6 +5,7 @@ use std::rc::Rc;
|
||||
use crate::parser::parser_with_context::parser_with_context;
|
||||
use crate::parser::text::paragraph_end;
|
||||
|
||||
use super::nom_context::OrgModeContext;
|
||||
use super::text::bold_end;
|
||||
use super::text::bold_start;
|
||||
use super::text::line_break;
|
||||
@@ -23,7 +24,10 @@ use nom::multi::many_till;
|
||||
use nom::sequence::tuple;
|
||||
use nom::IResult;
|
||||
|
||||
fn flat_text_element<'s, 'r>(i: &'s str, context: u32) -> Res<&'s str, TextElement<'s>> {
|
||||
fn flat_text_element<'s, 'r>(
|
||||
i: &'s str,
|
||||
context: &'r OrgModeContext<'r>,
|
||||
) -> Res<&'s str, TextElement<'s>> {
|
||||
// context.not_matching_fail(i)?;
|
||||
|
||||
alt((
|
||||
@@ -36,7 +40,7 @@ fn flat_text_element<'s, 'r>(i: &'s str, context: u32) -> Res<&'s str, TextEleme
|
||||
))(i)
|
||||
}
|
||||
|
||||
fn flat_bold<'s, 'r>(i: &'s str, context: u32) -> Res<&'s str, TextElement<'s>> {
|
||||
fn flat_bold<'s, 'r>(i: &'s str, context: &'r OrgModeContext<'r>) -> Res<&'s str, TextElement<'s>> {
|
||||
// let fail_matcher = recognize(bold_end);
|
||||
// let new_context = context.with_additional_fail_matcher(Rc::new(RefCell::new(paragraph_end)));
|
||||
// let new_context =
|
||||
@@ -47,7 +51,7 @@ fn flat_bold<'s, 'r>(i: &'s str, context: u32) -> Res<&'s str, TextElement<'s>>
|
||||
|
||||
pub fn paragraph<'s, 'r>(
|
||||
i: &'s str,
|
||||
context: u32,
|
||||
context: &'r OrgModeContext<'r>,
|
||||
) -> Res<&'s str, (Vec<TextElement<'s>>, &'s str)> {
|
||||
let text_element_parser = parser_with_context!(flat_text_element)(context);
|
||||
many_till(text_element_parser, paragraph_end)(i)
|
||||
|
||||
Reference in New Issue
Block a user