astro-ghostcms/.pnpm-store/v3/files/40/408dac19b880603759e7f22c3a8...

19 lines
591 B
Plaintext
Raw Normal View History

2024-02-14 14:10:47 +00:00
import {characterEntities} from 'character-entities'
const own = {}.hasOwnProperty
/**
* Decode a single character reference (without the `&` or `;`).
* You probably only need this when youre building parsers yourself that follow
* different rules compared to HTML.
* This is optimized to be tiny in browsers.
*
* @param {string} value
* `notin` (named), `#123` (deci), `#x123` (hexa).
* @returns {string|false}
* Decoded reference.
*/
export function decodeNamedCharacterReference(value) {
return own.call(characterEntities, value) ? characterEntities[value] : false
}