astro-ghostcms/.pnpm-store/v3/files/6e/4d1c49ad385393de20e86405df4...

15 lines
393 B
Plaintext

/**
* Configurable ways to encode characters as hexadecimal references.
*
* @param {number} code
* @param {number} next
* @param {boolean|undefined} omit
* @returns {string}
*/
export function toHexadecimal(code, next, omit) {
const value = '&#x' + code.toString(16).toUpperCase()
return omit && next && !/[\dA-Fa-f]/.test(String.fromCharCode(next))
? value
: value + ';'
}