From 30042ddcfedf5c3349639c5ba21d7638c919dea9 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 15 Oct 2022 14:28:24 -0400 Subject: [PATCH] Lifetime issue not general enough. --- src/parser/nom_context.rs | 9 +++++++++ src/parser/text_element_parser.rs | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/parser/nom_context.rs b/src/parser/nom_context.rs index 3a0ada8..92b6899 100644 --- a/src/parser/nom_context.rs +++ b/src/parser/nom_context.rs @@ -49,6 +49,15 @@ impl<'r> NomContext<'r> { } } + pub fn without_bold(&self, other: MatcherRef) -> NomContext { + NomContext { + parent: Some(&self), + fail_matcher: ChainBehavior::AndParent(Some(other)), + match_bold_allowed: false, + match_link_allowed: self.match_link_allowed, + } + } + pub fn not_matching_fail<'s>(&self, i: &'s str) -> IResult<&'s str, (), VerboseError<&'s str>> { not(FailChecker::new(self))(i) } diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index 2376526..b1267df 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -1,4 +1,7 @@ //! A single element of text. +use std::cell::RefCell; +use std::rc::Rc; + use crate::parser::parser_with_context::parser_with_context; use crate::parser::text::paragraph_end; @@ -34,6 +37,11 @@ fn flat_text_element<'s, 'r>(i: &'s str, context: &'r NomContext) -> Res<&'s str ))(i) } +fn flat_bold<'s, 'r>(i: &'s str, context: &'r NomContext) -> Res<&'s str, TextElement<'s>> { + let new_context = context.without_bold(Rc::new(RefCell::new(recognize(bold_end)))); + todo!() +} + pub fn paragraph<'s, 'r>( i: &'s str, context: &'r NomContext,