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 {