Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions extension/_test/typographer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,10 @@ We're talking about the internet --- 'net for short. Let's rock 'n roll!
//- - - - - - - - -//
<p><img src="https://example.com/image.jpg" alt="Nice &amp; day, isn&rsquo;t it?"></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//

20: Quoted words starting with 't' keep their opening quote
//- - - - - - - - -//
It was 'terrifying' but 'twas worth it; please 'turn' here.
//- - - - - - - - -//
<p>It was &lsquo;terrifying&rsquo; but &rsquo;twas worth it; please &lsquo;turn&rsquo; here.</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
5 changes: 3 additions & 2 deletions extension/typographer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down