diff options
| author | 2023-08-21 06:39:14 +0000 | |
|---|---|---|
| committer | 2023-08-21 06:39:14 +0000 | |
| commit | 36dceac56c467033648590dd7e6ea100e1f824a2 (patch) | |
| tree | 54d1d6451c63785278ad5c1a6331a1d38fe2363e /vendor/github.com/yuin/goldmark/extension/typographer.go | |
| parent | [feature/bugfix] Probe S3 storage for CSP uri, add config flag for extra URIs... (diff) | |
| download | gotosocial-36dceac56c467033648590dd7e6ea100e1f824a2.tar.xz | |
[chore]: Bump github.com/yuin/goldmark from 1.5.5 to 1.5.6 (#2140)
Diffstat (limited to 'vendor/github.com/yuin/goldmark/extension/typographer.go')
| -rw-r--r-- | vendor/github.com/yuin/goldmark/extension/typographer.go | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/vendor/github.com/yuin/goldmark/extension/typographer.go b/vendor/github.com/yuin/goldmark/extension/typographer.go index f56c06f74..259c4f72f 100644 --- a/vendor/github.com/yuin/goldmark/extension/typographer.go +++ b/vendor/github.com/yuin/goldmark/extension/typographer.go @@ -36,25 +36,25 @@ func getUnclosedCounter(pc parser.Context) *unclosedCounter { type TypographicPunctuation int const ( - // LeftSingleQuote is ' + // LeftSingleQuote is ' . LeftSingleQuote TypographicPunctuation = iota + 1 - // RightSingleQuote is ' + // RightSingleQuote is ' . RightSingleQuote - // LeftDoubleQuote is " + // LeftDoubleQuote is " . LeftDoubleQuote - // RightDoubleQuote is " + // RightDoubleQuote is " . RightDoubleQuote - // EnDash is -- + // EnDash is -- . EnDash - // EmDash is --- + // EmDash is --- . EmDash - // Ellipsis is ... + // Ellipsis is ... . Ellipsis - // LeftAngleQuote is << + // LeftAngleQuote is << . LeftAngleQuote - // RightAngleQuote is >> + // RightAngleQuote is >> . RightAngleQuote - // Apostrophe is ' + // Apostrophe is ' . Apostrophe typographicPunctuationMax @@ -218,7 +218,8 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser if c == '\'' { if s.Substitutions[Apostrophe] != nil { // Handle decade abbrevations such as '90s - if d.CanOpen && !d.CanClose && len(line) > 3 && util.IsNumeric(line[1]) && util.IsNumeric(line[2]) && line[3] == 's' { + if d.CanOpen && !d.CanClose && len(line) > 3 && + util.IsNumeric(line[1]) && util.IsNumeric(line[2]) && line[3] == 's' { after := rune(' ') if len(line) > 4 { after = util.ToRune(line, 4) @@ -231,7 +232,8 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser } } // 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') { + if len(line) > 1 && (unicode.IsPunct(before) || unicode.IsSpace(before)) && + (line[1] == 't' || line[1] == 'e' || line[1] == 'n' || line[1] == 'l') { node := gast.NewString(s.Substitutions[Apostrophe]) node.SetCode(true) block.Advance(1) @@ -239,7 +241,8 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser } // 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))) { + if len(line) > 1 && (unicode.IsDigit(before) || unicode.IsLetter(before)) && + (unicode.IsLetter(util.ToRune(line, 1))) { node := gast.NewString(s.Substitutions[Apostrophe]) node.SetCode(true) block.Advance(1) @@ -249,11 +252,14 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser if s.Substitutions[LeftSingleQuote] != nil && d.CanOpen && !d.CanClose { nt := LeftSingleQuote // special cases: Alice's, I'm, Don't, You'd - if len(line) > 1 && (line[1] == 's' || line[1] == 'm' || line[1] == 't' || line[1] == 'd') && (len(line) < 3 || util.IsPunct(line[2]) || util.IsSpace(line[2])) { + if len(line) > 1 && (line[1] == 's' || line[1] == 'm' || line[1] == 't' || line[1] == 'd') && + (len(line) < 3 || util.IsPunct(line[2]) || util.IsSpace(line[2])) { nt = RightSingleQuote } // special cases: I've, I'll, You're - if len(line) > 2 && ((line[1] == 'v' && line[2] == 'e') || (line[1] == 'l' && line[2] == 'l') || (line[1] == 'r' && line[2] == 'e')) && (len(line) < 4 || util.IsPunct(line[3]) || util.IsSpace(line[3])) { + if len(line) > 2 && ((line[1] == 'v' && line[2] == 'e') || + (line[1] == 'l' && line[2] == 'l') || (line[1] == 'r' && line[2] == 'e')) && + (len(line) < 4 || util.IsPunct(line[3]) || util.IsSpace(line[3])) { nt = RightSingleQuote } if nt == LeftSingleQuote { @@ -266,8 +272,9 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser return node } if s.Substitutions[RightSingleQuote] != nil { - // plural possesives and abbreviations: Smiths', doin' - if len(line) > 1 && unicode.IsSpace(util.ToRune(line, 0)) || unicode.IsPunct(util.ToRune(line, 0)) && (len(line) > 2 && !unicode.IsDigit(util.ToRune(line, 1))) { + // plural possesive and abbreviations: Smiths', doin' + if len(line) > 1 && unicode.IsSpace(util.ToRune(line, 0)) || unicode.IsPunct(util.ToRune(line, 0)) && + (len(line) > 2 && !unicode.IsDigit(util.ToRune(line, 1))) { node := gast.NewString(s.Substitutions[RightSingleQuote]) node.SetCode(true) block.Advance(1) @@ -276,7 +283,8 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser } if s.Substitutions[RightSingleQuote] != nil && counter.Single > 0 { isClose := d.CanClose && !d.CanOpen - maybeClose := d.CanClose && d.CanOpen && len(line) > 1 && unicode.IsPunct(util.ToRune(line, 1)) && (len(line) == 2 || (len(line) > 2 && util.IsPunct(line[2]) || util.IsSpace(line[2]))) + maybeClose := d.CanClose && d.CanOpen && len(line) > 1 && unicode.IsPunct(util.ToRune(line, 1)) && + (len(line) == 2 || (len(line) > 2 && util.IsPunct(line[2]) || util.IsSpace(line[2]))) if isClose || maybeClose { node := gast.NewString(s.Substitutions[RightSingleQuote]) node.SetCode(true) @@ -296,7 +304,8 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser } if s.Substitutions[RightDoubleQuote] != nil && counter.Double > 0 { isClose := d.CanClose && !d.CanOpen - maybeClose := d.CanClose && d.CanOpen && len(line) > 1 && (unicode.IsPunct(util.ToRune(line, 1))) && (len(line) == 2 || (len(line) > 2 && util.IsPunct(line[2]) || util.IsSpace(line[2]))) + maybeClose := d.CanClose && d.CanOpen && len(line) > 1 && (unicode.IsPunct(util.ToRune(line, 1))) && + (len(line) == 2 || (len(line) > 2 && util.IsPunct(line[2]) || util.IsSpace(line[2]))) if isClose || maybeClose { // special case: "Monitor 21"" if len(line) > 1 && line[1] == '"' && unicode.IsDigit(before) { |
