diff --git a/extension/_test/typographer.txt b/extension/_test/typographer.txt index af6c1cb..556353c 100644 --- a/extension/_test/typographer.txt +++ b/extension/_test/typographer.txt @@ -130,8 +130,7 @@ Janet said, "When everything is 'breaking news,' nothing is 'breaking news.'" 18: Opening single quotation marks for abbreviations //- - - - - - - - -// -We're talking about the internet --- 'net for short. +We're talking about the internet --- 'net for short. Let's rock 'n roll! //- - - - - - - - -// -

We’re talking about the internet — ’net for short.

+

We’re talking about the internet — ’net for short. Let’s rock ’n roll!

//= = = = = = = = = = = = = = = = = = = = = = = =// - diff --git a/extension/typographer.go b/extension/typographer.go index 4a57ba4..a788228 100644 --- a/extension/typographer.go +++ b/extension/typographer.go @@ -1,6 +1,7 @@ package extension import ( + "fmt" "unicode" "github.com/yuin/goldmark" @@ -230,6 +231,14 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser return node } } + // special cases: 'twas, 'em, 'net + if len(line) > 1 && (unicode.IsPunct(before) || unicode.IsSpace(before)) && (line[1] == 't' || line[1] == 'e' || line[1] == 'n' || line[1] == 'l') { + fmt.Println(string(line)) + node := gast.NewString(s.Substitutions[Apostrophe]) + node.SetCode(true) + block.Advance(1) + return node + } // Convert normal apostrophes. This is probably more flexible than necessary but // converts any apostrophe in between two alphanumerics. if len(line) > 1 && (unicode.IsDigit(before) || unicode.IsLetter(before)) && (unicode.IsLetter(util.ToRune(line, 1))) {