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

Function unescapePunctuation

internal/attachments/references.go:427–442  ·  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

425// unescapePunctuation drops the backslash from every backslash-escaped ASCII
426// punctuation character, which is how markdown spells a literal one.
427func 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
444type byteRange struct {
445 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