Move HTML entities JSON file to src/core/vendor/htmlEntities with txt file containing link and copyright notice.
This commit is contained in:
parent
ff0826bd50
commit
98a768ffda
@ -4,7 +4,8 @@
|
||||
* operations.
|
||||
*
|
||||
* The data is derived from the vendored WHATWG named character reference set
|
||||
* (htmlEntities.json, from https://html.spec.whatwg.org/entities.json) so the
|
||||
* (src/core/vendor/htmlEntities/entity.json, from
|
||||
* https://html.spec.whatwg.org/entities.json) so the
|
||||
* two operations cannot drift apart and every entity is spec-conformant:
|
||||
*
|
||||
* - HTML_ENTITY_REVERSE_LOOKUP (decode) is every single-code-point spec name.
|
||||
@ -34,7 +35,8 @@ if (!fs.existsSync(path.join(process.cwd(), "src/core/lib"))) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const SPEC = JSON.parse(fs.readFileSync(path.join(scriptDir, "htmlEntities.json"), "utf8"));
|
||||
const SPEC = JSON.parse(fs.readFileSync(
|
||||
path.join(scriptDir, "..", "..", "vendor", "htmlEntities", "entity.json"), "utf8"));
|
||||
|
||||
// Build code point -> [spec names] for single-code-point, semicolon-terminated
|
||||
// references (the representable subset; multi-code-point entities are skipped).
|
||||
@ -97,7 +99,8 @@ const code = `/**
|
||||
* HTML entity lookup tables shared by the "To HTML Entity" and "From HTML Entity"
|
||||
* operations, derived from the WHATWG named character reference set
|
||||
* (https://html.spec.whatwg.org/entities.json). Do not edit by hand — change the
|
||||
* vendored htmlEntities.json or htmlEntityOverrides.mjs and regenerate.
|
||||
* vendored src/core/vendor/htmlEntities/entity.json or htmlEntityOverrides.mjs
|
||||
* and regenerate.
|
||||
*
|
||||
* @author roberson-io [michaelroberson@gmail.com]
|
||||
* @copyright Crown Copyright ${new Date().getUTCFullYear()}
|
||||
|
||||
14
src/core/vendor/htmlEntities/entity.txt
vendored
Normal file
14
src/core/vendor/htmlEntities/entity.txt
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
entity.json is the WHATWG named character reference set, retrieved verbatim from:
|
||||
|
||||
https://html.spec.whatwg.org/entities.json
|
||||
|
||||
It is used by src/core/config/scripts/generateHTMLEntities.mjs to generate the
|
||||
shared HTML entity lookup tables (src/core/lib/HTMLEntities.mjs) consumed by the
|
||||
"To HTML Entity" and "From HTML Entity" operations.
|
||||
|
||||
Source: HTML Standard — 13.5 Named character references
|
||||
https://html.spec.whatwg.org/multipage/named-characters.html
|
||||
|
||||
Copyright and licence
|
||||
---------------------
|
||||
Copyright © WHATWG (Apple, Google, Mozilla, Microsoft). This work is licensed under a Creative Commons Attribution 4.0 International License. To the extent portions of it are incorporated into source code, such portions in the source code are licensed under the BSD 3-Clause License instead.
|
||||
@ -11,7 +11,7 @@ import path from "path";
|
||||
// Vendored WHATWG named character reference set (https://html.spec.whatwg.org/entities.json).
|
||||
const SPEC = JSON.parse(readFileSync(path.join(
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
"../../../src/core/config/scripts/htmlEntities.json"), "utf8"));
|
||||
"../../../src/core/vendor/htmlEntities/entity.json"), "utf8"));
|
||||
const specByName = {};
|
||||
for (const [key, val] of Object.entries(SPEC))
|
||||
if (key.endsWith(";")) specByName[key.slice(1, -1)] = val.codepoints;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user