From b10798b778392521fc3efa4e10bc120126b5a003 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Fri, 27 Jan 2023 19:17:06 +0100 Subject: [PATCH] inline: impl smart ellipsis --- src/inline.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/inline.rs b/src/inline.rs index 7037e67..998c3b3 100644 --- a/src/inline.rs +++ b/src/inline.rs @@ -584,7 +584,23 @@ impl + Clone> Parser { lex::Kind::Hardbreak => Hardbreak, lex::Kind::Escape => Escape, lex::Kind::Nbsp => Nbsp, - lex::Kind::Seq(lex::Sequence::Period) if first.len == 3 => Ellipsis, + lex::Kind::Seq(lex::Sequence::Period) if first.len >= 3 => { + while self.span.len() > 3 { + self.events.push_back(Event { + kind: EventKind::Atom(Ellipsis), + span: self.span.with_len(3), + }); + self.span = self.span.skip(3); + } + if self.span.len() == 3 { + Ellipsis + } else { + return Some(Event { + kind: EventKind::Str, + span: self.span, + }); + } + } lex::Kind::Seq(lex::Sequence::Hyphen) if first.len == 2 => EnDash, lex::Kind::Seq(lex::Sequence::Hyphen) if first.len == 3 => EmDash, lex::Kind::Open(lex::Delimiter::BraceQuote1) => Quote {