Really start from scratch.

This commit is contained in:
Tom Alexander
2022-11-24 14:42:05 -05:00
parent 6f416f6997
commit 1487f7d96b
3 changed files with 39 additions and 36 deletions

View File

@@ -5,8 +5,6 @@ use std::rc::Rc;
use crate::parser::parser_with_context::parser_with_context;
use crate::parser::text::paragraph_end;
use super::nom_context::ContextData;
use super::nom_context::TestContext;
use super::text::bold_end;
use super::text::bold_start;
use super::text::line_break;
@@ -25,10 +23,7 @@ use nom::multi::many_till;
use nom::sequence::tuple;
use nom::IResult;
fn flat_text_element<'s, 'r>(
i: &'s str,
context: &'r TestContext<ContextData>,
) -> Res<&'s str, TextElement<'s>> {
fn flat_text_element<'s, 'r>(i: &'s str, context: u32) -> Res<&'s str, TextElement<'s>> {
// context.not_matching_fail(i)?;
alt((
@@ -41,10 +36,7 @@ fn flat_text_element<'s, 'r>(
))(i)
}
fn flat_bold<'s, 'r>(
i: &'s str,
context: &'r TestContext<ContextData>,
) -> Res<&'s str, TextElement<'s>> {
fn flat_bold<'s, 'r>(i: &'s str, context: u32) -> 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 =
@@ -55,7 +47,7 @@ fn flat_bold<'s, 'r>(
pub fn paragraph<'s, 'r>(
i: &'s str,
context: &'r TestContext<ContextData>,
context: u32,
) -> 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)