From d050c504ae00163c44540a33ffeb5e6fba4a0950 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Thu, 26 Jan 2023 21:59:25 +0100 Subject: [PATCH] inline: disallow whitespace after/before emph --- src/inline.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/inline.rs b/src/inline.rs index 8ceedb2..75feccf 100644 --- a/src/inline.rs +++ b/src/inline.rs @@ -401,6 +401,14 @@ impl + Clone> Parser { if matches!(dir, Dir::Open) { return None; } + if matches!(dir, Dir::Both) + && self + .events + .back() + .map_or(false, |ev| matches!(ev.kind, EventKind::Whitespace)) + { + return None; + } let (d, e) = self.openers[o]; let e_attr = e; let e_opener = e + 1; @@ -476,6 +484,13 @@ impl + Clone> Parser { if matches!(dir, Dir::Close) { return None; } + if matches!(dir, Dir::Both) + && self + .peek() + .map_or(true, |t| matches!(t.kind, lex::Kind::Whitespace)) + { + return None; + } self.openers.push((delim, self.events.len())); // push dummy event in case attributes are encountered after closing delimiter self.events.push_back(Event {