Provides a collection of named character references commonly used in HTML. It offers functions to check if a character is a named character reference, retrieve information about a named character reference, and obtain an iterable of all named character references. This module is useful for handling and manipulating HTML character references in your web development projects.
You can install this module using npm or yarn:
npm install named-characters
# or
yarn add named-charactersYou can use the isNamedChar function to check if a character is a named character reference. It returns true if the character is a named character reference, and false otherwise.
import { isNamedChar } from 'named-characters'
isNamedChar('<') // yields: true
isNamedChar('lt') // yields: true
isNamedChar('&') // yields: true
isNamedChar('&') // yields: true
isNamedChar('amp') // yields: true
isNamedChar('&') // yields: false
isNamedChar('amp;') // yields: false
isNamedChar('&foo;') // yields: falseTo retrieve information about a named character reference, use the getCharInfo function. It returns an object containing the name, Unicode code point, and glyph representation of the character reference. If the character is not found, it returns undefined.
import { getCharInfo } from 'named-characters'
const charInfo = getCharInfo('♥')
console.log(charInfo)Yields:
{
name: 'hearts',
unicode: 'U+02665',
glyph: '♥'
}To obtain an iterable of all named character references, you can use the getCharRefs function. It returns an iterable that allows you to iterate through all the named character references in the collection.
import { getCharRefs } from 'named-characters'
const charRefs = getCharRefs()
for (const charInfo of charRefs) {
console.log(charInfo)
}Yields:
{ name: 'AElig', unicode: 'U+000C6', glyph: 'Æ' }
{ name: 'AMP', unicode: 'U+00026', glyph: '&' }
{ name: 'Aacute', unicode: 'U+000C1', glyph: 'Á' }
{ name: 'Abreve', unicode: 'U+00102', glyph: 'Ă' }
{ name: 'Acirc', unicode: 'U+000C2', glyph: 'Â' }
...- attributes-parser - Tokenize and parse attributes string into meaningful tokens and key-value pairs.
We 💛 issues.
When committing, please conform to the semantic-release commit standards. Please install commitizen and the adapter globally, if you have not already.
npm i -g commitizen cz-conventional-changelogNow you can use git cz or just cz instead of git commit when committing. You can also use git-cz, which is an alias for cz.
git add . && git czA project by Stilearning © 2023.