unescapePunctuation drops the backslash from every backslash-escaped ASCII punctuation character, which is how markdown spells a literal one.
(s string)
| 462 | // unescapePunctuation drops the backslash from every backslash-escaped ASCII |
| 463 | // punctuation character, which is how markdown spells a literal one. |
| 464 | func unescapePunctuation(s string) string { |
| 465 | if !strings.Contains(s, `\`) { |
| 466 | return s |
| 467 | } |
| 468 | const punct = `!"#$%&'()*+,-./:;<=>?@[\]^_` + "`" + `{|}~` |
| 469 | var b strings.Builder |
| 470 | b.Grow(len(s)) |
| 471 | for i := 0; i < len(s); { |
| 472 | if s[i] == '\\' && i+1 < len(s) && strings.IndexByte(punct, s[i+1]) >= 0 { |
| 473 | i++ |
| 474 | } |
| 475 | b.WriteByte(s[i]) |
| 476 | i++ |
| 477 | } |
| 478 | return b.String() |
| 479 | } |
| 480 | |
| 481 | type byteRange struct { |
| 482 | start, stop int |
no test coverage detected