-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
formatter: render HTML entities (#481)
- Loading branch information
Showing
6 changed files
with
2,304 additions
and
13 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
// entities.json is from https://html.spec.whatwg.org/entities.json | ||
// which is built by https://github.com/whatwg/html-build/tree/main/entities | ||
// this processes it into a form more useful for us | ||
// no new entities will be added, so the output of this file is committed | ||
// rather than running it every time | ||
|
||
let fs = require('fs'); | ||
let entities = require('./entities.json'); | ||
|
||
let transformed = Object.fromEntries(Object.entries(entities).map(([k, v]) => { | ||
// whitespace, default-ignorable, combining characters, control characters | ||
if (v.characters === '&' || v.characters === '<' || /\p{White_Space}|\p{DI}|\p{gc=M}|\p{gc=C}/u.test(v.characters)) { | ||
return [k, null]; | ||
} | ||
return [k, v.characters]; | ||
})); | ||
fs.writeFileSync('./entities-processed.json', JSON.stringify(transformed), 'utf8'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters