Structurally this should be working but bold is not being captured.
This commit is contained in:
parent
f84fa09871
commit
6aa656127e
@ -31,7 +31,10 @@ fn flat_text_element<'s, 'r>(
|
||||
) -> Res<&'s str, TextElement<'s>> {
|
||||
not(|i| context.match_fail(i))(i)?;
|
||||
|
||||
let bold_matcher = parser_with_context!(flat_bold)(context);
|
||||
|
||||
alt((
|
||||
bold_matcher,
|
||||
map(span, TextElement::Span),
|
||||
map(symbol("*"), TextElement::Symbol),
|
||||
map(symbol("["), TextElement::Symbol),
|
||||
@ -41,13 +44,22 @@ fn flat_text_element<'s, 'r>(
|
||||
))(i)
|
||||
}
|
||||
|
||||
fn recognize_bold_end(input: &str) -> Res<&str, &str> {
|
||||
recognize(bold_end)(input)
|
||||
}
|
||||
|
||||
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 =
|
||||
// context.with_additional_fail_matcher(Rc::new(RefCell::new(recognize(bold_end))));
|
||||
// let new_context = context.without_bold(Rc::new(RefCell::new(recognize(bold_end))));
|
||||
todo!()
|
||||
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((
|
||||
bold_start,
|
||||
many_till(text_element_parser, bold_end),
|
||||
bold_end
|
||||
)))(i)?;
|
||||
let ret = TextElement::Bold(Bold {
|
||||
contents: captured
|
||||
});
|
||||
Ok((remaining, ret))
|
||||
}
|
||||
|
||||
pub fn paragraph<'s, 'r>(
|
||||
|
Loading…
x
Reference in New Issue
Block a user