MCPcopy Create free account
hub / github.com/cli/cli / unescapePunctuation

Function unescapePunctuation

internal/attachments/references.go:464–479  ·  view source on GitHub ↗

unescapePunctuation drops the backslash from every backslash-escaped ASCII punctuation character, which is how markdown spells a literal one.

(s string)

Source from the content-addressed store, hash-verified

462// unescapePunctuation drops the backslash from every backslash-escaped ASCII
463// punctuation character, which is how markdown spells a literal one.
464func 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
481type byteRange struct {
482 start, stop int

Callers 2

candidatePathsFunction · 0.85
comparableDestinationFunction · 0.85

Calls 2

ContainsMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected