diff --git a/src/core/config/scripts/generateHTMLEntities.mjs b/src/core/config/scripts/generateHTMLEntities.mjs index 12126a36..6ff2bdbb 100644 --- a/src/core/config/scripts/generateHTMLEntities.mjs +++ b/src/core/config/scripts/generateHTMLEntities.mjs @@ -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()} diff --git a/src/core/config/scripts/htmlEntities.json b/src/core/vendor/htmlEntities/entity.json similarity index 100% rename from src/core/config/scripts/htmlEntities.json rename to src/core/vendor/htmlEntities/entity.json diff --git a/src/core/vendor/htmlEntities/entity.txt b/src/core/vendor/htmlEntities/entity.txt new file mode 100644 index 00000000..14696f83 --- /dev/null +++ b/src/core/vendor/htmlEntities/entity.txt @@ -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. diff --git a/tests/node/tests/ToHTMLEntity.mjs b/tests/node/tests/ToHTMLEntity.mjs index e3bf683a..2ac47f3d 100644 --- a/tests/node/tests/ToHTMLEntity.mjs +++ b/tests/node/tests/ToHTMLEntity.mjs @@ -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;