diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index c0eae4ea..c4d7440d 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -22,11 +22,13 @@ use super::text::TextElement; use super::token::Token; use super::Context; use nom::branch::alt; +use nom::bytes::complete::tag; use nom::bytes::complete::take; use nom::combinator::cond; use nom::combinator::eof; use nom::combinator::map; use nom::combinator::not; +use nom::combinator::peek; use nom::combinator::recognize; use nom::error::ErrorKind; use nom::error::ParseError; @@ -166,7 +168,16 @@ pub fn context_bold_start<'s, 'r>( } pub fn context_bold_end<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> { - recognize(bold_end)(input) + let (remaining, actual_match) = recognize(bold_end)(input)?; + peek(alt(( + // Must have whitespace after the end asterisk or it must be the end of that section (as checked by the fail matcher) + tag(" "), + tag("\t"), + tag("\n"), + |i| context.check_fail_matcher(i) + )))(remaining)?; + + Ok((remaining, actual_match)) } pub fn paragraph<'s, 'r>(