Skip to content

Instantly share code, notes, and snippets.

@tomhodgins
Last active January 3, 2020 00:50
Show Gist options
  • Save tomhodgins/5ba20f04001f411106291e7277b5ed81 to your computer and use it in GitHub Desktop.
Save tomhodgins/5ba20f04001f411106291e7277b5ed81 to your computer and use it in GitHub Desktop.
import {parse} from 'https://unpkg.com/cssomtools'
function CSSUnescape(string = '') {
return JSON.parse(
parse(`
::-webkit-custom-pseudo {
content: "${string}";
}
`).cssRules[0].style.getPropertyValue('content')
)
}
console.assert(
CSSUnescape('\\#1\\$2\\%3') === '#1$2%3'
)
console.assert(
CSSUnescape('\\63 \\73 \\73 \\69 \\73 \\63 \\75 \\74 \\65') === 'css is cute'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment