mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
fix typographer leading apostrophe for abbreviations
This commit is contained in:
parent
7b616a4c80
commit
a6c48071ed
2 changed files with 11 additions and 3 deletions
|
|
@ -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!
|
||||
//- - - - - - - - -//
|
||||
<p>We’re talking about the internet — ’net for short.</p>
|
||||
<p>We’re talking about the internet — ’net for short. Let’s rock ’n roll!</p>
|
||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||
|
||||
|
|
|
|||
|
|
@ -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))) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue