From d593fdd660278fd72c82578383be4208bf4dcd1a Mon Sep 17 00:00:00 2001 From: Sai Asish Y Date: Tue, 12 May 2026 21:04:54 -0700 Subject: [PATCH] fix: stop typographer mangling opening quote of quoted 't' words --- extension/_test/typographer.txt | 7 +++++++ extension/typographer.go | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/extension/_test/typographer.txt b/extension/_test/typographer.txt index cf5fea6b..4accb656 100644 --- a/extension/_test/typographer.txt +++ b/extension/_test/typographer.txt @@ -141,3 +141,10 @@ We're talking about the internet --- 'net for short. Let's rock 'n roll! //- - - - - - - - -//

Nice & day, isn’t it?

//= = = = = = = = = = = = = = = = = = = = = = = =// + +20: Quoted words starting with 't' keep their opening quote +//- - - - - - - - -// +It was 'terrifying' but 'twas worth it; please 'turn' here. +//- - - - - - - - -// +

It was ‘terrifying’ but ’twas worth it; please ‘turn’ here.

+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/extension/typographer.go b/extension/typographer.go index 3a3f106a..b8202329 100644 --- a/extension/typographer.go +++ b/extension/typographer.go @@ -231,9 +231,10 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser return node } } - // special cases: 'twas, 'em, 'net + // special cases: 'twas/'tis, 'em, 'net (a leading 't only counts before w/i, so quoted words like 'terrifying' keep their opening quote) if len(line) > 1 && (unicode.IsPunct(before) || unicode.IsSpace(before)) && - (line[1] == 't' || line[1] == 'e' || line[1] == 'n' || line[1] == 'l') { + ((line[1] == 't' && len(line) > 2 && (line[2] == 'w' || line[2] == 'i')) || + line[1] == 'e' || line[1] == 'n' || line[1] == 'l') { node := gast.NewString(s.Substitutions[Apostrophe]) node.SetCode(true) block.Advance(1)