From a640890cad9621a94362e8c7c97bc031cf3b3cc1 Mon Sep 17 00:00:00 2001 From: Natty Date: Wed, 13 Mar 2024 14:31:05 +0100 Subject: [PATCH] Fixed an edge case in strict flanking rules --- magnetar_mmm_parser/src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/magnetar_mmm_parser/src/lib.rs b/magnetar_mmm_parser/src/lib.rs index 919ebd7..19a9235 100644 --- a/magnetar_mmm_parser/src/lib.rs +++ b/magnetar_mmm_parser/src/lib.rs @@ -1027,7 +1027,7 @@ impl Context { alphanumeric1_unicode, opt(tag("\\")), &opening_tag, - peek(not(alt((space1_unicode, eof)))), + peek(not(alt((recognize(satisfy(|c| c.is_whitespace())), eof)))), ))))(input)?; if let Some(pre_text) = pre { @@ -1909,6 +1909,15 @@ mod test { Token::PlainText("aaa_nnn_bbb".into()) ); + assert_eq!( + parse_full("aaa\n_iii_\nbbb"), + Token::Sequence(vec![ + Token::PlainText("aaa\n".into()), + Token::Italic(Box::new(Token::PlainText("iii".into()))), + Token::PlainText("\nbbb".into()) + ]) + ); + assert_eq!( parse_full(r#"*iii*"#), Token::Italic(Box::new(Token::PlainText("iii".into())))