unescapePunctuation drops the backslash from every backslash-escaped ASCII punctuation character, which is how markdown spells a literal one.
(s string)
| 425 | // unescapePunctuation drops the backslash from every backslash-escaped ASCII |
| 426 | // punctuation character, which is how markdown spells a literal one. |
| 427 | func unescapePunctuation(s string) string { |
| 428 | if !strings.Contains(s, `\`) { |
| 429 | return s |
| 430 | } |
| 431 | const punct = `!"#$%&'()*+,-./:;<=>?@[\]^_` + "`" + `{|}~` |
| 432 | var b strings.Builder |
| 433 | b.Grow(len(s)) |
| 434 | for i := 0; i < len(s); { |
| 435 | if s[i] == '\\' && i+1 < len(s) && strings.IndexByte(punct, s[i+1]) >= 0 { |
| 436 | i++ |
| 437 | } |
| 438 | b.WriteByte(s[i]) |
| 439 | i++ |
| 440 | } |
| 441 | return b.String() |
| 442 | } |
| 443 | |
| 444 | type byteRange struct { |
| 445 | start, stop int |
no test coverage detected