MCPcopy
hub / github.com/tailwindlabs/tailwindcss / unescape

Function unescape

packages/tailwindcss/src/utils/escape.ts:75–97  ·  view source on GitHub ↗
(escaped: string)

Source from the content-addressed store, hash-verified

73}
74
75export function unescape(escaped: string) {
76 return escaped.replace(/\\([\dA-Fa-f]{1,6}[\t\n\f\r ]?|[\S\s])/g, (match) => {
77 if (match.length <= 2) {
78 return match[1]
79 }
80
81 let codePoint = Number.parseInt(match.slice(1).trim(), 16)
82
83 if (
84 // Invalid codepoint: https://infra.spec.whatwg.org/#code-point
85 codePoint === 0x0000 ||
86 codePoint > 0x10ffff ||
87 // Is surrogate: https://infra.spec.whatwg.org/#leading-surrogate
88 // - A leading surrogate is a code point that is in the range U+D800 to U+DBFF, inclusive.
89 // - A trailing surrogate is a code point that is in the range U+DC00 to U+DFFF, inclusive.
90 (codePoint >= 0xd800 && codePoint <= 0xdfff)
91 ) {
92 return '\uFFFD'
93 }
94
95 return String.fromCodePoint(codePoint)
96 })
97}

Callers 6

parseCssFunction · 0.90
getOptionsMethod · 0.90
markUsedVariableMethod · 0.90
createCssUtilityFunction · 0.90
createThemeFnFunction · 0.90
escape.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected