@mark1russell7/text 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -1
- package/build/html.d.ts +1 -0
- package/build/html.d.ts.map +1 -1
- package/build/html.js.map +1 -1
- package/build/index.d.ts +5 -2
- package/build/index.d.ts.map +1 -1
- package/build/references.d.ts +18 -0
- package/build/references.d.ts.map +1 -0
- package/build/references.js +344 -0
- package/build/references.js.map +1 -0
- package/build/shell.d.ts +15 -0
- package/build/shell.d.ts.map +1 -0
- package/build/shell.js +27 -0
- package/build/shell.js.map +1 -0
- package/package.json +11 -2
- package/src/html-references.ts +207 -0
- package/src/html.ts +1 -0
- package/src/index.ts +5 -2
- package/src/references.ts +140 -0
- package/src/shell.ts +26 -0
package/README.md
CHANGED
|
@@ -26,6 +26,20 @@ next")}`); // "::warning title=a%3A b::50%25%0Anext"
|
|
|
26
26
|
escapeMarkdown("a | b *c*"); // "a \\| b \\*c\\*"
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
### One word of a POSIX shell
|
|
30
|
+
|
|
31
|
+
`escapeShell(text)` gives one word that a POSIX shell reads as the text, with no expansion and no split into words. A text of safe characters only (letters, digits and `_ @ % + = : , . / -`) stays as it is. Each other text goes in single quotes, and each `'` becomes `'\''`. The empty text becomes `''`.
|
|
32
|
+
|
|
33
|
+
The entry `@mark1russell7/text/shell` has `escapeShell`. The root entry does not have it, to keep its size.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { escapeShell } from "@mark1russell7/text/shell";
|
|
37
|
+
|
|
38
|
+
escapeShell("notes.txt"); // "notes.txt"
|
|
39
|
+
escapeShell("my file's name"); // "'my file'\\''s name'"
|
|
40
|
+
escapeShell("$HOME"); // "'$HOME'"
|
|
41
|
+
```
|
|
42
|
+
|
|
29
43
|
## English word forms
|
|
30
44
|
|
|
31
45
|
`countOf(count, noun, plural?)` gives a count with a noun. Only the count 1 takes the singular noun. The default plural noun is the singular noun with "s" at the end.
|
|
@@ -288,6 +302,27 @@ elements.some((element) => element.name === "link" && element.attributes["rel"]
|
|
|
288
302
|
scanHtml("<html><head><title>T</title></head><body><noscript>On</noscript>Body</body></html>", { skip: ["head", "script", "style", "template", "noscript"] }).text; // " Body "
|
|
289
303
|
```
|
|
290
304
|
|
|
305
|
+
### The decode of character references
|
|
306
|
+
|
|
307
|
+
`decodeReferences(text)` of the entry `@mark1russell7/text/references` decodes the character references of HTML content, as the tokenizer of the HTML Living Standard does. Use it on the `text` of a scan.
|
|
308
|
+
|
|
309
|
+
- A named reference gets its value from the table of the standard, with its 2231 names. The longest name wins.
|
|
310
|
+
- A legacy name, for example `&` or ` `, is also correct with no semicolon. Thus `¬it;` gives `¬it;`.
|
|
311
|
+
- A decimal or hexadecimal reference gives its code point. The semicolon after the digits is optional.
|
|
312
|
+
- The value 0, a surrogate and a value above `0x10FFFF` give U+FFFD. The values `0x80` to `0x9F` give the characters of windows-1252.
|
|
313
|
+
- An ampersand with no reference after it stays as text. The function changes no other character.
|
|
314
|
+
- The function does not throw, and it is linear in the length of the text.
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
import { scanHtml } from "@mark1russell7/text/html";
|
|
318
|
+
import { decodeReferences } from "@mark1russell7/text/references";
|
|
319
|
+
|
|
320
|
+
decodeReferences("We’re on it – ’’ ©2026 ¬it;"); // "We’re on it – ’’ ©2026 ¬it;"
|
|
321
|
+
decodeReferences(scanHtml("<p>Fish & chips</p>").text); // " Fish & chips "
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
The table comes from `entities.json` of the standard, under the license CC BY 4.0. The script `scripts/html-references.ts` makes the module `src/html-references.ts` from it. The table is in the entry `./references`. Thus a bundle that imports only `scanHtml` does not get the table.
|
|
325
|
+
|
|
291
326
|
## The copies that this package replaces
|
|
292
327
|
|
|
293
328
|
The tests run 58 copies of these functions from other repositories of the owner. Each copy comes from a list of the duplication atlas, at a pinned commit. The file `test/copies.json` has each copy, and `test/differences.ts` has each difference from the function of this package, with its reason. A copy that is not in the list gives the same output on each of the 1000 test strings.
|
|
@@ -299,6 +334,7 @@ The tests also examine 18 copies of a cut with a mark, from a later list of the
|
|
|
299
334
|
- `escapeHtml` does not escape quotes. For an attribute value, use `escapeAttribute`.
|
|
300
335
|
- `escapeRegExp` gives a pattern for use outside a character class. In a class, `-` also has a meaning.
|
|
301
336
|
- `escapeMarkdown` does not change spaces. Four spaces at the start of a line make a code block.
|
|
337
|
+
- `escapeShell` gives one word for a POSIX shell, not for `cmd.exe` or PowerShell. It throws a `RangeError` for a text with NUL.
|
|
302
338
|
- `wordSearch` keeps accents, so "cafe" does not find "café".
|
|
303
339
|
- `countOf` knows no irregular plural. Give the plural noun for each noun that does not add "s".
|
|
304
340
|
- `listOf` does not change the parts. A part with a comma makes a list that a reader cannot split again.
|
|
@@ -311,6 +347,8 @@ The tests also examine 18 copies of a cut with a mark, from a later list of the
|
|
|
311
347
|
- `partsAt` counts in code units, as `String.prototype.slice` does. A range can cut a surrogate pair or a grapheme.
|
|
312
348
|
- The three functions count units, not the width on a screen. A wide character, for example 日, is one unit, as a narrow character is.
|
|
313
349
|
- `scanHtml` does not make a tree. It does not close an element with no end tag, and it does not move an element as a browser does.
|
|
314
|
-
- `scanHtml` keeps the character references of the text and of each attribute value. Thus `&` stays as five characters.
|
|
350
|
+
- `scanHtml` keeps the character references of the text and of each attribute value. Thus `&` stays as five characters. `decodeReferences` decodes them.
|
|
351
|
+
- `decodeReferences` uses the rule of element content. In an attribute value, a legacy name with no semicolon before `=`, a letter or a digit stays as text, for example `©=`.
|
|
352
|
+
- `decodeReferences` does not change the other characters. The tokenizer also changes a NUL character and a carriage return, but this function does not.
|
|
315
353
|
- In `scanHtml`, a comment or a skipped element with no end is text. A browser hides the rest of the page in that case.
|
|
316
354
|
- In `scanHtml`, a tag in a word also gives a space. Thus `a<b>c</b>` gives the text `a c `.
|
package/build/html.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface HtmlScan {
|
|
|
20
20
|
/**
|
|
21
21
|
* The text of the HTML outside the tags, the comments and the skipped elements. Each tag, comment and skipped element
|
|
22
22
|
* gives one space, so two words in two elements stay two words. The white space and the character references stay as in the HTML.
|
|
23
|
+
* The function `decodeReferences` of the entry `./references` decodes the character references.
|
|
23
24
|
*/
|
|
24
25
|
readonly text: string;
|
|
25
26
|
/** The start tags outside the comments and the skipped elements, in the order of the HTML. The start tag of a skipped element is in the list. */
|
package/build/html.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","names":[],"sources":["../src/html.ts"],"mappings":";;;;;;iBAOiB;;WAEN;;;;;WAKA,YAAY,SAAS;;WAErB;;;iBAIM
|
|
1
|
+
{"version":3,"file":"html.d.ts","names":[],"sources":["../src/html.ts"],"mappings":";;;;;;iBAOiB;;WAEN;;;;;WAKA,YAAY,SAAS;;WAErB;;;iBAIM;;;;;;WAMN;;WAEA,mBAAmB;;;iBAIb;;WAEN;;;qBAIE;;;;;;;;;;;;;;;wBAqGG,SAAS,cAAc,UAAS,kBAAuB"}
|
package/build/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","names":[],"sources":["../src/html.ts"],"sourcesContent":["/**\n * This module scans HTML for its text and its start tags, with no DOM. A check of a page reads the text that a reader with\n * no script gets. It also reads the elements of the page, for example an `h1` or a `link` with `rel=\"icon\"`. The scan is\n * linear in the length of the HTML. Thus a page with many starts of a comment and no end does not stop it.\n */\n\n/** A start tag that the scan found. */\nexport interface HtmlElement {\n /** The name of the element, in lower case. */\n readonly name: string;\n /**\n * The attributes of the start tag. Each name is in lower case. A value has no quotes, and its character references stay\n * as in the HTML. An attribute with no value has an empty value. When a tag has a name two times, the first value counts.\n */\n readonly attributes: Readonly<Record<string, string>>;\n /** The index of the \"<\" of the start tag in the HTML, in UTF-16 code units. */\n readonly start: number;\n}\n\n/** The result of a scan of HTML. */\nexport interface HtmlScan {\n /**\n * The text of the HTML outside the tags, the comments and the skipped elements. Each tag, comment and skipped element\n * gives one space, so two words in two elements stay two words. The white space and the character references stay as in the HTML.\n */\n readonly text: string;\n /** The start tags outside the comments and the skipped elements, in the order of the HTML. The start tag of a skipped element is in the list. */\n readonly elements: readonly HtmlElement[];\n}\n\n/** The options of `scanHtml`. */\nexport interface HtmlScanOptions {\n /** The names of the elements whose content gives no text and no element. The default is `HTML_SKIP`. */\n readonly skip?: readonly string[];\n}\n\n/** The elements that the scan skips by default. A script and a style hold code, not text, and a template is not on the page. */\nexport const HTML_SKIP: readonly string[] = Object.freeze([\"script\", \"style\", \"template\"]);\n\n/**\n * The elements whose content has no tags. A \"<\" in a script, a title or a text area does not start a tag. The content of\n * such an element that the scan does not skip is text.\n */\nconst RAW_TEXT: readonly string[] = [\"script\", \"style\", \"title\", \"textarea\", \"xmp\", \"iframe\", \"noembed\", \"noframes\"];\n\n/** This function tells if a character is white space in HTML: space, tab, line feed, form feed or carriage return. */\nconst isSpace = (char: string): boolean => char === \" \" || char === \"\\t\" || char === \"\\n\" || char === \"\\f\" || char === \"\\r\";\n\n/** This function tells if a character ends the name of a tag: white space, \"/\", \">\" or the end of the HTML. */\nconst endsName = (char: string): boolean => char === \"\" || char === \"/\" || char === \">\" || isSpace(char);\n\n/** A search for the first index of a text at or after a position, or -1. */\ntype Search = (needle: string, from: number) => number;\n\n/**\n * This function gives a search in a source. A text that is not after a position is not after a later position either. Thus\n * the search keeps each failure and does not do it again, and a scan with many searches stays linear.\n */\nfunction searchIn(source: string): Search {\n const missing = new Map<string, number>();\n return (needle, from) => {\n const least = missing.get(needle);\n if (least !== undefined && from >= least) return -1;\n const index = source.indexOf(needle, from);\n if (index === -1) missing.set(needle, from);\n return index;\n };\n}\n\n/** This function reads the start tag at `lt`. It gives undefined for a tag with no \">\" after it. */\nfunction readTag(html: string, lower: string, lt: number): { element: HtmlElement; end: number } | undefined {\n let at = lt + 1;\n while (!endsName(lower.charAt(at))) at += 1;\n const name = lower.slice(lt + 1, at);\n const attributes = new Map<string, string>();\n while (at < lower.length) {\n const char = lower.charAt(at);\n if (char === \">\") return { element: { name, attributes: Object.fromEntries(attributes), start: lt }, end: at + 1 };\n if (char === \"/\" || isSpace(char)) {\n at += 1;\n continue;\n }\n // A name of an attribute ends at white space, \"/\", \">\" or \"=\". A \"=\" at its start is a part of the name.\n const from = at;\n at += 1;\n while (!endsName(lower.charAt(at)) && lower.charAt(at) !== \"=\") at += 1;\n const key = lower.slice(from, at);\n let value = \"\";\n let next = at;\n while (isSpace(lower.charAt(next))) next += 1;\n if (lower.charAt(next) === \"=\") {\n next += 1;\n while (isSpace(lower.charAt(next))) next += 1;\n const quote = lower.charAt(next);\n if (quote === '\"' || quote === \"'\") {\n const close = lower.indexOf(quote, next + 1);\n if (close === -1) return undefined;\n value = html.slice(next + 1, close);\n at = close + 1;\n } else {\n at = next;\n while (at < lower.length && lower.charAt(at) !== \">\" && !isSpace(lower.charAt(at))) at += 1;\n value = html.slice(next, at);\n }\n }\n if (!attributes.has(key)) attributes.set(key, value);\n }\n return undefined;\n}\n\n/**\n * This function gives the start and the end of the end tag of `name` at or after `from`, or undefined. The name of the end\n * tag ends at white space, \"/\" or \">\", and the tag ends at the next \">\".\n */\nfunction endTagOf(lower: string, name: string, from: number, search: Search): { start: number; end: number } | undefined {\n const needle = `</${name}`;\n for (let start = search(needle, from); start !== -1; start = search(needle, start + 1)) {\n if (!endsName(lower.charAt(start + needle.length)) || lower.charAt(start + needle.length) === \"\") continue;\n const gt = search(\">\", start + needle.length);\n return gt === -1 ? undefined : { start, end: gt + 1 };\n }\n return undefined;\n}\n\n/**\n * This function scans HTML for its text and its start tags, from the left to the right, in one pass.\n *\n * - A comment, a tag, a doctype and a processing instruction give no text. Each gives one space.\n * - The content of an element of `skip`, to its end tag, gives no text and no element.\n * - The content of a script, a style, a title or a text area that the scan does not skip is text with no tags.\n * - A \"<\" starts a tag only before a letter, \"/\", \"!\" or \"?\", as in HTML. Each other \"<\" is text, as in `1 < 2`.\n * - A comment or a skipped element with no end is text, and the scan continues in it. A tag with no \">\" ends the scan,\n * and the rest of the HTML is text.\n *\n * @param html - The HTML, a document or a part of one.\n * @param options - The elements to skip. The default is `HTML_SKIP`.\n * @returns The text and the start tags.\n */\nexport function scanHtml(html: string, options: HtmlScanOptions = {}): HtmlScan {\n const skip = new Set((options.skip ?? HTML_SKIP).map((name) => name.toLowerCase()));\n // Only A to Z go to lower case, so each index of the copy is an index of the HTML.\n const lower = html.replace(/[A-Z]+/g, (upper) => upper.toLowerCase());\n const search = searchIn(lower);\n const unclosed = new Set<string>();\n const parts: string[] = [];\n const elements: HtmlElement[] = [];\n let at = 0;\n for (let lt = search(\"<\", 0); lt !== -1; lt = search(\"<\", Math.max(at, lt + 1))) {\n const next = lower.charAt(lt + 1);\n let end: number;\n if (lower.startsWith(\"<!--\", lt)) {\n // A comment can end at once: `<!-->` and `<!--->` are comments.\n const close = search(\"-->\", lt + 2);\n if (close === -1) continue;\n end = close + 3;\n } else if (next === \"/\" || next === \"!\" || next === \"?\") {\n const gt = search(\">\", lt + 2);\n if (gt === -1) break;\n end = gt + 1;\n } else if (next >= \"a\" && next <= \"z\") {\n const tag = readTag(html, lower, lt);\n if (tag === undefined) break;\n elements.push(tag.element);\n end = tag.end;\n const { name } = tag.element;\n const skipped = skip.has(name);\n if ((skipped || RAW_TEXT.includes(name)) && !unclosed.has(name)) {\n const close = endTagOf(lower, name, end, search);\n if (close === undefined) unclosed.add(name);\n else {\n parts.push(html.slice(at, lt), \" \");\n if (!skipped) parts.push(html.slice(end, close.start), \" \");\n at = close.end;\n continue;\n }\n }\n } else continue;\n parts.push(html.slice(at, lt), \" \");\n at = end;\n }\n parts.push(html.slice(at));\n return { text: parts.join(\"\"), elements };\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"html.js","names":[],"sources":["../src/html.ts"],"sourcesContent":["/**\n * This module scans HTML for its text and its start tags, with no DOM. A check of a page reads the text that a reader with\n * no script gets. It also reads the elements of the page, for example an `h1` or a `link` with `rel=\"icon\"`. The scan is\n * linear in the length of the HTML. Thus a page with many starts of a comment and no end does not stop it.\n */\n\n/** A start tag that the scan found. */\nexport interface HtmlElement {\n /** The name of the element, in lower case. */\n readonly name: string;\n /**\n * The attributes of the start tag. Each name is in lower case. A value has no quotes, and its character references stay\n * as in the HTML. An attribute with no value has an empty value. When a tag has a name two times, the first value counts.\n */\n readonly attributes: Readonly<Record<string, string>>;\n /** The index of the \"<\" of the start tag in the HTML, in UTF-16 code units. */\n readonly start: number;\n}\n\n/** The result of a scan of HTML. */\nexport interface HtmlScan {\n /**\n * The text of the HTML outside the tags, the comments and the skipped elements. Each tag, comment and skipped element\n * gives one space, so two words in two elements stay two words. The white space and the character references stay as in the HTML.\n * The function `decodeReferences` of the entry `./references` decodes the character references.\n */\n readonly text: string;\n /** The start tags outside the comments and the skipped elements, in the order of the HTML. The start tag of a skipped element is in the list. */\n readonly elements: readonly HtmlElement[];\n}\n\n/** The options of `scanHtml`. */\nexport interface HtmlScanOptions {\n /** The names of the elements whose content gives no text and no element. The default is `HTML_SKIP`. */\n readonly skip?: readonly string[];\n}\n\n/** The elements that the scan skips by default. A script and a style hold code, not text, and a template is not on the page. */\nexport const HTML_SKIP: readonly string[] = Object.freeze([\"script\", \"style\", \"template\"]);\n\n/**\n * The elements whose content has no tags. A \"<\" in a script, a title or a text area does not start a tag. The content of\n * such an element that the scan does not skip is text.\n */\nconst RAW_TEXT: readonly string[] = [\"script\", \"style\", \"title\", \"textarea\", \"xmp\", \"iframe\", \"noembed\", \"noframes\"];\n\n/** This function tells if a character is white space in HTML: space, tab, line feed, form feed or carriage return. */\nconst isSpace = (char: string): boolean => char === \" \" || char === \"\\t\" || char === \"\\n\" || char === \"\\f\" || char === \"\\r\";\n\n/** This function tells if a character ends the name of a tag: white space, \"/\", \">\" or the end of the HTML. */\nconst endsName = (char: string): boolean => char === \"\" || char === \"/\" || char === \">\" || isSpace(char);\n\n/** A search for the first index of a text at or after a position, or -1. */\ntype Search = (needle: string, from: number) => number;\n\n/**\n * This function gives a search in a source. A text that is not after a position is not after a later position either. Thus\n * the search keeps each failure and does not do it again, and a scan with many searches stays linear.\n */\nfunction searchIn(source: string): Search {\n const missing = new Map<string, number>();\n return (needle, from) => {\n const least = missing.get(needle);\n if (least !== undefined && from >= least) return -1;\n const index = source.indexOf(needle, from);\n if (index === -1) missing.set(needle, from);\n return index;\n };\n}\n\n/** This function reads the start tag at `lt`. It gives undefined for a tag with no \">\" after it. */\nfunction readTag(html: string, lower: string, lt: number): { element: HtmlElement; end: number } | undefined {\n let at = lt + 1;\n while (!endsName(lower.charAt(at))) at += 1;\n const name = lower.slice(lt + 1, at);\n const attributes = new Map<string, string>();\n while (at < lower.length) {\n const char = lower.charAt(at);\n if (char === \">\") return { element: { name, attributes: Object.fromEntries(attributes), start: lt }, end: at + 1 };\n if (char === \"/\" || isSpace(char)) {\n at += 1;\n continue;\n }\n // A name of an attribute ends at white space, \"/\", \">\" or \"=\". A \"=\" at its start is a part of the name.\n const from = at;\n at += 1;\n while (!endsName(lower.charAt(at)) && lower.charAt(at) !== \"=\") at += 1;\n const key = lower.slice(from, at);\n let value = \"\";\n let next = at;\n while (isSpace(lower.charAt(next))) next += 1;\n if (lower.charAt(next) === \"=\") {\n next += 1;\n while (isSpace(lower.charAt(next))) next += 1;\n const quote = lower.charAt(next);\n if (quote === '\"' || quote === \"'\") {\n const close = lower.indexOf(quote, next + 1);\n if (close === -1) return undefined;\n value = html.slice(next + 1, close);\n at = close + 1;\n } else {\n at = next;\n while (at < lower.length && lower.charAt(at) !== \">\" && !isSpace(lower.charAt(at))) at += 1;\n value = html.slice(next, at);\n }\n }\n if (!attributes.has(key)) attributes.set(key, value);\n }\n return undefined;\n}\n\n/**\n * This function gives the start and the end of the end tag of `name` at or after `from`, or undefined. The name of the end\n * tag ends at white space, \"/\" or \">\", and the tag ends at the next \">\".\n */\nfunction endTagOf(lower: string, name: string, from: number, search: Search): { start: number; end: number } | undefined {\n const needle = `</${name}`;\n for (let start = search(needle, from); start !== -1; start = search(needle, start + 1)) {\n if (!endsName(lower.charAt(start + needle.length)) || lower.charAt(start + needle.length) === \"\") continue;\n const gt = search(\">\", start + needle.length);\n return gt === -1 ? undefined : { start, end: gt + 1 };\n }\n return undefined;\n}\n\n/**\n * This function scans HTML for its text and its start tags, from the left to the right, in one pass.\n *\n * - A comment, a tag, a doctype and a processing instruction give no text. Each gives one space.\n * - The content of an element of `skip`, to its end tag, gives no text and no element.\n * - The content of a script, a style, a title or a text area that the scan does not skip is text with no tags.\n * - A \"<\" starts a tag only before a letter, \"/\", \"!\" or \"?\", as in HTML. Each other \"<\" is text, as in `1 < 2`.\n * - A comment or a skipped element with no end is text, and the scan continues in it. A tag with no \">\" ends the scan,\n * and the rest of the HTML is text.\n *\n * @param html - The HTML, a document or a part of one.\n * @param options - The elements to skip. The default is `HTML_SKIP`.\n * @returns The text and the start tags.\n */\nexport function scanHtml(html: string, options: HtmlScanOptions = {}): HtmlScan {\n const skip = new Set((options.skip ?? HTML_SKIP).map((name) => name.toLowerCase()));\n // Only A to Z go to lower case, so each index of the copy is an index of the HTML.\n const lower = html.replace(/[A-Z]+/g, (upper) => upper.toLowerCase());\n const search = searchIn(lower);\n const unclosed = new Set<string>();\n const parts: string[] = [];\n const elements: HtmlElement[] = [];\n let at = 0;\n for (let lt = search(\"<\", 0); lt !== -1; lt = search(\"<\", Math.max(at, lt + 1))) {\n const next = lower.charAt(lt + 1);\n let end: number;\n if (lower.startsWith(\"<!--\", lt)) {\n // A comment can end at once: `<!-->` and `<!--->` are comments.\n const close = search(\"-->\", lt + 2);\n if (close === -1) continue;\n end = close + 3;\n } else if (next === \"/\" || next === \"!\" || next === \"?\") {\n const gt = search(\">\", lt + 2);\n if (gt === -1) break;\n end = gt + 1;\n } else if (next >= \"a\" && next <= \"z\") {\n const tag = readTag(html, lower, lt);\n if (tag === undefined) break;\n elements.push(tag.element);\n end = tag.end;\n const { name } = tag.element;\n const skipped = skip.has(name);\n if ((skipped || RAW_TEXT.includes(name)) && !unclosed.has(name)) {\n const close = endTagOf(lower, name, end, search);\n if (close === undefined) unclosed.add(name);\n else {\n parts.push(html.slice(at, lt), \" \");\n if (!skipped) parts.push(html.slice(end, close.start), \" \");\n at = close.end;\n continue;\n }\n }\n } else continue;\n parts.push(html.slice(at, lt), \" \");\n at = end;\n }\n parts.push(html.slice(at));\n return { text: parts.join(\"\"), elements };\n}\n"],"mappings":"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"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The entry of `@mark1russell7/text`: plain text helpers. The first group is the escapes for HTML, attributes, regular
|
|
3
3
|
* expressions, Markdown and GitHub Actions workflow commands. The other groups are the English word forms, a word
|
|
4
|
-
* search and the text of a thrown value.
|
|
4
|
+
* search and the text of a thrown value.
|
|
5
|
+
*
|
|
6
|
+
* The entry `@mark1russell7/text/redact` removes secrets from a text, and the entry
|
|
5
7
|
* `@mark1russell7/text/order` has two orders of texts. The entry `@mark1russell7/text/english` adds the list join `listOf`.
|
|
6
|
-
* The entry `@mark1russell7/text/search` adds a ranked search with TF-IDF.
|
|
8
|
+
* The entry `@mark1russell7/text/search` adds a ranked search with TF-IDF. The entry `@mark1russell7/text/shell` has the
|
|
9
|
+
* escape of a POSIX shell word.
|
|
7
10
|
*/
|
|
8
11
|
import { countOf } from "./english.js";
|
|
9
12
|
import { searchKey, wordSearch } from "./search.js";
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/error.ts","../src/escape.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/error.ts","../src/escape.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkBgB,aAAa;;;;;;;;wBCHb,WAAW;;;;;;;;wBAWX,gBAAgB;;;;;;;;;wBAYhB,aAAa;;;;;;;;;;;;wBAeb,eAAe;;;;;;;;wBAWf,mBAAmB;;;;;;;;wBAWnB,uBAAuB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function decodes the character references of a text, as the tokenizer of the HTML Living Standard does in the
|
|
3
|
+
* content of an element. Use it on the `text` of a scan of `scanHtml`.
|
|
4
|
+
*
|
|
5
|
+
* - A named reference gets its value from the table of the standard. The longest name wins.
|
|
6
|
+
* - A legacy name, for example `&` or `¬`, is also correct with no semicolon. Thus `¬it;` gives `¬it;`.
|
|
7
|
+
* - A decimal or hexadecimal reference, for example `’` or `’`, gives its code point. The semicolon is optional.
|
|
8
|
+
* - The value 0, a surrogate and a value above `0x10FFFF` give U+FFFD.
|
|
9
|
+
* - The values `0x80` to `0x9F` give the characters of windows-1252, from the table of the standard.
|
|
10
|
+
* - An ampersand with no reference after it stays as text. The function changes no other character.
|
|
11
|
+
*
|
|
12
|
+
* The function does not throw, and it is linear in the length of the text. The result is not longer than the text.
|
|
13
|
+
*
|
|
14
|
+
* @param text - The text of HTML content, with its character references.
|
|
15
|
+
* @returns The text with the value of each character reference in place of the reference.
|
|
16
|
+
*/
|
|
17
|
+
export declare function decodeReferences(text: string): string;
|
|
18
|
+
//# sourceMappingURL=references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.d.ts","names":[],"sources":["../src/references.ts"],"mappings":";;;;;;;;;;;;;;;;wBA2HgB,iBAAiB"}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
// src/html-references.ts
|
|
2
|
+
/**
|
|
3
|
+
* This module has the named character references of HTML. The script `scripts/html-references.ts` made it. Do not
|
|
4
|
+
* edit it. Start the script again to make it.
|
|
5
|
+
*
|
|
6
|
+
* The source is the table of the HTML Living Standard, `https://html.spec.whatwg.org/entities.json`. Copyright WHATWG
|
|
7
|
+
* (Apple, Google, Mozilla, Microsoft). The table has the license CC BY 4.0,
|
|
8
|
+
* `https://creativecommons.org/licenses/by/4.0/`. The SHA-256 of the source file is
|
|
9
|
+
* `d741d877ac77c4194c4ad526b5b4a19aef8dfe411ab840a466891cdbb9f362e6`.
|
|
10
|
+
*
|
|
11
|
+
* The script changed the format of the table, not its content. The source has 2231 names. 106 of them are
|
|
12
|
+
* legacy names, which are in the source with a semicolon and with no semicolon.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The names and the values of the named character references. The names with one value make one group. A comma or a
|
|
16
|
+
* line end comes between two groups. Each group has these parts:
|
|
17
|
+
*
|
|
18
|
+
* - the first code point of the value, as the difference from the first code point of the group before it,
|
|
19
|
+
* - a plus sign and the second code point, only for a value with two code points,
|
|
20
|
+
* - an equals sign and the names of the group, with a space between two names.
|
|
21
|
+
*
|
|
22
|
+
* Each number is in base 36. A name has no ampersand and no semicolon. A star after a name tells that the name is also
|
|
23
|
+
* correct with no semicolon. The groups are in the order of their values. The longest name has 31 characters, and the
|
|
24
|
+
* longest legacy name has 6 characters.
|
|
25
|
+
*/
|
|
26
|
+
const NAMED_REFERENCES = `9=Tab,1=NewLine,n=excl,1=QUOT* quot*,1=num,1=dollar,1=percnt,1=AMP* amp*,1=apos,1=lpar,1=rpar,1=ast midast,1=plus
|
|
27
|
+
1=comma,2=period,1=sol,b=colon,1=semi,1=LT* lt*,0+6he=nvlt,1=equals,0+6hx=bne,1=GT* gt*,0+6he=nvgt,1=quest,1=commat
|
|
28
|
+
r=lbrack lsqb,1=bsol,1=rbrack rsqb,1=Hat,1=UnderBar lowbar,1=DiacriticalGrave grave,6+2y=fjlig,l=lbrace lcub
|
|
29
|
+
1=VerticalLine verbar vert,1=rbrace rcub,z=NonBreakingSpace nbsp*,1=iexcl*,1=cent*,1=pound*,1=curren*,1=yen*
|
|
30
|
+
1=brvbar*,1=sect*,1=Dot DoubleDot die uml*,1=COPY* copy*,1=ordf*,1=laquo*,1=not*,1=shy*,1=REG* circledR reg*
|
|
31
|
+
1=macr* strns,1=deg*,1=PlusMinus plusmn* pm,1=sup2*,1=sup3*,1=DiacriticalAcute acute*,1=micro*,1=para*
|
|
32
|
+
1=CenterDot centerdot middot*,1=Cedilla cedil*,1=sup1*,1=ordm*,1=raquo*,1=frac14*,1=frac12* half,1=frac34*,1=iquest*
|
|
33
|
+
1=Agrave*,1=Aacute*,1=Acirc*,1=Atilde*,1=Auml*,1=Aring* angst,1=AElig*,1=Ccedil*,1=Egrave*,1=Eacute*,1=Ecirc*
|
|
34
|
+
1=Euml*,1=Igrave*,1=Iacute*,1=Icirc*,1=Iuml*,1=ETH*,1=Ntilde*,1=Ograve*,1=Oacute*,1=Ocirc*,1=Otilde*,1=Ouml*
|
|
35
|
+
1=times*,1=Oslash*,1=Ugrave*,1=Uacute*,1=Ucirc*,1=Uuml*,1=Yacute*,1=THORN*,1=szlig*,1=agrave*,1=aacute*,1=acirc*
|
|
36
|
+
1=atilde*,1=auml*,1=aring*,1=aelig*,1=ccedil*,1=egrave*,1=eacute*,1=ecirc*,1=euml*,1=igrave*,1=iacute*,1=icirc*
|
|
37
|
+
1=iuml*,1=eth*,1=ntilde*,1=ograve*,1=oacute*,1=ocirc*,1=otilde*,1=ouml*,1=div divide*,1=oslash*,1=ugrave*,1=uacute*
|
|
38
|
+
1=ucirc*,1=uuml*,1=yacute*,1=thorn*,1=yuml*,1=Amacr,1=amacr,1=Abreve,1=abreve,1=Aogon,1=aogon,1=Cacute,1=cacute
|
|
39
|
+
1=Ccirc,1=ccirc,1=Cdot,1=cdot,1=Ccaron,1=ccaron,1=Dcaron,1=dcaron,1=Dstrok,1=dstrok,1=Emacr,1=emacr,3=Edot,1=edot
|
|
40
|
+
1=Eogon,1=eogon,1=Ecaron,1=ecaron,1=Gcirc,1=gcirc,1=Gbreve,1=gbreve,1=Gdot,1=gdot,1=Gcedil,2=Hcirc,1=hcirc,1=Hstrok
|
|
41
|
+
1=hstrok,1=Itilde,1=itilde,1=Imacr,1=imacr,3=Iogon,1=iogon,1=Idot,1=imath inodot,1=IJlig,1=ijlig,1=Jcirc,1=jcirc
|
|
42
|
+
1=Kcedil,1=kcedil,1=kgreen,1=Lacute,1=lacute,1=Lcedil,1=lcedil,1=Lcaron,1=lcaron,1=Lmidot,1=lmidot,1=Lstrok,1=lstrok
|
|
43
|
+
1=Nacute,1=nacute,1=Ncedil,1=ncedil,1=Ncaron,1=ncaron,1=napos,1=ENG,1=eng,1=Omacr,1=omacr,3=Odblac,1=odblac,1=OElig
|
|
44
|
+
1=oelig,1=Racute,1=racute,1=Rcedil,1=rcedil,1=Rcaron,1=rcaron,1=Sacute,1=sacute,1=Scirc,1=scirc,1=Scedil,1=scedil
|
|
45
|
+
1=Scaron,1=scaron,1=Tcedil,1=tcedil,1=Tcaron,1=tcaron,1=Tstrok,1=tstrok,1=Utilde,1=utilde,1=Umacr,1=umacr,1=Ubreve
|
|
46
|
+
1=ubreve,1=Uring,1=uring,1=Udblac,1=udblac,1=Uogon,1=uogon,1=Wcirc,1=wcirc,1=Ycirc,1=ycirc,1=Yuml,1=Zacute,1=zacute
|
|
47
|
+
1=Zdot,1=zdot,1=Zcaron,1=zcaron,k=fnof,z=imped,1s=gacute,1u=jmath,3z=circ,1=Hacek caron,h=Breve breve
|
|
48
|
+
1=DiacriticalDot dot,1=ring,1=ogon,1=DiacriticalTilde tilde,1=DiacriticalDoubleAcute dblac,1g=DownBreve,3k=Alpha
|
|
49
|
+
1=Beta,1=Gamma,1=Delta,1=Epsilon,1=Zeta,1=Eta,1=Theta,1=Iota,1=Kappa,1=Lambda,1=Mu,1=Nu,1=Xi,1=Omicron,1=Pi,1=Rho
|
|
50
|
+
2=Sigma,1=Tau,1=Upsilon,1=Phi,1=Chi,1=Psi,1=Omega ohm,8=alpha,1=beta,1=gamma,1=delta,1=epsi epsilon,1=zeta,1=eta
|
|
51
|
+
1=theta,1=iota,1=kappa,1=lambda,1=mu,1=nu,1=xi,1=omicron,1=pi,1=rho,1=sigmaf sigmav varsigma,1=sigma,1=tau
|
|
52
|
+
1=upsi upsilon,1=phi,1=chi,1=psi,1=omega,8=thetasym thetav vartheta,1=Upsi upsih,3=phiv straightphi varphi
|
|
53
|
+
1=piv varpi,6=Gammad,1=digamma gammad,j=kappav varkappa,1=rhov varrho,4=epsiv straightepsilon varepsilon
|
|
54
|
+
1=backepsilon bepsi,b=IOcy,1=DJcy,1=GJcy,1=Jukcy,1=DScy,1=Iukcy,1=YIcy,1=Jsercy,1=LJcy,1=NJcy,1=TSHcy,1=KJcy,2=Ubrcy
|
|
55
|
+
1=DZcy,1=Acy,1=Bcy,1=Vcy,1=Gcy,1=Dcy,1=IEcy,1=ZHcy,1=Zcy,1=Icy,1=Jcy,1=Kcy,1=Lcy,1=Mcy,1=Ncy,1=Ocy,1=Pcy,1=Rcy,1=Scy
|
|
56
|
+
1=Tcy,1=Ucy,1=Fcy,1=KHcy,1=TScy,1=CHcy,1=SHcy,1=SHCHcy,1=HARDcy,1=Ycy,1=SOFTcy,1=Ecy,1=YUcy,1=YAcy,1=acy,1=bcy,1=vcy
|
|
57
|
+
1=gcy,1=dcy,1=iecy,1=zhcy,1=zcy,1=icy,1=jcy,1=kcy,1=lcy,1=mcy,1=ncy,1=ocy,1=pcy,1=rcy,1=scy,1=tcy,1=ucy,1=fcy,1=khcy
|
|
58
|
+
1=tscy,1=chcy,1=shcy,1=shchcy,1=hardcy,1=ycy,1=softcy,1=ecy,1=yucy,1=yacy,2=iocy,1=djcy,1=gjcy,1=jukcy,1=dscy
|
|
59
|
+
1=iukcy,1=yicy,1=jsercy,1=ljcy,1=njcy,1=tshcy,1=kjcy,2=ubrcy,1=dzcy,5gj=ensp,1=emsp,1=emsp13,1=emsp14,2=numsp
|
|
60
|
+
1=puncsp,1=ThinSpace thinsp,1=VeryThinSpace hairsp
|
|
61
|
+
1=NegativeMediumSpace NegativeThickSpace NegativeThinSpace NegativeVeryThinSpace ZeroWidthSpace,1=zwnj,1=zwj,1=lrm
|
|
62
|
+
1=rlm,1=dash hyphen,3=ndash,1=mdash,1=horbar,1=Verbar Vert,2=OpenCurlyQuote lsquo,1=CloseCurlyQuote rsquo rsquor
|
|
63
|
+
1=lsquor sbquo,2=OpenCurlyDoubleQuote ldquo,1=CloseCurlyDoubleQuote rdquo rdquor,1=bdquo ldquor,2=dagger
|
|
64
|
+
1=Dagger ddagger,1=bull bullet,3=nldr,1=hellip mldr,a=permil,1=pertenk,1=prime,1=Prime,1=tprime,1=backprime bprime
|
|
65
|
+
4=lsaquo,1=rsaquo,4=OverBar oline,3=caret,2=hybull,1=frasl,b=bsemi,8=qprime,8=MediumSpace,0+6bu=ThickSpace,1=NoBreak
|
|
66
|
+
1=ApplyFunction af,1=InvisibleTimes it,1=InvisibleComma ic,21=euro,1b=TripleDot tdot,1=DotDot,12=Copf complexes
|
|
67
|
+
3=incare,5=gscr,1=HilbertSpace Hscr hamilt,1=Hfr Poincareplane,1=Hopf quaternions,1=planckh
|
|
68
|
+
1=hbar hslash planck plankv,1=Iscr imagline,1=Ifr Im image imagpart,1=Laplacetrf Lscr lagran,1=ell,2=Nopf naturals
|
|
69
|
+
1=numero,1=copysr,1=weierp wp,1=Popf primes,1=Qopf rationals,1=Rscr realine,1=Re Rfr real realpart,1=Ropf reals,1=rx
|
|
70
|
+
4=TRADE trade,2=Zopf integers,3=mho,1=Zfr zeetrf,1=iiota,3=Bernoullis Bscr bernou,1=Cayleys Cfr,2=escr
|
|
71
|
+
1=Escr expectation,1=Fouriertrf Fscr,2=Mellintrf Mscr phmmat,1=order orderof oscr,1=alefsym aleph,1=beth,1=gimel
|
|
72
|
+
1=daleth,d=CapitalDifferentialD DD,1=DifferentialD dd,1=ExponentialE ee exponentiale,1=ImaginaryI ii,b=frac13
|
|
73
|
+
1=frac23,1=frac15,1=frac25,1=frac35,1=frac45,1=frac16,1=frac56,1=frac18,1=frac38,1=frac58,1=frac78
|
|
74
|
+
1e=LeftArrow ShortLeftArrow larr leftarrow slarr,1=ShortUpArrow UpArrow uarr uparrow
|
|
75
|
+
1=RightArrow ShortRightArrow rarr rightarrow srarr,1=DownArrow ShortDownArrow darr downarrow
|
|
76
|
+
1=LeftRightArrow harr leftrightarrow,1=UpDownArrow updownarrow varr,1=UpperLeftArrow nwarr nwarrow
|
|
77
|
+
1=UpperRightArrow nearr nearrow,1=LowerRightArrow searr searrow,1=LowerLeftArrow swarr swarrow,1=nlarr nleftarrow
|
|
78
|
+
1=nrarr nrightarrow,2=rarrw rightsquigarrow,0+mw=nrarrw,1=Larr twoheadleftarrow,1=Uarr,1=Rarr twoheadrightarrow
|
|
79
|
+
1=Darr,1=larrtl leftarrowtail,1=rarrtl rightarrowtail,1=LeftTeeArrow mapstoleft,1=UpTeeArrow mapstoup
|
|
80
|
+
1=RightTeeArrow map mapsto,1=DownTeeArrow mapstodown,2=hookleftarrow larrhk,1=hookrightarrow rarrhk
|
|
81
|
+
1=larrlp looparrowleft,1=looparrowright rarrlp,1=harrw leftrightsquigarrow,1=nharr nleftrightarrow,2=Lsh lsh
|
|
82
|
+
1=Rsh rsh,1=ldsh,1=rdsh,2=crarr,1=cularr curvearrowleft,1=curarr curvearrowright,3=circlearrowleft olarr
|
|
83
|
+
1=circlearrowright orarr,1=LeftVector leftharpoonup lharu,1=DownLeftVector leftharpoondown lhard
|
|
84
|
+
1=RightUpVector uharr upharpoonright,1=LeftUpVector uharl upharpoonleft,1=RightVector rharu rightharpoonup
|
|
85
|
+
1=DownRightVector rhard rightharpoondown,1=RightDownVector dharr downharpoonright
|
|
86
|
+
1=LeftDownVector dharl downharpoonleft,1=RightArrowLeftArrow rightleftarrows rlarr,1=UpArrowDownArrow udarr
|
|
87
|
+
1=LeftArrowRightArrow leftrightarrows lrarr,1=leftleftarrows llarr,1=upuparrows uuarr,1=rightrightarrows rrarr
|
|
88
|
+
1=ddarr downdownarrows,1=ReverseEquilibrium leftrightharpoons lrhar,1=Equilibrium rightleftharpoons rlhar
|
|
89
|
+
1=nLeftarrow nlArr,1=nLeftrightarrow nhArr,1=nRightarrow nrArr,1=DoubleLeftArrow Leftarrow lArr
|
|
90
|
+
1=DoubleUpArrow Uparrow uArr,1=DoubleRightArrow Implies Rightarrow rArr,1=DoubleDownArrow Downarrow dArr
|
|
91
|
+
1=DoubleLeftRightArrow Leftrightarrow hArr iff,1=DoubleUpDownArrow Updownarrow vArr,1=nwArr,1=neArr,1=seArr,1=swArr
|
|
92
|
+
1=Lleftarrow lAarr,1=Rrightarrow rAarr,2=zigrarr,7=LeftArrowBar larrb,1=RightArrowBar rarrb,g=DownArrowUpArrow duarr
|
|
93
|
+
8=loarr,1=roarr,1=hoarr,1=ForAll forall,1=comp complement,1=PartialD part,0+mw=npart,1=Exists exist
|
|
94
|
+
1=NotExists nexist nexists,1=empty emptyset emptyv varnothing,2=Del nabla,1=Element in isin isinv
|
|
95
|
+
1=NotElement notin notinva,2=ReverseElement SuchThat ni niv,1=NotReverseElement notni notniva,3=Product prod
|
|
96
|
+
1=Coproduct coprod,1=Sum sum,1=minus,1=MinusPlus mnplus mp,1=dotplus plusdo
|
|
97
|
+
2=Backslash setminus setmn smallsetminus ssetmn,1=lowast,1=SmallCircle compfn,2=Sqrt radic
|
|
98
|
+
3=Proportional prop propto varpropto vprop,1=infin,1=angrt,1=ang angle,0+6he=nang,1=angmsd measuredangle,1=angsph
|
|
99
|
+
1=VerticalBar mid shortmid smid,1=NotVerticalBar nmid nshortmid nsmid
|
|
100
|
+
1=DoubleVerticalBar par parallel shortparallel spar,1=NotDoubleVerticalBar npar nparallel nshortparallel nspar
|
|
101
|
+
1=and wedge,1=or vee,1=cap,0+1e68=caps,1=cup,0+1e68=cups,1=Integral int,1=Int,1=iiint tint
|
|
102
|
+
1=ContourIntegral conint oint,1=Conint DoubleContourIntegral,1=Cconint,1=cwint,1=ClockwiseContourIntegral cwconint
|
|
103
|
+
1=CounterClockwiseContourIntegral awconint,1=Therefore there4 therefore,1=Because becaus because,1=ratio
|
|
104
|
+
1=Colon Proportion,1=dotminus minusd,2=mDDot,1=homtht,1=Tilde sim thicksim thksim,0+6he=nvsim,1=backsim bsim
|
|
105
|
+
0+mp=race,1=ac mstpos,0+mr=acE,1=acd,1=VerticalTilde wr wreath,1=NotTilde nsim,1=EqualTilde eqsim esim
|
|
106
|
+
0+mw=NotEqualTilde nesim,1=TildeEqual sime simeq,1=NotTildeEqual nsime nsimeq,1=TildeFullEqual cong,1=simne
|
|
107
|
+
1=NotTildeFullEqual ncong,1=TildeTilde ap approx asymp thickapprox thkap,1=NotTildeTilde nap napprox,1=ape approxeq
|
|
108
|
+
1=apid,0+mw=napid,1=backcong bcong,1=CupCap asympeq,0+6he=nvap,1=Bumpeq HumpDownHump bump,0+mw=NotHumpDownHump nbump
|
|
109
|
+
1=HumpEqual bumpe bumpeq,0+mw=NotHumpEqual nbumpe,1=DotEqual doteq esdot,0+mw=nedot,1=doteqdot eDot
|
|
110
|
+
1=efDot fallingdotseq,1=erDot risingdotseq,1=Assign colone coloneq,1=ecolon eqcolon,1=ecir eqcirc,1=circeq cire
|
|
111
|
+
2=wedgeq,1=veeeq,2=triangleq trie,3=equest questeq,1=NotEqual ne,1=Congruent equiv,0+6hx=bnequiv
|
|
112
|
+
1=NotCongruent nequiv,2=le leq,0+6he=nvle,1=GreaterEqual ge geq,0+6he=nvge,1=LessFullEqual lE leqq,0+mw=nlE nleqq
|
|
113
|
+
1=GreaterFullEqual gE geqq,0+mw=NotGreaterFullEqual ngE ngeqq,1=lnE lneqq,0+1e68=lvertneqq lvnE,1=gnE gneqq
|
|
114
|
+
0+1e68=gvertneqq gvnE,1=Lt NestedLessLess ll,0+mw=NotLessLess nLtv,0+6he=nLt,1=Gt NestedGreaterGreater gg
|
|
115
|
+
0+mw=NotGreaterGreater nGtv,0+6he=nGt,1=between twixt,1=NotCupCap,1=NotLess nless nlt,1=NotGreater ngt ngtr
|
|
116
|
+
1=NotLessEqual nle nleq,1=NotGreaterEqual nge ngeq,1=LessTilde lesssim lsim,1=GreaterTilde gsim gtrsim
|
|
117
|
+
1=NotLessTilde nlsim,1=NotGreaterTilde ngsim,1=LessGreater lessgtr lg,1=GreaterLess gl gtrless,1=NotLessGreater ntlg
|
|
118
|
+
1=NotGreaterLess ntgl,1=Precedes pr prec,1=Succeeds sc succ,1=PrecedesSlantEqual prcue preccurlyeq
|
|
119
|
+
1=SucceedsSlantEqual sccue succcurlyeq,1=PrecedesTilde precsim prsim,1=SucceedsTilde scsim succsim
|
|
120
|
+
0+mw=NotSucceedsTilde,1=NotPrecedes npr nprec,1=NotSucceeds nsc nsucc,1=sub subset,0+6he=NotSubset nsubset vnsub
|
|
121
|
+
1=Superset sup supset,0+6he=NotSuperset nsupset vnsup,1=nsub,1=nsup,1=SubsetEqual sube subseteq
|
|
122
|
+
1=SupersetEqual supe supseteq,1=NotSubsetEqual nsube nsubseteq,1=NotSupersetEqual nsupe nsupseteq,1=subne subsetneq
|
|
123
|
+
0+1e68=varsubsetneq vsubne,1=supne supsetneq,0+1e68=varsupsetneq vsupne,2=cupdot,1=UnionPlus uplus
|
|
124
|
+
1=SquareSubset sqsub sqsubset,0+mw=NotSquareSubset,1=SquareSuperset sqsup sqsupset,0+mw=NotSquareSuperset
|
|
125
|
+
1=SquareSubsetEqual sqsube sqsubseteq,1=SquareSupersetEqual sqsupe sqsupseteq,1=SquareIntersection sqcap
|
|
126
|
+
0+1e68=sqcaps,1=SquareUnion sqcup,0+1e68=sqcups,1=CirclePlus oplus,1=CircleMinus ominus,1=CircleTimes otimes,1=osol
|
|
127
|
+
1=CircleDot odot,1=circledcirc ocir,1=circledast oast,2=circleddash odash,1=boxplus plusb,1=boxminus minusb
|
|
128
|
+
1=boxtimes timesb,1=dotsquare sdotb,1=RightTee vdash,1=LeftTee dashv,1=DownTee top,1=UpTee bot bottom perp,2=models
|
|
129
|
+
1=DoubleRightTee vDash,1=Vdash,1=Vvdash,1=VDash,1=nvdash,1=nvDash,1=nVdash,1=nVDash,1=prurel
|
|
130
|
+
2=LeftTriangle vartriangleleft vltri,1=RightTriangle vartriangleright vrtri,1=LeftTriangleEqual ltrie trianglelefteq
|
|
131
|
+
0+6he=nvltrie,1=RightTriangleEqual rtrie trianglerighteq,0+6he=nvrtrie,1=origof,1=imof,1=multimap mumap,1=hercon
|
|
132
|
+
1=intcal intercal,1=veebar,2=barvee,1=angrtvb,1=lrtri,1=Wedge bigwedge xwedge,1=Vee bigvee xvee
|
|
133
|
+
1=Intersection bigcap xcap,1=Union bigcup xcup,1=Diamond diam diamond,1=sdot,1=Star sstarf,1=divideontimes divonx
|
|
134
|
+
1=bowtie,1=ltimes,1=rtimes,1=leftthreetimes lthree,1=rightthreetimes rthree,1=backsimeq bsime,1=curlyvee cuvee
|
|
135
|
+
1=curlywedge cuwed,1=Sub Subset,1=Sup Supset,1=Cap,1=Cup,1=fork pitchfork,1=epar,1=lessdot ltdot,1=gtdot gtrdot,1=Ll
|
|
136
|
+
0+mw=nLl,1=Gg ggg,0+mw=nGg,1=LessEqualGreater leg lesseqgtr,0+1e68=lesg,1=GreaterEqualLess gel gtreqless,0+1e68=gesl
|
|
137
|
+
3=cuepr curlyeqprec,1=cuesc curlyeqsucc,1=NotPrecedesSlantEqual nprcue,1=NotSucceedsSlantEqual nsccue
|
|
138
|
+
1=NotSquareSubsetEqual nsqsube,1=NotSquareSupersetEqual nsqsupe,3=lnsim,1=gnsim,1=precnsim prnsim,1=scnsim succnsim
|
|
139
|
+
1=NotLeftTriangle nltri ntriangleleft,1=NotRightTriangle nrtri ntriangleright
|
|
140
|
+
1=NotLeftTriangleEqual nltrie ntrianglelefteq,1=NotRightTriangleEqual nrtrie ntrianglerighteq,1=vellip,1=ctdot
|
|
141
|
+
1=utdot,1=dtdot,1=disin,1=isinsv,1=isins,1=isindot,0+mw=notindot,1=notinvc,1=notinvb,2=isinE,0+mw=notinE,1=nisd
|
|
142
|
+
1=xnis,1=nis,1=notnivc,1=notnivb,7=barwed barwedge,1=Barwed doublebarwedge,2=LeftCeiling lceil,1=RightCeiling rceil
|
|
143
|
+
1=LeftFloor lfloor,1=RightFloor rfloor,1=drcrop,1=dlcrop,1=urcrop,1=ulcrop,1=bnot,2=profline,1=profsurf,2=telrec
|
|
144
|
+
1=target,6=ulcorn ulcorner,1=urcorn urcorner,1=dlcorn llcorner,1=drcorn lrcorner,3=frown sfrown,1=smile ssmile
|
|
145
|
+
a=cylcty,1=profalar,8=topbot,7=ovbar,2=solbar,1p=angzarr,1g=lmoust lmoustache,1=rmoust rmoustache,3=OverBracket tbrk
|
|
146
|
+
1=UnderBracket bbrk,1=bbrktbrk,12=OverParenthesis,1=UnderParenthesis,1=OverBrace,1=UnderBrace,3=trpezium,5=elinters
|
|
147
|
+
1o=blank,4l=circledS oS,1k=HorizontalLine boxh,2=boxv,a=boxdr,4=boxdl,4=boxur,4=boxul,4=boxvr,8=boxvl,8=boxhd
|
|
148
|
+
8=boxhu,8=boxvh,k=boxH,1=boxV,1=boxdR,1=boxDr,1=boxDR,1=boxdL,1=boxDl,1=boxDL,1=boxuR,1=boxUr,1=boxUR,1=boxuL
|
|
149
|
+
1=boxUl,1=boxUL,1=boxvR,1=boxVr,1=boxVR,1=boxvL,1=boxVl,1=boxVL,1=boxHd,1=boxhD,1=boxHD,1=boxHu,1=boxhU,1=boxHU
|
|
150
|
+
1=boxvH,1=boxVh,1=boxVH,k=uhblk,4=lhblk,4=block,9=blk14,1=blk12,1=blk34,e=Square squ square
|
|
151
|
+
9=FilledVerySmallSquare blacksquare squarf squf,1=EmptyVerySmallSquare,2=rect,1=marker,3=fltns,2=bigtriangleup xutri
|
|
152
|
+
1=blacktriangle utrif,1=triangle utri,3=blacktriangleright rtrif,1=rtri triangleright,4=bigtriangledown xdtri
|
|
153
|
+
1=blacktriangledown dtrif,1=dtri triangledown,3=blacktriangleleft ltrif,1=ltri triangleleft,7=loz lozenge,1=cir
|
|
154
|
+
x=tridot,3=bigcirc xcirc,9=ultri,1=urtri,1=lltri,1=EmptySmallSquare,1=FilledSmallSquare,9=bigstar starf,1=star
|
|
155
|
+
8=phone,1e=female,2=male,u=spades spadesuit,3=clubs clubsuit,2=hearts heartsuit,1=diamondsuit diams,4=sung,3=flat
|
|
156
|
+
1=natur natural,1=sharp,4k=check checkmark,4=cross,9=malt maltese,m=sext,y=VerticalSeparator,q=lbbrk,1=rbbrk
|
|
157
|
+
2d=bsolhsub,1=suphsol,t=LeftDoubleBracket lobrk,1=RightDoubleBracket robrk,1=LeftAngleBracket lang langle
|
|
158
|
+
1=RightAngleBracket rang rangle,1=Lang,1=Rang,1=loang,1=roang,8=LongLeftArrow longleftarrow xlarr
|
|
159
|
+
1=LongRightArrow longrightarrow xrarr,1=LongLeftRightArrow longleftrightarrow xharr
|
|
160
|
+
1=DoubleLongLeftArrow Longleftarrow xlArr,1=DoubleLongRightArrow Longrightarrow xrArr
|
|
161
|
+
1=DoubleLongLeftRightArrow Longleftrightarrow xhArr,2=longmapsto xmap,3=dzigrarr,77=nvlArr,1=nvrArr,1=nvHarr,1=Map
|
|
162
|
+
7=lbarr,1=bkarow rbarr,1=lBarr,1=dbkarow rBarr,1=RBarr drbkarow,1=DDotrahd,1=UpArrowBar,1=DownArrowBar,3=Rarrtl
|
|
163
|
+
3=latail,1=ratail,1=lAtail,1=rAtail,1=larrfs,1=rarrfs,1=larrbfs,1=rarrbfs,3=nwarhk,1=nearhk,1=hksearow searhk
|
|
164
|
+
1=hkswarow swarhk,1=nwnear,1=nesear toea,1=seswar tosa,1=swnwar,9=rarrc,0+mw=nrarrc,2=cudarrr,1=ldca,1=rdca
|
|
165
|
+
1=cudarrl,1=larrpl,3=curarrm,1=cularrp,8=rarrpl,3=harrcir,1=Uarrocir,1=lurdshar,1=ldrushar,3=LeftRightVector
|
|
166
|
+
1=RightUpDownVector,1=DownLeftRightVector,1=LeftUpDownVector,1=LeftVectorBar,1=RightVectorBar,1=RightUpVectorBar
|
|
167
|
+
1=RightDownVectorBar,1=DownLeftVectorBar,1=DownRightVectorBar,1=LeftUpVectorBar,1=LeftDownVectorBar,1=LeftTeeVector
|
|
168
|
+
1=RightTeeVector,1=RightUpTeeVector,1=RightDownTeeVector,1=DownLeftTeeVector,1=DownRightTeeVector,1=LeftUpTeeVector
|
|
169
|
+
1=LeftDownTeeVector,1=lHar,1=uHar,1=rHar,1=dHar,1=luruhar,1=ldrdhar,1=ruluhar,1=rdldhar,1=lharul,1=llhard,1=rharul
|
|
170
|
+
1=lrhard,1=UpEquilibrium udhar,1=ReverseUpEquilibrium duhar,1=RoundImplies,1=erarr,1=simrarr,1=larrsim,1=rarrsim
|
|
171
|
+
1=rarrap,1=ltlarr,2=gtrarr,1=subrarr,2=suplarr,1=lfisht,1=rfisht,1=ufisht,1=dfisht,6=lopar,1=ropar,5=lbrke,1=rbrke
|
|
172
|
+
1=lbrkslu,1=rbrksld,1=lbrksld,1=rbrkslu,1=langd,1=rangd,1=lparlt,1=rpargt,1=gtlPar,1=ltrPar,4=vzigzag,2=vangrt
|
|
173
|
+
1=angrtvbd,7=ange,1=range,1=dwangle,1=uwangle,1=angmsdaa,1=angmsdab,1=angmsdac,1=angmsdad,1=angmsdae,1=angmsdaf
|
|
174
|
+
1=angmsdag,1=angmsdah,1=bemptyv,1=demptyv,1=cemptyv,1=raemptyv,1=laemptyv,1=ohbar,1=omid,1=opar,2=operp,2=olcross
|
|
175
|
+
1=odsold,2=olcir,1=ofcir,1=olt,1=ogt,1=cirscir,1=cirE,1=solb,1=bsolb,4=boxbox,4=trisb,1=rtriltri,1=LeftTriangleBar
|
|
176
|
+
0+mw=NotLeftTriangleBar,1=RightTriangleBar,0+mw=NotRightTriangleBar,c=iinfin,1=infintie,1=nvinfin,5=eparsl
|
|
177
|
+
1=smeparsl,1=eqvparsl,6=blacklozenge lozf,9=RuleDelayed,2=dsol,a=bigodot xodot,1=bigoplus xoplus,1=bigotimes xotime
|
|
178
|
+
2=biguplus xuplus,2=bigsqcup xsqcup,6=iiiint qint,1=fpartint,3=cirfnint,1=awint,1=rppolint,1=scpolint,1=npolint
|
|
179
|
+
1=pointint,1=quatint,1=intlarhk,b=pluscir,1=plusacir,1=simplus,1=plusdu,1=plussim,1=plustwo,2=mcomma,1=minusdu
|
|
180
|
+
3=loplus,1=roplus,1=Cross,1=timesd,1=timesbar,2=smashp,1=lotimes,1=rotimes,1=otimesas,1=Otimes,1=odiv,1=triplus
|
|
181
|
+
1=triminus,1=tritime,1=intprod iprod,3=amalg,1=capdot,2=ncup,1=ncap,1=capand,1=cupor,1=cupcap,1=capcup,1=cupbrcap
|
|
182
|
+
1=capbrcup,1=cupcup,1=capcap,1=ccups,1=ccaps,3=ccupssm,3=And,1=Or,1=andand,1=oror,1=orslope,1=andslope,2=andv,1=orv
|
|
183
|
+
1=andd,1=ord,2=wedbar,7=sdote,4=simdot,3=congdot,0+mw=ncongdot,1=easter,1=apacir,1=apE,0+mw=napE,1=eplus,1=pluse
|
|
184
|
+
1=Esim,1=Colone,1=Equal,2=ddotseq eDDot,1=equivDD,1=ltcir,1=gtcir,1=ltquest,1=gtquest,1=LessSlantEqual leqslant les
|
|
185
|
+
0+mw=NotLessSlantEqual nleqslant nles,1=GreaterSlantEqual geqslant ges,0+mw=NotGreaterSlantEqual ngeqslant nges
|
|
186
|
+
1=lesdot,1=gesdot,1=lesdoto,1=gesdoto,1=lesdotor,1=gesdotol,1=lap lessapprox,1=gap gtrapprox,1=lne lneq,1=gne gneq
|
|
187
|
+
1=lnap lnapprox,1=gnap gnapprox,1=lEg lesseqqgtr,1=gEl gtreqqless,1=lsime,1=gsime,1=lsimg,1=gsiml,1=lgE,1=glE
|
|
188
|
+
1=lesges,1=gesles,1=els eqslantless,1=egs eqslantgtr,1=elsdot,1=egsdot,1=el,1=eg,3=siml,1=simg,1=simlE,1=simgE
|
|
189
|
+
1=LessLess,0+mw=NotNestedLessLess,1=GreaterGreater,0+mw=NotNestedGreaterGreater,2=glj,1=gla,1=ltcc,1=gtcc,1=lescc
|
|
190
|
+
1=gescc,1=smt,1=lat,1=smte,0+1e68=smtes,1=late,0+1e68=lates,1=bumpE,1=PrecedesEqual pre preceq
|
|
191
|
+
0+mw=NotPrecedesEqual npre npreceq,1=SucceedsEqual sce succeq,0+mw=NotSucceedsEqual nsce nsucceq,3=prE,1=scE
|
|
192
|
+
1=precneqq prnE,1=scnE succneqq,1=prap precapprox,1=scap succapprox,1=precnapprox prnap,1=scnap succnapprox,1=Pr
|
|
193
|
+
1=Sc,1=subdot,1=supdot,1=subplus,1=supplus,1=submult,1=supmult,1=subedot,1=supedot,1=subE subseteqq
|
|
194
|
+
0+mw=nsubE nsubseteqq,1=supE supseteqq,0+mw=nsupE nsupseteqq,1=subsim,1=supsim,3=subnE subsetneqq
|
|
195
|
+
0+1e68=varsubsetneqq vsubnE,1=supnE supsetneqq,0+1e68=varsupsetneqq vsupnE,3=csub,1=csup,1=csube,1=csupe,1=subsup
|
|
196
|
+
1=supsub,1=subsub,1=supsup,1=suphsub,1=supdsub,1=forkv,1=topfork,1=mlcp,9=Dashv DoubleLeftTee,2=Vdashl,1=Barv,1=vBar
|
|
197
|
+
1=vBarv,2=Vbar,1=Not,1=bNot,1=rnmid,1=cirmid,1=midcir,1=topcir,1=nhpar,1=parsim,a=parsl,0+6hx=nparsl,1537=fflig
|
|
198
|
+
1=filig,1=fllig,1=ffilig,1=ffllig,16zc=Ascr,2=Cscr,1=Dscr,3=Gscr,3=Jscr,1=Kscr,3=Nscr,1=Oscr,1=Pscr,1=Qscr,2=Sscr
|
|
199
|
+
1=Tscr,1=Uscr,1=Vscr,1=Wscr,1=Xscr,1=Yscr,1=Zscr,1=ascr,1=bscr,1=cscr,1=dscr,2=fscr,2=hscr,1=iscr,1=jscr,1=kscr
|
|
200
|
+
1=lscr,1=mscr,1=nscr,2=pscr,1=qscr,1=rscr,1=sscr,1=tscr,1=uscr,1=vscr,1=wscr,1=xscr,1=yscr,1=zscr,1h=Afr,1=Bfr,2=Dfr
|
|
201
|
+
1=Efr,1=Ffr,1=Gfr,3=Jfr,1=Kfr,1=Lfr,1=Mfr,1=Nfr,1=Ofr,1=Pfr,1=Qfr,2=Sfr,1=Tfr,1=Ufr,1=Vfr,1=Wfr,1=Xfr,1=Yfr,2=afr
|
|
202
|
+
1=bfr,1=cfr,1=dfr,1=efr,1=ffr,1=gfr,1=hfr,1=ifr,1=jfr,1=kfr,1=lfr,1=mfr,1=nfr,1=ofr,1=pfr,1=qfr,1=rfr,1=sfr,1=tfr
|
|
203
|
+
1=ufr,1=vfr,1=wfr,1=xfr,1=yfr,1=zfr,1=Aopf,1=Bopf,2=Dopf,1=Eopf,1=Fopf,1=Gopf,2=Iopf,1=Jopf,1=Kopf,1=Lopf,1=Mopf
|
|
204
|
+
2=Oopf,4=Sopf,1=Topf,1=Uopf,1=Vopf,1=Wopf,1=Xopf,1=Yopf,2=aopf,1=bopf,1=copf,1=dopf,1=eopf,1=fopf,1=gopf,1=hopf
|
|
205
|
+
1=iopf,1=jopf,1=kopf,1=lopf,1=mopf,1=nopf,1=oopf,1=popf,1=qopf,1=ropf,1=sopf,1=topf,1=uopf,1=vopf,1=wopf,1=xopf
|
|
206
|
+
1=yopf,1=zopf`;
|
|
207
|
+
// src/references.ts
|
|
208
|
+
/**
|
|
209
|
+
* This module decodes the character references of HTML content, with no DOM. The table of the named references has
|
|
210
|
+
* 2231 names. It is in a separate entry, so a bundle that only scans HTML does not get the table.
|
|
211
|
+
*/
|
|
212
|
+
/**
|
|
213
|
+
* The values of the code points 0x80 to 0x9F in a numeric character reference, from the table of the standard. They are
|
|
214
|
+
* the characters of windows-1252. The five code points that windows-1252 does not have stay as they are.
|
|
215
|
+
*/
|
|
216
|
+
const C1_VALUES = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ";
|
|
217
|
+
/** The value of each named character reference. A name with `;` is a key, and a legacy name is also a key with no `;`. */
|
|
218
|
+
let named;
|
|
219
|
+
/** The length of the longest name, with no `;`. */
|
|
220
|
+
let longestName = 0;
|
|
221
|
+
/** The length of the longest legacy name. */
|
|
222
|
+
let longestLegacy = 0;
|
|
223
|
+
/** This function reads the table of the named character references one time, when the decoder first needs it. */
|
|
224
|
+
function namedReferences() {
|
|
225
|
+
if (named !== void 0) return named;
|
|
226
|
+
const table = /* @__PURE__ */ new Map();
|
|
227
|
+
let point = 0;
|
|
228
|
+
for (const group of NAMED_REFERENCES.split(/[,\n]/)) {
|
|
229
|
+
const equals = group.indexOf("=");
|
|
230
|
+
const [first = "", second] = group.slice(0, equals).split("+");
|
|
231
|
+
point += parseInt(first, 36);
|
|
232
|
+
const value = second === void 0 ? String.fromCodePoint(point) : String.fromCodePoint(point, parseInt(second, 36));
|
|
233
|
+
for (const entry of group.slice(equals + 1).split(" ")) {
|
|
234
|
+
const legacy = entry.endsWith("*");
|
|
235
|
+
const name = legacy ? entry.slice(0, -1) : entry;
|
|
236
|
+
table.set(`${name};`, value);
|
|
237
|
+
longestName = Math.max(longestName, name.length);
|
|
238
|
+
if (legacy) {
|
|
239
|
+
table.set(name, value);
|
|
240
|
+
longestLegacy = Math.max(longestLegacy, name.length);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
named = table;
|
|
245
|
+
return table;
|
|
246
|
+
}
|
|
247
|
+
/** This function tells if a code unit is an ASCII letter or an ASCII digit. */
|
|
248
|
+
const isAlphanumeric = (code) => code >= 48 && code <= 57 || (code | 32) >= 97 && (code | 32) <= 122;
|
|
249
|
+
/** This function gives the value of a code unit as a decimal or a hexadecimal digit, or -1 for a different code unit. */
|
|
250
|
+
function digitOf(code, hex) {
|
|
251
|
+
if (code >= 48 && code <= 57) return code - 48;
|
|
252
|
+
const lower = code | 32;
|
|
253
|
+
return hex && lower >= 97 && lower <= 102 ? lower - 97 + 10 : -1;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* This function reads the numeric character reference at the "&" at `amp`, with the fixes of the standard. It gives
|
|
257
|
+
* undefined when no digit follows "&#" or "&#x".
|
|
258
|
+
*/
|
|
259
|
+
function readNumeric(text, amp) {
|
|
260
|
+
let at = amp + 2;
|
|
261
|
+
const hex = (text.charCodeAt(at) | 32) === 120;
|
|
262
|
+
if (hex) at += 1;
|
|
263
|
+
const start = at;
|
|
264
|
+
let point = 0;
|
|
265
|
+
for (let digit = digitOf(text.charCodeAt(at), hex); digit !== -1; digit = digitOf(text.charCodeAt(at), hex)) {
|
|
266
|
+
point = Math.min(point * (hex ? 16 : 10) + digit, 1114112);
|
|
267
|
+
at += 1;
|
|
268
|
+
}
|
|
269
|
+
if (at === start) return void 0;
|
|
270
|
+
if (text.charCodeAt(at) === 59) at += 1;
|
|
271
|
+
if (point === 0 || point > 1114111 || point >= 55296 && point <= 57343) return {
|
|
272
|
+
value: "�",
|
|
273
|
+
end: at
|
|
274
|
+
};
|
|
275
|
+
if (point >= 128 && point <= 159) return {
|
|
276
|
+
value: C1_VALUES.charAt(point - 128),
|
|
277
|
+
end: at
|
|
278
|
+
};
|
|
279
|
+
return {
|
|
280
|
+
value: String.fromCodePoint(point),
|
|
281
|
+
end: at
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* This function reads the named character reference at the "&" at `amp`. The longest name wins. It gives undefined when
|
|
286
|
+
* no name of the table follows the "&".
|
|
287
|
+
*/
|
|
288
|
+
function readNamed(text, amp) {
|
|
289
|
+
const from = amp + 1;
|
|
290
|
+
if (!isAlphanumeric(text.charCodeAt(from))) return void 0;
|
|
291
|
+
const table = namedReferences();
|
|
292
|
+
let at = from;
|
|
293
|
+
while (at - from <= longestName && isAlphanumeric(text.charCodeAt(at))) at += 1;
|
|
294
|
+
if (text.charCodeAt(at) === 59) {
|
|
295
|
+
const value = table.get(text.slice(from, at + 1));
|
|
296
|
+
if (value !== void 0) return {
|
|
297
|
+
value,
|
|
298
|
+
end: at + 1
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
for (let end = Math.min(at, from + longestLegacy); end > from; end -= 1) {
|
|
302
|
+
const value = table.get(text.slice(from, end));
|
|
303
|
+
if (value !== void 0) return {
|
|
304
|
+
value,
|
|
305
|
+
end
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* This function decodes the character references of a text, as the tokenizer of the HTML Living Standard does in the
|
|
311
|
+
* content of an element. Use it on the `text` of a scan of `scanHtml`.
|
|
312
|
+
*
|
|
313
|
+
* - A named reference gets its value from the table of the standard. The longest name wins.
|
|
314
|
+
* - A legacy name, for example `&` or `¬`, is also correct with no semicolon. Thus `¬it;` gives `¬it;`.
|
|
315
|
+
* - A decimal or hexadecimal reference, for example `’` or `’`, gives its code point. The semicolon is optional.
|
|
316
|
+
* - The value 0, a surrogate and a value above `0x10FFFF` give U+FFFD.
|
|
317
|
+
* - The values `0x80` to `0x9F` give the characters of windows-1252, from the table of the standard.
|
|
318
|
+
* - An ampersand with no reference after it stays as text. The function changes no other character.
|
|
319
|
+
*
|
|
320
|
+
* The function does not throw, and it is linear in the length of the text. The result is not longer than the text.
|
|
321
|
+
*
|
|
322
|
+
* @param text - The text of HTML content, with its character references.
|
|
323
|
+
* @returns The text with the value of each character reference in place of the reference.
|
|
324
|
+
*/
|
|
325
|
+
function decodeReferences(text) {
|
|
326
|
+
let amp = text.indexOf("&");
|
|
327
|
+
if (amp === -1) return text;
|
|
328
|
+
const parts = [];
|
|
329
|
+
let at = 0;
|
|
330
|
+
while (amp !== -1) {
|
|
331
|
+
const reference = text.charCodeAt(amp + 1) === 35 ? readNumeric(text, amp) : readNamed(text, amp);
|
|
332
|
+
if (reference === void 0) amp = text.indexOf("&", amp + 1);
|
|
333
|
+
else {
|
|
334
|
+
parts.push(text.slice(at, amp), reference.value);
|
|
335
|
+
at = reference.end;
|
|
336
|
+
amp = text.indexOf("&", at);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
parts.push(text.slice(at));
|
|
340
|
+
return parts.join("");
|
|
341
|
+
}
|
|
342
|
+
export { decodeReferences };
|
|
343
|
+
|
|
344
|
+
//# sourceMappingURL=references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.js","names":[],"sources":["../src/html-references.ts","../src/references.ts"],"sourcesContent":["/**\n * This module has the named character references of HTML. The script `scripts/html-references.ts` made it. Do not\n * edit it. Start the script again to make it.\n *\n * The source is the table of the HTML Living Standard, `https://html.spec.whatwg.org/entities.json`. Copyright WHATWG\n * (Apple, Google, Mozilla, Microsoft). The table has the license CC BY 4.0,\n * `https://creativecommons.org/licenses/by/4.0/`. The SHA-256 of the source file is\n * `d741d877ac77c4194c4ad526b5b4a19aef8dfe411ab840a466891cdbb9f362e6`.\n *\n * The script changed the format of the table, not its content. The source has 2231 names. 106 of them are\n * legacy names, which are in the source with a semicolon and with no semicolon.\n */\n\n/**\n * The names and the values of the named character references. The names with one value make one group. A comma or a\n * line end comes between two groups. Each group has these parts:\n *\n * - the first code point of the value, as the difference from the first code point of the group before it,\n * - a plus sign and the second code point, only for a value with two code points,\n * - an equals sign and the names of the group, with a space between two names.\n *\n * Each number is in base 36. A name has no ampersand and no semicolon. A star after a name tells that the name is also\n * correct with no semicolon. The groups are in the order of their values. The longest name has 31 characters, and the\n * longest legacy name has 6 characters.\n */\nexport const NAMED_REFERENCES: string =\n `9=Tab,1=NewLine,n=excl,1=QUOT* quot*,1=num,1=dollar,1=percnt,1=AMP* amp*,1=apos,1=lpar,1=rpar,1=ast midast,1=plus\n1=comma,2=period,1=sol,b=colon,1=semi,1=LT* lt*,0+6he=nvlt,1=equals,0+6hx=bne,1=GT* gt*,0+6he=nvgt,1=quest,1=commat\nr=lbrack lsqb,1=bsol,1=rbrack rsqb,1=Hat,1=UnderBar lowbar,1=DiacriticalGrave grave,6+2y=fjlig,l=lbrace lcub\n1=VerticalLine verbar vert,1=rbrace rcub,z=NonBreakingSpace nbsp*,1=iexcl*,1=cent*,1=pound*,1=curren*,1=yen*\n1=brvbar*,1=sect*,1=Dot DoubleDot die uml*,1=COPY* copy*,1=ordf*,1=laquo*,1=not*,1=shy*,1=REG* circledR reg*\n1=macr* strns,1=deg*,1=PlusMinus plusmn* pm,1=sup2*,1=sup3*,1=DiacriticalAcute acute*,1=micro*,1=para*\n1=CenterDot centerdot middot*,1=Cedilla cedil*,1=sup1*,1=ordm*,1=raquo*,1=frac14*,1=frac12* half,1=frac34*,1=iquest*\n1=Agrave*,1=Aacute*,1=Acirc*,1=Atilde*,1=Auml*,1=Aring* angst,1=AElig*,1=Ccedil*,1=Egrave*,1=Eacute*,1=Ecirc*\n1=Euml*,1=Igrave*,1=Iacute*,1=Icirc*,1=Iuml*,1=ETH*,1=Ntilde*,1=Ograve*,1=Oacute*,1=Ocirc*,1=Otilde*,1=Ouml*\n1=times*,1=Oslash*,1=Ugrave*,1=Uacute*,1=Ucirc*,1=Uuml*,1=Yacute*,1=THORN*,1=szlig*,1=agrave*,1=aacute*,1=acirc*\n1=atilde*,1=auml*,1=aring*,1=aelig*,1=ccedil*,1=egrave*,1=eacute*,1=ecirc*,1=euml*,1=igrave*,1=iacute*,1=icirc*\n1=iuml*,1=eth*,1=ntilde*,1=ograve*,1=oacute*,1=ocirc*,1=otilde*,1=ouml*,1=div divide*,1=oslash*,1=ugrave*,1=uacute*\n1=ucirc*,1=uuml*,1=yacute*,1=thorn*,1=yuml*,1=Amacr,1=amacr,1=Abreve,1=abreve,1=Aogon,1=aogon,1=Cacute,1=cacute\n1=Ccirc,1=ccirc,1=Cdot,1=cdot,1=Ccaron,1=ccaron,1=Dcaron,1=dcaron,1=Dstrok,1=dstrok,1=Emacr,1=emacr,3=Edot,1=edot\n1=Eogon,1=eogon,1=Ecaron,1=ecaron,1=Gcirc,1=gcirc,1=Gbreve,1=gbreve,1=Gdot,1=gdot,1=Gcedil,2=Hcirc,1=hcirc,1=Hstrok\n1=hstrok,1=Itilde,1=itilde,1=Imacr,1=imacr,3=Iogon,1=iogon,1=Idot,1=imath inodot,1=IJlig,1=ijlig,1=Jcirc,1=jcirc\n1=Kcedil,1=kcedil,1=kgreen,1=Lacute,1=lacute,1=Lcedil,1=lcedil,1=Lcaron,1=lcaron,1=Lmidot,1=lmidot,1=Lstrok,1=lstrok\n1=Nacute,1=nacute,1=Ncedil,1=ncedil,1=Ncaron,1=ncaron,1=napos,1=ENG,1=eng,1=Omacr,1=omacr,3=Odblac,1=odblac,1=OElig\n1=oelig,1=Racute,1=racute,1=Rcedil,1=rcedil,1=Rcaron,1=rcaron,1=Sacute,1=sacute,1=Scirc,1=scirc,1=Scedil,1=scedil\n1=Scaron,1=scaron,1=Tcedil,1=tcedil,1=Tcaron,1=tcaron,1=Tstrok,1=tstrok,1=Utilde,1=utilde,1=Umacr,1=umacr,1=Ubreve\n1=ubreve,1=Uring,1=uring,1=Udblac,1=udblac,1=Uogon,1=uogon,1=Wcirc,1=wcirc,1=Ycirc,1=ycirc,1=Yuml,1=Zacute,1=zacute\n1=Zdot,1=zdot,1=Zcaron,1=zcaron,k=fnof,z=imped,1s=gacute,1u=jmath,3z=circ,1=Hacek caron,h=Breve breve\n1=DiacriticalDot dot,1=ring,1=ogon,1=DiacriticalTilde tilde,1=DiacriticalDoubleAcute dblac,1g=DownBreve,3k=Alpha\n1=Beta,1=Gamma,1=Delta,1=Epsilon,1=Zeta,1=Eta,1=Theta,1=Iota,1=Kappa,1=Lambda,1=Mu,1=Nu,1=Xi,1=Omicron,1=Pi,1=Rho\n2=Sigma,1=Tau,1=Upsilon,1=Phi,1=Chi,1=Psi,1=Omega ohm,8=alpha,1=beta,1=gamma,1=delta,1=epsi epsilon,1=zeta,1=eta\n1=theta,1=iota,1=kappa,1=lambda,1=mu,1=nu,1=xi,1=omicron,1=pi,1=rho,1=sigmaf sigmav varsigma,1=sigma,1=tau\n1=upsi upsilon,1=phi,1=chi,1=psi,1=omega,8=thetasym thetav vartheta,1=Upsi upsih,3=phiv straightphi varphi\n1=piv varpi,6=Gammad,1=digamma gammad,j=kappav varkappa,1=rhov varrho,4=epsiv straightepsilon varepsilon\n1=backepsilon bepsi,b=IOcy,1=DJcy,1=GJcy,1=Jukcy,1=DScy,1=Iukcy,1=YIcy,1=Jsercy,1=LJcy,1=NJcy,1=TSHcy,1=KJcy,2=Ubrcy\n1=DZcy,1=Acy,1=Bcy,1=Vcy,1=Gcy,1=Dcy,1=IEcy,1=ZHcy,1=Zcy,1=Icy,1=Jcy,1=Kcy,1=Lcy,1=Mcy,1=Ncy,1=Ocy,1=Pcy,1=Rcy,1=Scy\n1=Tcy,1=Ucy,1=Fcy,1=KHcy,1=TScy,1=CHcy,1=SHcy,1=SHCHcy,1=HARDcy,1=Ycy,1=SOFTcy,1=Ecy,1=YUcy,1=YAcy,1=acy,1=bcy,1=vcy\n1=gcy,1=dcy,1=iecy,1=zhcy,1=zcy,1=icy,1=jcy,1=kcy,1=lcy,1=mcy,1=ncy,1=ocy,1=pcy,1=rcy,1=scy,1=tcy,1=ucy,1=fcy,1=khcy\n1=tscy,1=chcy,1=shcy,1=shchcy,1=hardcy,1=ycy,1=softcy,1=ecy,1=yucy,1=yacy,2=iocy,1=djcy,1=gjcy,1=jukcy,1=dscy\n1=iukcy,1=yicy,1=jsercy,1=ljcy,1=njcy,1=tshcy,1=kjcy,2=ubrcy,1=dzcy,5gj=ensp,1=emsp,1=emsp13,1=emsp14,2=numsp\n1=puncsp,1=ThinSpace thinsp,1=VeryThinSpace hairsp\n1=NegativeMediumSpace NegativeThickSpace NegativeThinSpace NegativeVeryThinSpace ZeroWidthSpace,1=zwnj,1=zwj,1=lrm\n1=rlm,1=dash hyphen,3=ndash,1=mdash,1=horbar,1=Verbar Vert,2=OpenCurlyQuote lsquo,1=CloseCurlyQuote rsquo rsquor\n1=lsquor sbquo,2=OpenCurlyDoubleQuote ldquo,1=CloseCurlyDoubleQuote rdquo rdquor,1=bdquo ldquor,2=dagger\n1=Dagger ddagger,1=bull bullet,3=nldr,1=hellip mldr,a=permil,1=pertenk,1=prime,1=Prime,1=tprime,1=backprime bprime\n4=lsaquo,1=rsaquo,4=OverBar oline,3=caret,2=hybull,1=frasl,b=bsemi,8=qprime,8=MediumSpace,0+6bu=ThickSpace,1=NoBreak\n1=ApplyFunction af,1=InvisibleTimes it,1=InvisibleComma ic,21=euro,1b=TripleDot tdot,1=DotDot,12=Copf complexes\n3=incare,5=gscr,1=HilbertSpace Hscr hamilt,1=Hfr Poincareplane,1=Hopf quaternions,1=planckh\n1=hbar hslash planck plankv,1=Iscr imagline,1=Ifr Im image imagpart,1=Laplacetrf Lscr lagran,1=ell,2=Nopf naturals\n1=numero,1=copysr,1=weierp wp,1=Popf primes,1=Qopf rationals,1=Rscr realine,1=Re Rfr real realpart,1=Ropf reals,1=rx\n4=TRADE trade,2=Zopf integers,3=mho,1=Zfr zeetrf,1=iiota,3=Bernoullis Bscr bernou,1=Cayleys Cfr,2=escr\n1=Escr expectation,1=Fouriertrf Fscr,2=Mellintrf Mscr phmmat,1=order orderof oscr,1=alefsym aleph,1=beth,1=gimel\n1=daleth,d=CapitalDifferentialD DD,1=DifferentialD dd,1=ExponentialE ee exponentiale,1=ImaginaryI ii,b=frac13\n1=frac23,1=frac15,1=frac25,1=frac35,1=frac45,1=frac16,1=frac56,1=frac18,1=frac38,1=frac58,1=frac78\n1e=LeftArrow ShortLeftArrow larr leftarrow slarr,1=ShortUpArrow UpArrow uarr uparrow\n1=RightArrow ShortRightArrow rarr rightarrow srarr,1=DownArrow ShortDownArrow darr downarrow\n1=LeftRightArrow harr leftrightarrow,1=UpDownArrow updownarrow varr,1=UpperLeftArrow nwarr nwarrow\n1=UpperRightArrow nearr nearrow,1=LowerRightArrow searr searrow,1=LowerLeftArrow swarr swarrow,1=nlarr nleftarrow\n1=nrarr nrightarrow,2=rarrw rightsquigarrow,0+mw=nrarrw,1=Larr twoheadleftarrow,1=Uarr,1=Rarr twoheadrightarrow\n1=Darr,1=larrtl leftarrowtail,1=rarrtl rightarrowtail,1=LeftTeeArrow mapstoleft,1=UpTeeArrow mapstoup\n1=RightTeeArrow map mapsto,1=DownTeeArrow mapstodown,2=hookleftarrow larrhk,1=hookrightarrow rarrhk\n1=larrlp looparrowleft,1=looparrowright rarrlp,1=harrw leftrightsquigarrow,1=nharr nleftrightarrow,2=Lsh lsh\n1=Rsh rsh,1=ldsh,1=rdsh,2=crarr,1=cularr curvearrowleft,1=curarr curvearrowright,3=circlearrowleft olarr\n1=circlearrowright orarr,1=LeftVector leftharpoonup lharu,1=DownLeftVector leftharpoondown lhard\n1=RightUpVector uharr upharpoonright,1=LeftUpVector uharl upharpoonleft,1=RightVector rharu rightharpoonup\n1=DownRightVector rhard rightharpoondown,1=RightDownVector dharr downharpoonright\n1=LeftDownVector dharl downharpoonleft,1=RightArrowLeftArrow rightleftarrows rlarr,1=UpArrowDownArrow udarr\n1=LeftArrowRightArrow leftrightarrows lrarr,1=leftleftarrows llarr,1=upuparrows uuarr,1=rightrightarrows rrarr\n1=ddarr downdownarrows,1=ReverseEquilibrium leftrightharpoons lrhar,1=Equilibrium rightleftharpoons rlhar\n1=nLeftarrow nlArr,1=nLeftrightarrow nhArr,1=nRightarrow nrArr,1=DoubleLeftArrow Leftarrow lArr\n1=DoubleUpArrow Uparrow uArr,1=DoubleRightArrow Implies Rightarrow rArr,1=DoubleDownArrow Downarrow dArr\n1=DoubleLeftRightArrow Leftrightarrow hArr iff,1=DoubleUpDownArrow Updownarrow vArr,1=nwArr,1=neArr,1=seArr,1=swArr\n1=Lleftarrow lAarr,1=Rrightarrow rAarr,2=zigrarr,7=LeftArrowBar larrb,1=RightArrowBar rarrb,g=DownArrowUpArrow duarr\n8=loarr,1=roarr,1=hoarr,1=ForAll forall,1=comp complement,1=PartialD part,0+mw=npart,1=Exists exist\n1=NotExists nexist nexists,1=empty emptyset emptyv varnothing,2=Del nabla,1=Element in isin isinv\n1=NotElement notin notinva,2=ReverseElement SuchThat ni niv,1=NotReverseElement notni notniva,3=Product prod\n1=Coproduct coprod,1=Sum sum,1=minus,1=MinusPlus mnplus mp,1=dotplus plusdo\n2=Backslash setminus setmn smallsetminus ssetmn,1=lowast,1=SmallCircle compfn,2=Sqrt radic\n3=Proportional prop propto varpropto vprop,1=infin,1=angrt,1=ang angle,0+6he=nang,1=angmsd measuredangle,1=angsph\n1=VerticalBar mid shortmid smid,1=NotVerticalBar nmid nshortmid nsmid\n1=DoubleVerticalBar par parallel shortparallel spar,1=NotDoubleVerticalBar npar nparallel nshortparallel nspar\n1=and wedge,1=or vee,1=cap,0+1e68=caps,1=cup,0+1e68=cups,1=Integral int,1=Int,1=iiint tint\n1=ContourIntegral conint oint,1=Conint DoubleContourIntegral,1=Cconint,1=cwint,1=ClockwiseContourIntegral cwconint\n1=CounterClockwiseContourIntegral awconint,1=Therefore there4 therefore,1=Because becaus because,1=ratio\n1=Colon Proportion,1=dotminus minusd,2=mDDot,1=homtht,1=Tilde sim thicksim thksim,0+6he=nvsim,1=backsim bsim\n0+mp=race,1=ac mstpos,0+mr=acE,1=acd,1=VerticalTilde wr wreath,1=NotTilde nsim,1=EqualTilde eqsim esim\n0+mw=NotEqualTilde nesim,1=TildeEqual sime simeq,1=NotTildeEqual nsime nsimeq,1=TildeFullEqual cong,1=simne\n1=NotTildeFullEqual ncong,1=TildeTilde ap approx asymp thickapprox thkap,1=NotTildeTilde nap napprox,1=ape approxeq\n1=apid,0+mw=napid,1=backcong bcong,1=CupCap asympeq,0+6he=nvap,1=Bumpeq HumpDownHump bump,0+mw=NotHumpDownHump nbump\n1=HumpEqual bumpe bumpeq,0+mw=NotHumpEqual nbumpe,1=DotEqual doteq esdot,0+mw=nedot,1=doteqdot eDot\n1=efDot fallingdotseq,1=erDot risingdotseq,1=Assign colone coloneq,1=ecolon eqcolon,1=ecir eqcirc,1=circeq cire\n2=wedgeq,1=veeeq,2=triangleq trie,3=equest questeq,1=NotEqual ne,1=Congruent equiv,0+6hx=bnequiv\n1=NotCongruent nequiv,2=le leq,0+6he=nvle,1=GreaterEqual ge geq,0+6he=nvge,1=LessFullEqual lE leqq,0+mw=nlE nleqq\n1=GreaterFullEqual gE geqq,0+mw=NotGreaterFullEqual ngE ngeqq,1=lnE lneqq,0+1e68=lvertneqq lvnE,1=gnE gneqq\n0+1e68=gvertneqq gvnE,1=Lt NestedLessLess ll,0+mw=NotLessLess nLtv,0+6he=nLt,1=Gt NestedGreaterGreater gg\n0+mw=NotGreaterGreater nGtv,0+6he=nGt,1=between twixt,1=NotCupCap,1=NotLess nless nlt,1=NotGreater ngt ngtr\n1=NotLessEqual nle nleq,1=NotGreaterEqual nge ngeq,1=LessTilde lesssim lsim,1=GreaterTilde gsim gtrsim\n1=NotLessTilde nlsim,1=NotGreaterTilde ngsim,1=LessGreater lessgtr lg,1=GreaterLess gl gtrless,1=NotLessGreater ntlg\n1=NotGreaterLess ntgl,1=Precedes pr prec,1=Succeeds sc succ,1=PrecedesSlantEqual prcue preccurlyeq\n1=SucceedsSlantEqual sccue succcurlyeq,1=PrecedesTilde precsim prsim,1=SucceedsTilde scsim succsim\n0+mw=NotSucceedsTilde,1=NotPrecedes npr nprec,1=NotSucceeds nsc nsucc,1=sub subset,0+6he=NotSubset nsubset vnsub\n1=Superset sup supset,0+6he=NotSuperset nsupset vnsup,1=nsub,1=nsup,1=SubsetEqual sube subseteq\n1=SupersetEqual supe supseteq,1=NotSubsetEqual nsube nsubseteq,1=NotSupersetEqual nsupe nsupseteq,1=subne subsetneq\n0+1e68=varsubsetneq vsubne,1=supne supsetneq,0+1e68=varsupsetneq vsupne,2=cupdot,1=UnionPlus uplus\n1=SquareSubset sqsub sqsubset,0+mw=NotSquareSubset,1=SquareSuperset sqsup sqsupset,0+mw=NotSquareSuperset\n1=SquareSubsetEqual sqsube sqsubseteq,1=SquareSupersetEqual sqsupe sqsupseteq,1=SquareIntersection sqcap\n0+1e68=sqcaps,1=SquareUnion sqcup,0+1e68=sqcups,1=CirclePlus oplus,1=CircleMinus ominus,1=CircleTimes otimes,1=osol\n1=CircleDot odot,1=circledcirc ocir,1=circledast oast,2=circleddash odash,1=boxplus plusb,1=boxminus minusb\n1=boxtimes timesb,1=dotsquare sdotb,1=RightTee vdash,1=LeftTee dashv,1=DownTee top,1=UpTee bot bottom perp,2=models\n1=DoubleRightTee vDash,1=Vdash,1=Vvdash,1=VDash,1=nvdash,1=nvDash,1=nVdash,1=nVDash,1=prurel\n2=LeftTriangle vartriangleleft vltri,1=RightTriangle vartriangleright vrtri,1=LeftTriangleEqual ltrie trianglelefteq\n0+6he=nvltrie,1=RightTriangleEqual rtrie trianglerighteq,0+6he=nvrtrie,1=origof,1=imof,1=multimap mumap,1=hercon\n1=intcal intercal,1=veebar,2=barvee,1=angrtvb,1=lrtri,1=Wedge bigwedge xwedge,1=Vee bigvee xvee\n1=Intersection bigcap xcap,1=Union bigcup xcup,1=Diamond diam diamond,1=sdot,1=Star sstarf,1=divideontimes divonx\n1=bowtie,1=ltimes,1=rtimes,1=leftthreetimes lthree,1=rightthreetimes rthree,1=backsimeq bsime,1=curlyvee cuvee\n1=curlywedge cuwed,1=Sub Subset,1=Sup Supset,1=Cap,1=Cup,1=fork pitchfork,1=epar,1=lessdot ltdot,1=gtdot gtrdot,1=Ll\n0+mw=nLl,1=Gg ggg,0+mw=nGg,1=LessEqualGreater leg lesseqgtr,0+1e68=lesg,1=GreaterEqualLess gel gtreqless,0+1e68=gesl\n3=cuepr curlyeqprec,1=cuesc curlyeqsucc,1=NotPrecedesSlantEqual nprcue,1=NotSucceedsSlantEqual nsccue\n1=NotSquareSubsetEqual nsqsube,1=NotSquareSupersetEqual nsqsupe,3=lnsim,1=gnsim,1=precnsim prnsim,1=scnsim succnsim\n1=NotLeftTriangle nltri ntriangleleft,1=NotRightTriangle nrtri ntriangleright\n1=NotLeftTriangleEqual nltrie ntrianglelefteq,1=NotRightTriangleEqual nrtrie ntrianglerighteq,1=vellip,1=ctdot\n1=utdot,1=dtdot,1=disin,1=isinsv,1=isins,1=isindot,0+mw=notindot,1=notinvc,1=notinvb,2=isinE,0+mw=notinE,1=nisd\n1=xnis,1=nis,1=notnivc,1=notnivb,7=barwed barwedge,1=Barwed doublebarwedge,2=LeftCeiling lceil,1=RightCeiling rceil\n1=LeftFloor lfloor,1=RightFloor rfloor,1=drcrop,1=dlcrop,1=urcrop,1=ulcrop,1=bnot,2=profline,1=profsurf,2=telrec\n1=target,6=ulcorn ulcorner,1=urcorn urcorner,1=dlcorn llcorner,1=drcorn lrcorner,3=frown sfrown,1=smile ssmile\na=cylcty,1=profalar,8=topbot,7=ovbar,2=solbar,1p=angzarr,1g=lmoust lmoustache,1=rmoust rmoustache,3=OverBracket tbrk\n1=UnderBracket bbrk,1=bbrktbrk,12=OverParenthesis,1=UnderParenthesis,1=OverBrace,1=UnderBrace,3=trpezium,5=elinters\n1o=blank,4l=circledS oS,1k=HorizontalLine boxh,2=boxv,a=boxdr,4=boxdl,4=boxur,4=boxul,4=boxvr,8=boxvl,8=boxhd\n8=boxhu,8=boxvh,k=boxH,1=boxV,1=boxdR,1=boxDr,1=boxDR,1=boxdL,1=boxDl,1=boxDL,1=boxuR,1=boxUr,1=boxUR,1=boxuL\n1=boxUl,1=boxUL,1=boxvR,1=boxVr,1=boxVR,1=boxvL,1=boxVl,1=boxVL,1=boxHd,1=boxhD,1=boxHD,1=boxHu,1=boxhU,1=boxHU\n1=boxvH,1=boxVh,1=boxVH,k=uhblk,4=lhblk,4=block,9=blk14,1=blk12,1=blk34,e=Square squ square\n9=FilledVerySmallSquare blacksquare squarf squf,1=EmptyVerySmallSquare,2=rect,1=marker,3=fltns,2=bigtriangleup xutri\n1=blacktriangle utrif,1=triangle utri,3=blacktriangleright rtrif,1=rtri triangleright,4=bigtriangledown xdtri\n1=blacktriangledown dtrif,1=dtri triangledown,3=blacktriangleleft ltrif,1=ltri triangleleft,7=loz lozenge,1=cir\nx=tridot,3=bigcirc xcirc,9=ultri,1=urtri,1=lltri,1=EmptySmallSquare,1=FilledSmallSquare,9=bigstar starf,1=star\n8=phone,1e=female,2=male,u=spades spadesuit,3=clubs clubsuit,2=hearts heartsuit,1=diamondsuit diams,4=sung,3=flat\n1=natur natural,1=sharp,4k=check checkmark,4=cross,9=malt maltese,m=sext,y=VerticalSeparator,q=lbbrk,1=rbbrk\n2d=bsolhsub,1=suphsol,t=LeftDoubleBracket lobrk,1=RightDoubleBracket robrk,1=LeftAngleBracket lang langle\n1=RightAngleBracket rang rangle,1=Lang,1=Rang,1=loang,1=roang,8=LongLeftArrow longleftarrow xlarr\n1=LongRightArrow longrightarrow xrarr,1=LongLeftRightArrow longleftrightarrow xharr\n1=DoubleLongLeftArrow Longleftarrow xlArr,1=DoubleLongRightArrow Longrightarrow xrArr\n1=DoubleLongLeftRightArrow Longleftrightarrow xhArr,2=longmapsto xmap,3=dzigrarr,77=nvlArr,1=nvrArr,1=nvHarr,1=Map\n7=lbarr,1=bkarow rbarr,1=lBarr,1=dbkarow rBarr,1=RBarr drbkarow,1=DDotrahd,1=UpArrowBar,1=DownArrowBar,3=Rarrtl\n3=latail,1=ratail,1=lAtail,1=rAtail,1=larrfs,1=rarrfs,1=larrbfs,1=rarrbfs,3=nwarhk,1=nearhk,1=hksearow searhk\n1=hkswarow swarhk,1=nwnear,1=nesear toea,1=seswar tosa,1=swnwar,9=rarrc,0+mw=nrarrc,2=cudarrr,1=ldca,1=rdca\n1=cudarrl,1=larrpl,3=curarrm,1=cularrp,8=rarrpl,3=harrcir,1=Uarrocir,1=lurdshar,1=ldrushar,3=LeftRightVector\n1=RightUpDownVector,1=DownLeftRightVector,1=LeftUpDownVector,1=LeftVectorBar,1=RightVectorBar,1=RightUpVectorBar\n1=RightDownVectorBar,1=DownLeftVectorBar,1=DownRightVectorBar,1=LeftUpVectorBar,1=LeftDownVectorBar,1=LeftTeeVector\n1=RightTeeVector,1=RightUpTeeVector,1=RightDownTeeVector,1=DownLeftTeeVector,1=DownRightTeeVector,1=LeftUpTeeVector\n1=LeftDownTeeVector,1=lHar,1=uHar,1=rHar,1=dHar,1=luruhar,1=ldrdhar,1=ruluhar,1=rdldhar,1=lharul,1=llhard,1=rharul\n1=lrhard,1=UpEquilibrium udhar,1=ReverseUpEquilibrium duhar,1=RoundImplies,1=erarr,1=simrarr,1=larrsim,1=rarrsim\n1=rarrap,1=ltlarr,2=gtrarr,1=subrarr,2=suplarr,1=lfisht,1=rfisht,1=ufisht,1=dfisht,6=lopar,1=ropar,5=lbrke,1=rbrke\n1=lbrkslu,1=rbrksld,1=lbrksld,1=rbrkslu,1=langd,1=rangd,1=lparlt,1=rpargt,1=gtlPar,1=ltrPar,4=vzigzag,2=vangrt\n1=angrtvbd,7=ange,1=range,1=dwangle,1=uwangle,1=angmsdaa,1=angmsdab,1=angmsdac,1=angmsdad,1=angmsdae,1=angmsdaf\n1=angmsdag,1=angmsdah,1=bemptyv,1=demptyv,1=cemptyv,1=raemptyv,1=laemptyv,1=ohbar,1=omid,1=opar,2=operp,2=olcross\n1=odsold,2=olcir,1=ofcir,1=olt,1=ogt,1=cirscir,1=cirE,1=solb,1=bsolb,4=boxbox,4=trisb,1=rtriltri,1=LeftTriangleBar\n0+mw=NotLeftTriangleBar,1=RightTriangleBar,0+mw=NotRightTriangleBar,c=iinfin,1=infintie,1=nvinfin,5=eparsl\n1=smeparsl,1=eqvparsl,6=blacklozenge lozf,9=RuleDelayed,2=dsol,a=bigodot xodot,1=bigoplus xoplus,1=bigotimes xotime\n2=biguplus xuplus,2=bigsqcup xsqcup,6=iiiint qint,1=fpartint,3=cirfnint,1=awint,1=rppolint,1=scpolint,1=npolint\n1=pointint,1=quatint,1=intlarhk,b=pluscir,1=plusacir,1=simplus,1=plusdu,1=plussim,1=plustwo,2=mcomma,1=minusdu\n3=loplus,1=roplus,1=Cross,1=timesd,1=timesbar,2=smashp,1=lotimes,1=rotimes,1=otimesas,1=Otimes,1=odiv,1=triplus\n1=triminus,1=tritime,1=intprod iprod,3=amalg,1=capdot,2=ncup,1=ncap,1=capand,1=cupor,1=cupcap,1=capcup,1=cupbrcap\n1=capbrcup,1=cupcup,1=capcap,1=ccups,1=ccaps,3=ccupssm,3=And,1=Or,1=andand,1=oror,1=orslope,1=andslope,2=andv,1=orv\n1=andd,1=ord,2=wedbar,7=sdote,4=simdot,3=congdot,0+mw=ncongdot,1=easter,1=apacir,1=apE,0+mw=napE,1=eplus,1=pluse\n1=Esim,1=Colone,1=Equal,2=ddotseq eDDot,1=equivDD,1=ltcir,1=gtcir,1=ltquest,1=gtquest,1=LessSlantEqual leqslant les\n0+mw=NotLessSlantEqual nleqslant nles,1=GreaterSlantEqual geqslant ges,0+mw=NotGreaterSlantEqual ngeqslant nges\n1=lesdot,1=gesdot,1=lesdoto,1=gesdoto,1=lesdotor,1=gesdotol,1=lap lessapprox,1=gap gtrapprox,1=lne lneq,1=gne gneq\n1=lnap lnapprox,1=gnap gnapprox,1=lEg lesseqqgtr,1=gEl gtreqqless,1=lsime,1=gsime,1=lsimg,1=gsiml,1=lgE,1=glE\n1=lesges,1=gesles,1=els eqslantless,1=egs eqslantgtr,1=elsdot,1=egsdot,1=el,1=eg,3=siml,1=simg,1=simlE,1=simgE\n1=LessLess,0+mw=NotNestedLessLess,1=GreaterGreater,0+mw=NotNestedGreaterGreater,2=glj,1=gla,1=ltcc,1=gtcc,1=lescc\n1=gescc,1=smt,1=lat,1=smte,0+1e68=smtes,1=late,0+1e68=lates,1=bumpE,1=PrecedesEqual pre preceq\n0+mw=NotPrecedesEqual npre npreceq,1=SucceedsEqual sce succeq,0+mw=NotSucceedsEqual nsce nsucceq,3=prE,1=scE\n1=precneqq prnE,1=scnE succneqq,1=prap precapprox,1=scap succapprox,1=precnapprox prnap,1=scnap succnapprox,1=Pr\n1=Sc,1=subdot,1=supdot,1=subplus,1=supplus,1=submult,1=supmult,1=subedot,1=supedot,1=subE subseteqq\n0+mw=nsubE nsubseteqq,1=supE supseteqq,0+mw=nsupE nsupseteqq,1=subsim,1=supsim,3=subnE subsetneqq\n0+1e68=varsubsetneqq vsubnE,1=supnE supsetneqq,0+1e68=varsupsetneqq vsupnE,3=csub,1=csup,1=csube,1=csupe,1=subsup\n1=supsub,1=subsub,1=supsup,1=suphsub,1=supdsub,1=forkv,1=topfork,1=mlcp,9=Dashv DoubleLeftTee,2=Vdashl,1=Barv,1=vBar\n1=vBarv,2=Vbar,1=Not,1=bNot,1=rnmid,1=cirmid,1=midcir,1=topcir,1=nhpar,1=parsim,a=parsl,0+6hx=nparsl,1537=fflig\n1=filig,1=fllig,1=ffilig,1=ffllig,16zc=Ascr,2=Cscr,1=Dscr,3=Gscr,3=Jscr,1=Kscr,3=Nscr,1=Oscr,1=Pscr,1=Qscr,2=Sscr\n1=Tscr,1=Uscr,1=Vscr,1=Wscr,1=Xscr,1=Yscr,1=Zscr,1=ascr,1=bscr,1=cscr,1=dscr,2=fscr,2=hscr,1=iscr,1=jscr,1=kscr\n1=lscr,1=mscr,1=nscr,2=pscr,1=qscr,1=rscr,1=sscr,1=tscr,1=uscr,1=vscr,1=wscr,1=xscr,1=yscr,1=zscr,1h=Afr,1=Bfr,2=Dfr\n1=Efr,1=Ffr,1=Gfr,3=Jfr,1=Kfr,1=Lfr,1=Mfr,1=Nfr,1=Ofr,1=Pfr,1=Qfr,2=Sfr,1=Tfr,1=Ufr,1=Vfr,1=Wfr,1=Xfr,1=Yfr,2=afr\n1=bfr,1=cfr,1=dfr,1=efr,1=ffr,1=gfr,1=hfr,1=ifr,1=jfr,1=kfr,1=lfr,1=mfr,1=nfr,1=ofr,1=pfr,1=qfr,1=rfr,1=sfr,1=tfr\n1=ufr,1=vfr,1=wfr,1=xfr,1=yfr,1=zfr,1=Aopf,1=Bopf,2=Dopf,1=Eopf,1=Fopf,1=Gopf,2=Iopf,1=Jopf,1=Kopf,1=Lopf,1=Mopf\n2=Oopf,4=Sopf,1=Topf,1=Uopf,1=Vopf,1=Wopf,1=Xopf,1=Yopf,2=aopf,1=bopf,1=copf,1=dopf,1=eopf,1=fopf,1=gopf,1=hopf\n1=iopf,1=jopf,1=kopf,1=lopf,1=mopf,1=nopf,1=oopf,1=popf,1=qopf,1=ropf,1=sopf,1=topf,1=uopf,1=vopf,1=wopf,1=xopf\n1=yopf,1=zopf`;\n","/**\n * This module decodes the character references of HTML content, with no DOM. The table of the named references has\n * 2231 names. It is in a separate entry, so a bundle that only scans HTML does not get the table.\n */\nimport { NAMED_REFERENCES } from \"./html-references.ts\";\n\n/**\n * The values of the code points 0x80 to 0x9F in a numeric character reference, from the table of the standard. They are\n * the characters of windows-1252. The five code points that windows-1252 does not have stay as they are.\n */\nconst C1_VALUES =\n \"\\u20AC\\u0081\\u201A\\u0192\\u201E\\u2026\\u2020\\u2021\\u02C6\\u2030\\u0160\\u2039\\u0152\\u008D\\u017D\\u008F\" +\n \"\\u0090\\u2018\\u2019\\u201C\\u201D\\u2022\\u2013\\u2014\\u02DC\\u2122\\u0161\\u203A\\u0153\\u009D\\u017E\\u0178\";\n\n/** The value of each named character reference. A name with `;` is a key, and a legacy name is also a key with no `;`. */\nlet named: Map<string, string> | undefined;\n/** The length of the longest name, with no `;`. */\nlet longestName = 0;\n/** The length of the longest legacy name. */\nlet longestLegacy = 0;\n\n/** This function reads the table of the named character references one time, when the decoder first needs it. */\nfunction namedReferences(): Map<string, string> {\n if (named !== undefined) return named;\n const table = new Map<string, string>();\n let point = 0;\n for (const group of NAMED_REFERENCES.split(/[,\\n]/)) {\n const equals = group.indexOf(\"=\");\n const [first = \"\", second] = group.slice(0, equals).split(\"+\");\n point += parseInt(first, 36);\n const value = second === undefined ? String.fromCodePoint(point) : String.fromCodePoint(point, parseInt(second, 36));\n for (const entry of group.slice(equals + 1).split(\" \")) {\n const legacy = entry.endsWith(\"*\");\n const name = legacy ? entry.slice(0, -1) : entry;\n table.set(`${name};`, value);\n longestName = Math.max(longestName, name.length);\n if (legacy) {\n table.set(name, value);\n longestLegacy = Math.max(longestLegacy, name.length);\n }\n }\n }\n named = table;\n return table;\n}\n\n/** This function tells if a code unit is an ASCII letter or an ASCII digit. */\nconst isAlphanumeric = (code: number): boolean => (code >= 0x30 && code <= 0x39) || ((code | 0x20) >= 0x61 && (code | 0x20) <= 0x7a);\n\n/** This function gives the value of a code unit as a decimal or a hexadecimal digit, or -1 for a different code unit. */\nfunction digitOf(code: number, hex: boolean): number {\n if (code >= 0x30 && code <= 0x39) return code - 0x30;\n const lower = code | 0x20;\n return hex && lower >= 0x61 && lower <= 0x66 ? lower - 0x61 + 10 : -1;\n}\n\n/** A character reference that the decoder found: its value, and the index after its last character. */\ninterface Reference {\n readonly value: string;\n readonly end: number;\n}\n\n/**\n * This function reads the numeric character reference at the \"&\" at `amp`, with the fixes of the standard. It gives\n * undefined when no digit follows \"&#\" or \"&#x\".\n */\nfunction readNumeric(text: string, amp: number): Reference | undefined {\n let at = amp + 2;\n const hex = (text.charCodeAt(at) | 0x20) === 0x78;\n if (hex) at += 1;\n const start = at;\n let point = 0;\n for (let digit = digitOf(text.charCodeAt(at), hex); digit !== -1; digit = digitOf(text.charCodeAt(at), hex)) {\n // A value above 0x10FFFF stays at 0x110000. Thus a long run of digits does not make a number that is too large.\n point = Math.min(point * (hex ? 16 : 10) + digit, 0x110000);\n at += 1;\n }\n if (at === start) return undefined;\n if (text.charCodeAt(at) === 0x3b) at += 1;\n if (point === 0 || point > 0x10ffff || (point >= 0xd800 && point <= 0xdfff)) return { value: \"\\uFFFD\", end: at };\n if (point >= 0x80 && point <= 0x9f) return { value: C1_VALUES.charAt(point - 0x80), end: at };\n return { value: String.fromCodePoint(point), end: at };\n}\n\n/**\n * This function reads the named character reference at the \"&\" at `amp`. The longest name wins. It gives undefined when\n * no name of the table follows the \"&\".\n */\nfunction readNamed(text: string, amp: number): Reference | undefined {\n const from = amp + 1;\n if (!isAlphanumeric(text.charCodeAt(from))) return undefined;\n const table = namedReferences();\n // A run of letters and digits that is longer than the longest name is not a name. Thus each \"&\" reads few characters.\n let at = from;\n while (at - from <= longestName && isAlphanumeric(text.charCodeAt(at))) at += 1;\n if (text.charCodeAt(at) === 0x3b) {\n const value = table.get(text.slice(from, at + 1));\n if (value !== undefined) return { value, end: at + 1 };\n }\n // With no `;`, only a legacy name can match: the longest legacy name at the start of the run.\n for (let end = Math.min(at, from + longestLegacy); end > from; end -= 1) {\n const value = table.get(text.slice(from, end));\n if (value !== undefined) return { value, end };\n }\n return undefined;\n}\n\n/**\n * This function decodes the character references of a text, as the tokenizer of the HTML Living Standard does in the\n * content of an element. Use it on the `text` of a scan of `scanHtml`.\n *\n * - A named reference gets its value from the table of the standard. The longest name wins.\n * - A legacy name, for example `&` or `¬`, is also correct with no semicolon. Thus `¬it;` gives `¬it;`.\n * - A decimal or hexadecimal reference, for example `’` or `’`, gives its code point. The semicolon is optional.\n * - The value 0, a surrogate and a value above `0x10FFFF` give U+FFFD.\n * - The values `0x80` to `0x9F` give the characters of windows-1252, from the table of the standard.\n * - An ampersand with no reference after it stays as text. The function changes no other character.\n *\n * The function does not throw, and it is linear in the length of the text. The result is not longer than the text.\n *\n * @param text - The text of HTML content, with its character references.\n * @returns The text with the value of each character reference in place of the reference.\n */\nexport function decodeReferences(text: string): string {\n let amp = text.indexOf(\"&\");\n if (amp === -1) return text;\n const parts: string[] = [];\n let at = 0;\n while (amp !== -1) {\n const reference = text.charCodeAt(amp + 1) === 0x23 ? readNumeric(text, amp) : readNamed(text, amp);\n if (reference === undefined) amp = text.indexOf(\"&\", amp + 1);\n else {\n parts.push(text.slice(at, amp), reference.value);\n at = reference.end;\n amp = text.indexOf(\"&\", at);\n }\n }\n parts.push(text.slice(at));\n return parts.join(\"\");\n}\n"],"mappings":"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"}
|
package/build/shell.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function escapes a text for one word of a POSIX shell command, for example an argument of a command in a script.
|
|
3
|
+
* The shell reads the word as the text, with no expansion and no split into words.
|
|
4
|
+
*
|
|
5
|
+
* - A text of safe characters only (letters, digits and `_ @ % + = : , . / -`) stays as it is.
|
|
6
|
+
* - Each other text goes in single quotes. Each single quote of the text becomes `'\''`.
|
|
7
|
+
* - The empty text becomes `''`.
|
|
8
|
+
*
|
|
9
|
+
* A shell word cannot hold the NUL character. Thus the function throws a `RangeError` for a text with NUL.
|
|
10
|
+
*
|
|
11
|
+
* @param text - The plain text.
|
|
12
|
+
* @returns One word that a POSIX shell reads as the text.
|
|
13
|
+
*/
|
|
14
|
+
export declare function escapeShell(text: string): string;
|
|
15
|
+
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.d.ts","names":[],"sources":["../src/shell.ts"],"mappings":";;;;;;;;;;;;;wBAqBgB,YAAY"}
|
package/build/shell.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/shell.ts
|
|
2
|
+
/**
|
|
3
|
+
* The entry `@mark1russell7/text/shell`: the escape of a text for one word of a POSIX shell command. It is a separate
|
|
4
|
+
* entry, so the root entry keeps its size.
|
|
5
|
+
*/
|
|
6
|
+
const SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
7
|
+
/**
|
|
8
|
+
* This function escapes a text for one word of a POSIX shell command, for example an argument of a command in a script.
|
|
9
|
+
* The shell reads the word as the text, with no expansion and no split into words.
|
|
10
|
+
*
|
|
11
|
+
* - A text of safe characters only (letters, digits and `_ @ % + = : , . / -`) stays as it is.
|
|
12
|
+
* - Each other text goes in single quotes. Each single quote of the text becomes `'\''`.
|
|
13
|
+
* - The empty text becomes `''`.
|
|
14
|
+
*
|
|
15
|
+
* A shell word cannot hold the NUL character. Thus the function throws a `RangeError` for a text with NUL.
|
|
16
|
+
*
|
|
17
|
+
* @param text - The plain text.
|
|
18
|
+
* @returns One word that a POSIX shell reads as the text.
|
|
19
|
+
*/
|
|
20
|
+
function escapeShell(text) {
|
|
21
|
+
if (text.includes("\0")) throw new RangeError("A shell word cannot hold the NUL character.");
|
|
22
|
+
if (SAFE.test(text)) return text;
|
|
23
|
+
return `'${text.replaceAll("'", "'\\''")}'`;
|
|
24
|
+
}
|
|
25
|
+
export { escapeShell };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","names":[],"sources":["../src/shell.ts"],"sourcesContent":["/**\n * The entry `@mark1russell7/text/shell`: the escape of a text for one word of a POSIX shell command. It is a separate\n * entry, so the root entry keeps its size.\n */\n\n// The characters that a POSIX shell reads as plain word characters at each place of a word. It is the safe set of `shlex.quote` of Python.\nconst SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/;\n\n/**\n * This function escapes a text for one word of a POSIX shell command, for example an argument of a command in a script.\n * The shell reads the word as the text, with no expansion and no split into words.\n *\n * - A text of safe characters only (letters, digits and `_ @ % + = : , . / -`) stays as it is.\n * - Each other text goes in single quotes. Each single quote of the text becomes `'\\''`.\n * - The empty text becomes `''`.\n *\n * A shell word cannot hold the NUL character. Thus the function throws a `RangeError` for a text with NUL.\n *\n * @param text - The plain text.\n * @returns One word that a POSIX shell reads as the text.\n */\nexport function escapeShell(text: string): string {\n if (text.includes(\"\\0\")) throw new RangeError(\"A shell word cannot hold the NUL character.\");\n if (SAFE.test(text)) return text;\n return `'${text.replaceAll(\"'\", \"'\\\\''\")}'`;\n}\n"],"mappings":";;;;;AAMA,MAAM,OAAO;;;;;;;;;;;;;;AAeb,SAAgB,YAAY,MAAsB;CAChD,IAAI,KAAK,SAAS,IAAI,GAAG,MAAM,IAAI,WAAW,6CAA6C;CAC3F,IAAI,KAAK,KAAK,IAAI,GAAG,OAAO;CAC5B,OAAO,IAAI,KAAK,WAAW,KAAK,OAAO,EAAE;AAC3C"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/text",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "Plain text helpers: the escapes for HTML, attributes, patterns, Markdown and workflow commands, English word forms (countOf, listOf), a word search (wordSearch), the text of a thrown value (errorMessage), the orders of texts by code units and by code points (compareCodeUnits, compareCodePoints), the removal of secrets (redactSecrets) and the shapes of tokens and of secrets by their context (findSecretShapes, redactSecretShapes, findSecretShapesInValue, CONTEXT_SHAPES, isSecretName), and lengths in code units, code points and graphemes with truncation and padding (textLength, truncate, pad), the marked parts of a text (partsAt, partsOf), and a scan of HTML for its text and its start tags (scanHtml).",
|
|
4
|
+
"version": "0.0.17",
|
|
5
|
+
"description": "Plain text helpers: the escapes for HTML, attributes, patterns, Markdown and workflow commands, English word forms (countOf, listOf), a word search (wordSearch), the text of a thrown value (errorMessage), the orders of texts by code units and by code points (compareCodeUnits, compareCodePoints), the removal of secrets (redactSecrets) and the shapes of tokens and of secrets by their context (findSecretShapes, redactSecretShapes, findSecretShapesInValue, CONTEXT_SHAPES, isSecretName), and lengths in code units, code points and graphemes with truncation and padding (textLength, truncate, pad), the marked parts of a text (partsAt, partsOf), and a scan of HTML for its text and its start tags (scanHtml) with the decode of its character references (decodeReferences).",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"text",
|
|
8
8
|
"escape",
|
|
9
9
|
"html",
|
|
10
|
+
"entities",
|
|
10
11
|
"regexp",
|
|
11
12
|
"markdown",
|
|
12
13
|
"search",
|
|
@@ -60,6 +61,10 @@
|
|
|
60
61
|
"types": "./build/html.d.ts",
|
|
61
62
|
"default": "./build/html.js"
|
|
62
63
|
},
|
|
64
|
+
"./references": {
|
|
65
|
+
"types": "./build/references.d.ts",
|
|
66
|
+
"default": "./build/references.js"
|
|
67
|
+
},
|
|
63
68
|
"./english": {
|
|
64
69
|
"types": "./build/english.d.ts",
|
|
65
70
|
"default": "./build/english.js"
|
|
@@ -68,6 +73,10 @@
|
|
|
68
73
|
"types": "./build/search.d.ts",
|
|
69
74
|
"default": "./build/search.js"
|
|
70
75
|
},
|
|
76
|
+
"./shell": {
|
|
77
|
+
"types": "./build/shell.d.ts",
|
|
78
|
+
"default": "./build/shell.js"
|
|
79
|
+
},
|
|
71
80
|
"./package.json": "./package.json"
|
|
72
81
|
},
|
|
73
82
|
"files": [
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module has the named character references of HTML. The script `scripts/html-references.ts` made it. Do not
|
|
3
|
+
* edit it. Start the script again to make it.
|
|
4
|
+
*
|
|
5
|
+
* The source is the table of the HTML Living Standard, `https://html.spec.whatwg.org/entities.json`. Copyright WHATWG
|
|
6
|
+
* (Apple, Google, Mozilla, Microsoft). The table has the license CC BY 4.0,
|
|
7
|
+
* `https://creativecommons.org/licenses/by/4.0/`. The SHA-256 of the source file is
|
|
8
|
+
* `d741d877ac77c4194c4ad526b5b4a19aef8dfe411ab840a466891cdbb9f362e6`.
|
|
9
|
+
*
|
|
10
|
+
* The script changed the format of the table, not its content. The source has 2231 names. 106 of them are
|
|
11
|
+
* legacy names, which are in the source with a semicolon and with no semicolon.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The names and the values of the named character references. The names with one value make one group. A comma or a
|
|
16
|
+
* line end comes between two groups. Each group has these parts:
|
|
17
|
+
*
|
|
18
|
+
* - the first code point of the value, as the difference from the first code point of the group before it,
|
|
19
|
+
* - a plus sign and the second code point, only for a value with two code points,
|
|
20
|
+
* - an equals sign and the names of the group, with a space between two names.
|
|
21
|
+
*
|
|
22
|
+
* Each number is in base 36. A name has no ampersand and no semicolon. A star after a name tells that the name is also
|
|
23
|
+
* correct with no semicolon. The groups are in the order of their values. The longest name has 31 characters, and the
|
|
24
|
+
* longest legacy name has 6 characters.
|
|
25
|
+
*/
|
|
26
|
+
export const NAMED_REFERENCES: string =
|
|
27
|
+
`9=Tab,1=NewLine,n=excl,1=QUOT* quot*,1=num,1=dollar,1=percnt,1=AMP* amp*,1=apos,1=lpar,1=rpar,1=ast midast,1=plus
|
|
28
|
+
1=comma,2=period,1=sol,b=colon,1=semi,1=LT* lt*,0+6he=nvlt,1=equals,0+6hx=bne,1=GT* gt*,0+6he=nvgt,1=quest,1=commat
|
|
29
|
+
r=lbrack lsqb,1=bsol,1=rbrack rsqb,1=Hat,1=UnderBar lowbar,1=DiacriticalGrave grave,6+2y=fjlig,l=lbrace lcub
|
|
30
|
+
1=VerticalLine verbar vert,1=rbrace rcub,z=NonBreakingSpace nbsp*,1=iexcl*,1=cent*,1=pound*,1=curren*,1=yen*
|
|
31
|
+
1=brvbar*,1=sect*,1=Dot DoubleDot die uml*,1=COPY* copy*,1=ordf*,1=laquo*,1=not*,1=shy*,1=REG* circledR reg*
|
|
32
|
+
1=macr* strns,1=deg*,1=PlusMinus plusmn* pm,1=sup2*,1=sup3*,1=DiacriticalAcute acute*,1=micro*,1=para*
|
|
33
|
+
1=CenterDot centerdot middot*,1=Cedilla cedil*,1=sup1*,1=ordm*,1=raquo*,1=frac14*,1=frac12* half,1=frac34*,1=iquest*
|
|
34
|
+
1=Agrave*,1=Aacute*,1=Acirc*,1=Atilde*,1=Auml*,1=Aring* angst,1=AElig*,1=Ccedil*,1=Egrave*,1=Eacute*,1=Ecirc*
|
|
35
|
+
1=Euml*,1=Igrave*,1=Iacute*,1=Icirc*,1=Iuml*,1=ETH*,1=Ntilde*,1=Ograve*,1=Oacute*,1=Ocirc*,1=Otilde*,1=Ouml*
|
|
36
|
+
1=times*,1=Oslash*,1=Ugrave*,1=Uacute*,1=Ucirc*,1=Uuml*,1=Yacute*,1=THORN*,1=szlig*,1=agrave*,1=aacute*,1=acirc*
|
|
37
|
+
1=atilde*,1=auml*,1=aring*,1=aelig*,1=ccedil*,1=egrave*,1=eacute*,1=ecirc*,1=euml*,1=igrave*,1=iacute*,1=icirc*
|
|
38
|
+
1=iuml*,1=eth*,1=ntilde*,1=ograve*,1=oacute*,1=ocirc*,1=otilde*,1=ouml*,1=div divide*,1=oslash*,1=ugrave*,1=uacute*
|
|
39
|
+
1=ucirc*,1=uuml*,1=yacute*,1=thorn*,1=yuml*,1=Amacr,1=amacr,1=Abreve,1=abreve,1=Aogon,1=aogon,1=Cacute,1=cacute
|
|
40
|
+
1=Ccirc,1=ccirc,1=Cdot,1=cdot,1=Ccaron,1=ccaron,1=Dcaron,1=dcaron,1=Dstrok,1=dstrok,1=Emacr,1=emacr,3=Edot,1=edot
|
|
41
|
+
1=Eogon,1=eogon,1=Ecaron,1=ecaron,1=Gcirc,1=gcirc,1=Gbreve,1=gbreve,1=Gdot,1=gdot,1=Gcedil,2=Hcirc,1=hcirc,1=Hstrok
|
|
42
|
+
1=hstrok,1=Itilde,1=itilde,1=Imacr,1=imacr,3=Iogon,1=iogon,1=Idot,1=imath inodot,1=IJlig,1=ijlig,1=Jcirc,1=jcirc
|
|
43
|
+
1=Kcedil,1=kcedil,1=kgreen,1=Lacute,1=lacute,1=Lcedil,1=lcedil,1=Lcaron,1=lcaron,1=Lmidot,1=lmidot,1=Lstrok,1=lstrok
|
|
44
|
+
1=Nacute,1=nacute,1=Ncedil,1=ncedil,1=Ncaron,1=ncaron,1=napos,1=ENG,1=eng,1=Omacr,1=omacr,3=Odblac,1=odblac,1=OElig
|
|
45
|
+
1=oelig,1=Racute,1=racute,1=Rcedil,1=rcedil,1=Rcaron,1=rcaron,1=Sacute,1=sacute,1=Scirc,1=scirc,1=Scedil,1=scedil
|
|
46
|
+
1=Scaron,1=scaron,1=Tcedil,1=tcedil,1=Tcaron,1=tcaron,1=Tstrok,1=tstrok,1=Utilde,1=utilde,1=Umacr,1=umacr,1=Ubreve
|
|
47
|
+
1=ubreve,1=Uring,1=uring,1=Udblac,1=udblac,1=Uogon,1=uogon,1=Wcirc,1=wcirc,1=Ycirc,1=ycirc,1=Yuml,1=Zacute,1=zacute
|
|
48
|
+
1=Zdot,1=zdot,1=Zcaron,1=zcaron,k=fnof,z=imped,1s=gacute,1u=jmath,3z=circ,1=Hacek caron,h=Breve breve
|
|
49
|
+
1=DiacriticalDot dot,1=ring,1=ogon,1=DiacriticalTilde tilde,1=DiacriticalDoubleAcute dblac,1g=DownBreve,3k=Alpha
|
|
50
|
+
1=Beta,1=Gamma,1=Delta,1=Epsilon,1=Zeta,1=Eta,1=Theta,1=Iota,1=Kappa,1=Lambda,1=Mu,1=Nu,1=Xi,1=Omicron,1=Pi,1=Rho
|
|
51
|
+
2=Sigma,1=Tau,1=Upsilon,1=Phi,1=Chi,1=Psi,1=Omega ohm,8=alpha,1=beta,1=gamma,1=delta,1=epsi epsilon,1=zeta,1=eta
|
|
52
|
+
1=theta,1=iota,1=kappa,1=lambda,1=mu,1=nu,1=xi,1=omicron,1=pi,1=rho,1=sigmaf sigmav varsigma,1=sigma,1=tau
|
|
53
|
+
1=upsi upsilon,1=phi,1=chi,1=psi,1=omega,8=thetasym thetav vartheta,1=Upsi upsih,3=phiv straightphi varphi
|
|
54
|
+
1=piv varpi,6=Gammad,1=digamma gammad,j=kappav varkappa,1=rhov varrho,4=epsiv straightepsilon varepsilon
|
|
55
|
+
1=backepsilon bepsi,b=IOcy,1=DJcy,1=GJcy,1=Jukcy,1=DScy,1=Iukcy,1=YIcy,1=Jsercy,1=LJcy,1=NJcy,1=TSHcy,1=KJcy,2=Ubrcy
|
|
56
|
+
1=DZcy,1=Acy,1=Bcy,1=Vcy,1=Gcy,1=Dcy,1=IEcy,1=ZHcy,1=Zcy,1=Icy,1=Jcy,1=Kcy,1=Lcy,1=Mcy,1=Ncy,1=Ocy,1=Pcy,1=Rcy,1=Scy
|
|
57
|
+
1=Tcy,1=Ucy,1=Fcy,1=KHcy,1=TScy,1=CHcy,1=SHcy,1=SHCHcy,1=HARDcy,1=Ycy,1=SOFTcy,1=Ecy,1=YUcy,1=YAcy,1=acy,1=bcy,1=vcy
|
|
58
|
+
1=gcy,1=dcy,1=iecy,1=zhcy,1=zcy,1=icy,1=jcy,1=kcy,1=lcy,1=mcy,1=ncy,1=ocy,1=pcy,1=rcy,1=scy,1=tcy,1=ucy,1=fcy,1=khcy
|
|
59
|
+
1=tscy,1=chcy,1=shcy,1=shchcy,1=hardcy,1=ycy,1=softcy,1=ecy,1=yucy,1=yacy,2=iocy,1=djcy,1=gjcy,1=jukcy,1=dscy
|
|
60
|
+
1=iukcy,1=yicy,1=jsercy,1=ljcy,1=njcy,1=tshcy,1=kjcy,2=ubrcy,1=dzcy,5gj=ensp,1=emsp,1=emsp13,1=emsp14,2=numsp
|
|
61
|
+
1=puncsp,1=ThinSpace thinsp,1=VeryThinSpace hairsp
|
|
62
|
+
1=NegativeMediumSpace NegativeThickSpace NegativeThinSpace NegativeVeryThinSpace ZeroWidthSpace,1=zwnj,1=zwj,1=lrm
|
|
63
|
+
1=rlm,1=dash hyphen,3=ndash,1=mdash,1=horbar,1=Verbar Vert,2=OpenCurlyQuote lsquo,1=CloseCurlyQuote rsquo rsquor
|
|
64
|
+
1=lsquor sbquo,2=OpenCurlyDoubleQuote ldquo,1=CloseCurlyDoubleQuote rdquo rdquor,1=bdquo ldquor,2=dagger
|
|
65
|
+
1=Dagger ddagger,1=bull bullet,3=nldr,1=hellip mldr,a=permil,1=pertenk,1=prime,1=Prime,1=tprime,1=backprime bprime
|
|
66
|
+
4=lsaquo,1=rsaquo,4=OverBar oline,3=caret,2=hybull,1=frasl,b=bsemi,8=qprime,8=MediumSpace,0+6bu=ThickSpace,1=NoBreak
|
|
67
|
+
1=ApplyFunction af,1=InvisibleTimes it,1=InvisibleComma ic,21=euro,1b=TripleDot tdot,1=DotDot,12=Copf complexes
|
|
68
|
+
3=incare,5=gscr,1=HilbertSpace Hscr hamilt,1=Hfr Poincareplane,1=Hopf quaternions,1=planckh
|
|
69
|
+
1=hbar hslash planck plankv,1=Iscr imagline,1=Ifr Im image imagpart,1=Laplacetrf Lscr lagran,1=ell,2=Nopf naturals
|
|
70
|
+
1=numero,1=copysr,1=weierp wp,1=Popf primes,1=Qopf rationals,1=Rscr realine,1=Re Rfr real realpart,1=Ropf reals,1=rx
|
|
71
|
+
4=TRADE trade,2=Zopf integers,3=mho,1=Zfr zeetrf,1=iiota,3=Bernoullis Bscr bernou,1=Cayleys Cfr,2=escr
|
|
72
|
+
1=Escr expectation,1=Fouriertrf Fscr,2=Mellintrf Mscr phmmat,1=order orderof oscr,1=alefsym aleph,1=beth,1=gimel
|
|
73
|
+
1=daleth,d=CapitalDifferentialD DD,1=DifferentialD dd,1=ExponentialE ee exponentiale,1=ImaginaryI ii,b=frac13
|
|
74
|
+
1=frac23,1=frac15,1=frac25,1=frac35,1=frac45,1=frac16,1=frac56,1=frac18,1=frac38,1=frac58,1=frac78
|
|
75
|
+
1e=LeftArrow ShortLeftArrow larr leftarrow slarr,1=ShortUpArrow UpArrow uarr uparrow
|
|
76
|
+
1=RightArrow ShortRightArrow rarr rightarrow srarr,1=DownArrow ShortDownArrow darr downarrow
|
|
77
|
+
1=LeftRightArrow harr leftrightarrow,1=UpDownArrow updownarrow varr,1=UpperLeftArrow nwarr nwarrow
|
|
78
|
+
1=UpperRightArrow nearr nearrow,1=LowerRightArrow searr searrow,1=LowerLeftArrow swarr swarrow,1=nlarr nleftarrow
|
|
79
|
+
1=nrarr nrightarrow,2=rarrw rightsquigarrow,0+mw=nrarrw,1=Larr twoheadleftarrow,1=Uarr,1=Rarr twoheadrightarrow
|
|
80
|
+
1=Darr,1=larrtl leftarrowtail,1=rarrtl rightarrowtail,1=LeftTeeArrow mapstoleft,1=UpTeeArrow mapstoup
|
|
81
|
+
1=RightTeeArrow map mapsto,1=DownTeeArrow mapstodown,2=hookleftarrow larrhk,1=hookrightarrow rarrhk
|
|
82
|
+
1=larrlp looparrowleft,1=looparrowright rarrlp,1=harrw leftrightsquigarrow,1=nharr nleftrightarrow,2=Lsh lsh
|
|
83
|
+
1=Rsh rsh,1=ldsh,1=rdsh,2=crarr,1=cularr curvearrowleft,1=curarr curvearrowright,3=circlearrowleft olarr
|
|
84
|
+
1=circlearrowright orarr,1=LeftVector leftharpoonup lharu,1=DownLeftVector leftharpoondown lhard
|
|
85
|
+
1=RightUpVector uharr upharpoonright,1=LeftUpVector uharl upharpoonleft,1=RightVector rharu rightharpoonup
|
|
86
|
+
1=DownRightVector rhard rightharpoondown,1=RightDownVector dharr downharpoonright
|
|
87
|
+
1=LeftDownVector dharl downharpoonleft,1=RightArrowLeftArrow rightleftarrows rlarr,1=UpArrowDownArrow udarr
|
|
88
|
+
1=LeftArrowRightArrow leftrightarrows lrarr,1=leftleftarrows llarr,1=upuparrows uuarr,1=rightrightarrows rrarr
|
|
89
|
+
1=ddarr downdownarrows,1=ReverseEquilibrium leftrightharpoons lrhar,1=Equilibrium rightleftharpoons rlhar
|
|
90
|
+
1=nLeftarrow nlArr,1=nLeftrightarrow nhArr,1=nRightarrow nrArr,1=DoubleLeftArrow Leftarrow lArr
|
|
91
|
+
1=DoubleUpArrow Uparrow uArr,1=DoubleRightArrow Implies Rightarrow rArr,1=DoubleDownArrow Downarrow dArr
|
|
92
|
+
1=DoubleLeftRightArrow Leftrightarrow hArr iff,1=DoubleUpDownArrow Updownarrow vArr,1=nwArr,1=neArr,1=seArr,1=swArr
|
|
93
|
+
1=Lleftarrow lAarr,1=Rrightarrow rAarr,2=zigrarr,7=LeftArrowBar larrb,1=RightArrowBar rarrb,g=DownArrowUpArrow duarr
|
|
94
|
+
8=loarr,1=roarr,1=hoarr,1=ForAll forall,1=comp complement,1=PartialD part,0+mw=npart,1=Exists exist
|
|
95
|
+
1=NotExists nexist nexists,1=empty emptyset emptyv varnothing,2=Del nabla,1=Element in isin isinv
|
|
96
|
+
1=NotElement notin notinva,2=ReverseElement SuchThat ni niv,1=NotReverseElement notni notniva,3=Product prod
|
|
97
|
+
1=Coproduct coprod,1=Sum sum,1=minus,1=MinusPlus mnplus mp,1=dotplus plusdo
|
|
98
|
+
2=Backslash setminus setmn smallsetminus ssetmn,1=lowast,1=SmallCircle compfn,2=Sqrt radic
|
|
99
|
+
3=Proportional prop propto varpropto vprop,1=infin,1=angrt,1=ang angle,0+6he=nang,1=angmsd measuredangle,1=angsph
|
|
100
|
+
1=VerticalBar mid shortmid smid,1=NotVerticalBar nmid nshortmid nsmid
|
|
101
|
+
1=DoubleVerticalBar par parallel shortparallel spar,1=NotDoubleVerticalBar npar nparallel nshortparallel nspar
|
|
102
|
+
1=and wedge,1=or vee,1=cap,0+1e68=caps,1=cup,0+1e68=cups,1=Integral int,1=Int,1=iiint tint
|
|
103
|
+
1=ContourIntegral conint oint,1=Conint DoubleContourIntegral,1=Cconint,1=cwint,1=ClockwiseContourIntegral cwconint
|
|
104
|
+
1=CounterClockwiseContourIntegral awconint,1=Therefore there4 therefore,1=Because becaus because,1=ratio
|
|
105
|
+
1=Colon Proportion,1=dotminus minusd,2=mDDot,1=homtht,1=Tilde sim thicksim thksim,0+6he=nvsim,1=backsim bsim
|
|
106
|
+
0+mp=race,1=ac mstpos,0+mr=acE,1=acd,1=VerticalTilde wr wreath,1=NotTilde nsim,1=EqualTilde eqsim esim
|
|
107
|
+
0+mw=NotEqualTilde nesim,1=TildeEqual sime simeq,1=NotTildeEqual nsime nsimeq,1=TildeFullEqual cong,1=simne
|
|
108
|
+
1=NotTildeFullEqual ncong,1=TildeTilde ap approx asymp thickapprox thkap,1=NotTildeTilde nap napprox,1=ape approxeq
|
|
109
|
+
1=apid,0+mw=napid,1=backcong bcong,1=CupCap asympeq,0+6he=nvap,1=Bumpeq HumpDownHump bump,0+mw=NotHumpDownHump nbump
|
|
110
|
+
1=HumpEqual bumpe bumpeq,0+mw=NotHumpEqual nbumpe,1=DotEqual doteq esdot,0+mw=nedot,1=doteqdot eDot
|
|
111
|
+
1=efDot fallingdotseq,1=erDot risingdotseq,1=Assign colone coloneq,1=ecolon eqcolon,1=ecir eqcirc,1=circeq cire
|
|
112
|
+
2=wedgeq,1=veeeq,2=triangleq trie,3=equest questeq,1=NotEqual ne,1=Congruent equiv,0+6hx=bnequiv
|
|
113
|
+
1=NotCongruent nequiv,2=le leq,0+6he=nvle,1=GreaterEqual ge geq,0+6he=nvge,1=LessFullEqual lE leqq,0+mw=nlE nleqq
|
|
114
|
+
1=GreaterFullEqual gE geqq,0+mw=NotGreaterFullEqual ngE ngeqq,1=lnE lneqq,0+1e68=lvertneqq lvnE,1=gnE gneqq
|
|
115
|
+
0+1e68=gvertneqq gvnE,1=Lt NestedLessLess ll,0+mw=NotLessLess nLtv,0+6he=nLt,1=Gt NestedGreaterGreater gg
|
|
116
|
+
0+mw=NotGreaterGreater nGtv,0+6he=nGt,1=between twixt,1=NotCupCap,1=NotLess nless nlt,1=NotGreater ngt ngtr
|
|
117
|
+
1=NotLessEqual nle nleq,1=NotGreaterEqual nge ngeq,1=LessTilde lesssim lsim,1=GreaterTilde gsim gtrsim
|
|
118
|
+
1=NotLessTilde nlsim,1=NotGreaterTilde ngsim,1=LessGreater lessgtr lg,1=GreaterLess gl gtrless,1=NotLessGreater ntlg
|
|
119
|
+
1=NotGreaterLess ntgl,1=Precedes pr prec,1=Succeeds sc succ,1=PrecedesSlantEqual prcue preccurlyeq
|
|
120
|
+
1=SucceedsSlantEqual sccue succcurlyeq,1=PrecedesTilde precsim prsim,1=SucceedsTilde scsim succsim
|
|
121
|
+
0+mw=NotSucceedsTilde,1=NotPrecedes npr nprec,1=NotSucceeds nsc nsucc,1=sub subset,0+6he=NotSubset nsubset vnsub
|
|
122
|
+
1=Superset sup supset,0+6he=NotSuperset nsupset vnsup,1=nsub,1=nsup,1=SubsetEqual sube subseteq
|
|
123
|
+
1=SupersetEqual supe supseteq,1=NotSubsetEqual nsube nsubseteq,1=NotSupersetEqual nsupe nsupseteq,1=subne subsetneq
|
|
124
|
+
0+1e68=varsubsetneq vsubne,1=supne supsetneq,0+1e68=varsupsetneq vsupne,2=cupdot,1=UnionPlus uplus
|
|
125
|
+
1=SquareSubset sqsub sqsubset,0+mw=NotSquareSubset,1=SquareSuperset sqsup sqsupset,0+mw=NotSquareSuperset
|
|
126
|
+
1=SquareSubsetEqual sqsube sqsubseteq,1=SquareSupersetEqual sqsupe sqsupseteq,1=SquareIntersection sqcap
|
|
127
|
+
0+1e68=sqcaps,1=SquareUnion sqcup,0+1e68=sqcups,1=CirclePlus oplus,1=CircleMinus ominus,1=CircleTimes otimes,1=osol
|
|
128
|
+
1=CircleDot odot,1=circledcirc ocir,1=circledast oast,2=circleddash odash,1=boxplus plusb,1=boxminus minusb
|
|
129
|
+
1=boxtimes timesb,1=dotsquare sdotb,1=RightTee vdash,1=LeftTee dashv,1=DownTee top,1=UpTee bot bottom perp,2=models
|
|
130
|
+
1=DoubleRightTee vDash,1=Vdash,1=Vvdash,1=VDash,1=nvdash,1=nvDash,1=nVdash,1=nVDash,1=prurel
|
|
131
|
+
2=LeftTriangle vartriangleleft vltri,1=RightTriangle vartriangleright vrtri,1=LeftTriangleEqual ltrie trianglelefteq
|
|
132
|
+
0+6he=nvltrie,1=RightTriangleEqual rtrie trianglerighteq,0+6he=nvrtrie,1=origof,1=imof,1=multimap mumap,1=hercon
|
|
133
|
+
1=intcal intercal,1=veebar,2=barvee,1=angrtvb,1=lrtri,1=Wedge bigwedge xwedge,1=Vee bigvee xvee
|
|
134
|
+
1=Intersection bigcap xcap,1=Union bigcup xcup,1=Diamond diam diamond,1=sdot,1=Star sstarf,1=divideontimes divonx
|
|
135
|
+
1=bowtie,1=ltimes,1=rtimes,1=leftthreetimes lthree,1=rightthreetimes rthree,1=backsimeq bsime,1=curlyvee cuvee
|
|
136
|
+
1=curlywedge cuwed,1=Sub Subset,1=Sup Supset,1=Cap,1=Cup,1=fork pitchfork,1=epar,1=lessdot ltdot,1=gtdot gtrdot,1=Ll
|
|
137
|
+
0+mw=nLl,1=Gg ggg,0+mw=nGg,1=LessEqualGreater leg lesseqgtr,0+1e68=lesg,1=GreaterEqualLess gel gtreqless,0+1e68=gesl
|
|
138
|
+
3=cuepr curlyeqprec,1=cuesc curlyeqsucc,1=NotPrecedesSlantEqual nprcue,1=NotSucceedsSlantEqual nsccue
|
|
139
|
+
1=NotSquareSubsetEqual nsqsube,1=NotSquareSupersetEqual nsqsupe,3=lnsim,1=gnsim,1=precnsim prnsim,1=scnsim succnsim
|
|
140
|
+
1=NotLeftTriangle nltri ntriangleleft,1=NotRightTriangle nrtri ntriangleright
|
|
141
|
+
1=NotLeftTriangleEqual nltrie ntrianglelefteq,1=NotRightTriangleEqual nrtrie ntrianglerighteq,1=vellip,1=ctdot
|
|
142
|
+
1=utdot,1=dtdot,1=disin,1=isinsv,1=isins,1=isindot,0+mw=notindot,1=notinvc,1=notinvb,2=isinE,0+mw=notinE,1=nisd
|
|
143
|
+
1=xnis,1=nis,1=notnivc,1=notnivb,7=barwed barwedge,1=Barwed doublebarwedge,2=LeftCeiling lceil,1=RightCeiling rceil
|
|
144
|
+
1=LeftFloor lfloor,1=RightFloor rfloor,1=drcrop,1=dlcrop,1=urcrop,1=ulcrop,1=bnot,2=profline,1=profsurf,2=telrec
|
|
145
|
+
1=target,6=ulcorn ulcorner,1=urcorn urcorner,1=dlcorn llcorner,1=drcorn lrcorner,3=frown sfrown,1=smile ssmile
|
|
146
|
+
a=cylcty,1=profalar,8=topbot,7=ovbar,2=solbar,1p=angzarr,1g=lmoust lmoustache,1=rmoust rmoustache,3=OverBracket tbrk
|
|
147
|
+
1=UnderBracket bbrk,1=bbrktbrk,12=OverParenthesis,1=UnderParenthesis,1=OverBrace,1=UnderBrace,3=trpezium,5=elinters
|
|
148
|
+
1o=blank,4l=circledS oS,1k=HorizontalLine boxh,2=boxv,a=boxdr,4=boxdl,4=boxur,4=boxul,4=boxvr,8=boxvl,8=boxhd
|
|
149
|
+
8=boxhu,8=boxvh,k=boxH,1=boxV,1=boxdR,1=boxDr,1=boxDR,1=boxdL,1=boxDl,1=boxDL,1=boxuR,1=boxUr,1=boxUR,1=boxuL
|
|
150
|
+
1=boxUl,1=boxUL,1=boxvR,1=boxVr,1=boxVR,1=boxvL,1=boxVl,1=boxVL,1=boxHd,1=boxhD,1=boxHD,1=boxHu,1=boxhU,1=boxHU
|
|
151
|
+
1=boxvH,1=boxVh,1=boxVH,k=uhblk,4=lhblk,4=block,9=blk14,1=blk12,1=blk34,e=Square squ square
|
|
152
|
+
9=FilledVerySmallSquare blacksquare squarf squf,1=EmptyVerySmallSquare,2=rect,1=marker,3=fltns,2=bigtriangleup xutri
|
|
153
|
+
1=blacktriangle utrif,1=triangle utri,3=blacktriangleright rtrif,1=rtri triangleright,4=bigtriangledown xdtri
|
|
154
|
+
1=blacktriangledown dtrif,1=dtri triangledown,3=blacktriangleleft ltrif,1=ltri triangleleft,7=loz lozenge,1=cir
|
|
155
|
+
x=tridot,3=bigcirc xcirc,9=ultri,1=urtri,1=lltri,1=EmptySmallSquare,1=FilledSmallSquare,9=bigstar starf,1=star
|
|
156
|
+
8=phone,1e=female,2=male,u=spades spadesuit,3=clubs clubsuit,2=hearts heartsuit,1=diamondsuit diams,4=sung,3=flat
|
|
157
|
+
1=natur natural,1=sharp,4k=check checkmark,4=cross,9=malt maltese,m=sext,y=VerticalSeparator,q=lbbrk,1=rbbrk
|
|
158
|
+
2d=bsolhsub,1=suphsol,t=LeftDoubleBracket lobrk,1=RightDoubleBracket robrk,1=LeftAngleBracket lang langle
|
|
159
|
+
1=RightAngleBracket rang rangle,1=Lang,1=Rang,1=loang,1=roang,8=LongLeftArrow longleftarrow xlarr
|
|
160
|
+
1=LongRightArrow longrightarrow xrarr,1=LongLeftRightArrow longleftrightarrow xharr
|
|
161
|
+
1=DoubleLongLeftArrow Longleftarrow xlArr,1=DoubleLongRightArrow Longrightarrow xrArr
|
|
162
|
+
1=DoubleLongLeftRightArrow Longleftrightarrow xhArr,2=longmapsto xmap,3=dzigrarr,77=nvlArr,1=nvrArr,1=nvHarr,1=Map
|
|
163
|
+
7=lbarr,1=bkarow rbarr,1=lBarr,1=dbkarow rBarr,1=RBarr drbkarow,1=DDotrahd,1=UpArrowBar,1=DownArrowBar,3=Rarrtl
|
|
164
|
+
3=latail,1=ratail,1=lAtail,1=rAtail,1=larrfs,1=rarrfs,1=larrbfs,1=rarrbfs,3=nwarhk,1=nearhk,1=hksearow searhk
|
|
165
|
+
1=hkswarow swarhk,1=nwnear,1=nesear toea,1=seswar tosa,1=swnwar,9=rarrc,0+mw=nrarrc,2=cudarrr,1=ldca,1=rdca
|
|
166
|
+
1=cudarrl,1=larrpl,3=curarrm,1=cularrp,8=rarrpl,3=harrcir,1=Uarrocir,1=lurdshar,1=ldrushar,3=LeftRightVector
|
|
167
|
+
1=RightUpDownVector,1=DownLeftRightVector,1=LeftUpDownVector,1=LeftVectorBar,1=RightVectorBar,1=RightUpVectorBar
|
|
168
|
+
1=RightDownVectorBar,1=DownLeftVectorBar,1=DownRightVectorBar,1=LeftUpVectorBar,1=LeftDownVectorBar,1=LeftTeeVector
|
|
169
|
+
1=RightTeeVector,1=RightUpTeeVector,1=RightDownTeeVector,1=DownLeftTeeVector,1=DownRightTeeVector,1=LeftUpTeeVector
|
|
170
|
+
1=LeftDownTeeVector,1=lHar,1=uHar,1=rHar,1=dHar,1=luruhar,1=ldrdhar,1=ruluhar,1=rdldhar,1=lharul,1=llhard,1=rharul
|
|
171
|
+
1=lrhard,1=UpEquilibrium udhar,1=ReverseUpEquilibrium duhar,1=RoundImplies,1=erarr,1=simrarr,1=larrsim,1=rarrsim
|
|
172
|
+
1=rarrap,1=ltlarr,2=gtrarr,1=subrarr,2=suplarr,1=lfisht,1=rfisht,1=ufisht,1=dfisht,6=lopar,1=ropar,5=lbrke,1=rbrke
|
|
173
|
+
1=lbrkslu,1=rbrksld,1=lbrksld,1=rbrkslu,1=langd,1=rangd,1=lparlt,1=rpargt,1=gtlPar,1=ltrPar,4=vzigzag,2=vangrt
|
|
174
|
+
1=angrtvbd,7=ange,1=range,1=dwangle,1=uwangle,1=angmsdaa,1=angmsdab,1=angmsdac,1=angmsdad,1=angmsdae,1=angmsdaf
|
|
175
|
+
1=angmsdag,1=angmsdah,1=bemptyv,1=demptyv,1=cemptyv,1=raemptyv,1=laemptyv,1=ohbar,1=omid,1=opar,2=operp,2=olcross
|
|
176
|
+
1=odsold,2=olcir,1=ofcir,1=olt,1=ogt,1=cirscir,1=cirE,1=solb,1=bsolb,4=boxbox,4=trisb,1=rtriltri,1=LeftTriangleBar
|
|
177
|
+
0+mw=NotLeftTriangleBar,1=RightTriangleBar,0+mw=NotRightTriangleBar,c=iinfin,1=infintie,1=nvinfin,5=eparsl
|
|
178
|
+
1=smeparsl,1=eqvparsl,6=blacklozenge lozf,9=RuleDelayed,2=dsol,a=bigodot xodot,1=bigoplus xoplus,1=bigotimes xotime
|
|
179
|
+
2=biguplus xuplus,2=bigsqcup xsqcup,6=iiiint qint,1=fpartint,3=cirfnint,1=awint,1=rppolint,1=scpolint,1=npolint
|
|
180
|
+
1=pointint,1=quatint,1=intlarhk,b=pluscir,1=plusacir,1=simplus,1=plusdu,1=plussim,1=plustwo,2=mcomma,1=minusdu
|
|
181
|
+
3=loplus,1=roplus,1=Cross,1=timesd,1=timesbar,2=smashp,1=lotimes,1=rotimes,1=otimesas,1=Otimes,1=odiv,1=triplus
|
|
182
|
+
1=triminus,1=tritime,1=intprod iprod,3=amalg,1=capdot,2=ncup,1=ncap,1=capand,1=cupor,1=cupcap,1=capcup,1=cupbrcap
|
|
183
|
+
1=capbrcup,1=cupcup,1=capcap,1=ccups,1=ccaps,3=ccupssm,3=And,1=Or,1=andand,1=oror,1=orslope,1=andslope,2=andv,1=orv
|
|
184
|
+
1=andd,1=ord,2=wedbar,7=sdote,4=simdot,3=congdot,0+mw=ncongdot,1=easter,1=apacir,1=apE,0+mw=napE,1=eplus,1=pluse
|
|
185
|
+
1=Esim,1=Colone,1=Equal,2=ddotseq eDDot,1=equivDD,1=ltcir,1=gtcir,1=ltquest,1=gtquest,1=LessSlantEqual leqslant les
|
|
186
|
+
0+mw=NotLessSlantEqual nleqslant nles,1=GreaterSlantEqual geqslant ges,0+mw=NotGreaterSlantEqual ngeqslant nges
|
|
187
|
+
1=lesdot,1=gesdot,1=lesdoto,1=gesdoto,1=lesdotor,1=gesdotol,1=lap lessapprox,1=gap gtrapprox,1=lne lneq,1=gne gneq
|
|
188
|
+
1=lnap lnapprox,1=gnap gnapprox,1=lEg lesseqqgtr,1=gEl gtreqqless,1=lsime,1=gsime,1=lsimg,1=gsiml,1=lgE,1=glE
|
|
189
|
+
1=lesges,1=gesles,1=els eqslantless,1=egs eqslantgtr,1=elsdot,1=egsdot,1=el,1=eg,3=siml,1=simg,1=simlE,1=simgE
|
|
190
|
+
1=LessLess,0+mw=NotNestedLessLess,1=GreaterGreater,0+mw=NotNestedGreaterGreater,2=glj,1=gla,1=ltcc,1=gtcc,1=lescc
|
|
191
|
+
1=gescc,1=smt,1=lat,1=smte,0+1e68=smtes,1=late,0+1e68=lates,1=bumpE,1=PrecedesEqual pre preceq
|
|
192
|
+
0+mw=NotPrecedesEqual npre npreceq,1=SucceedsEqual sce succeq,0+mw=NotSucceedsEqual nsce nsucceq,3=prE,1=scE
|
|
193
|
+
1=precneqq prnE,1=scnE succneqq,1=prap precapprox,1=scap succapprox,1=precnapprox prnap,1=scnap succnapprox,1=Pr
|
|
194
|
+
1=Sc,1=subdot,1=supdot,1=subplus,1=supplus,1=submult,1=supmult,1=subedot,1=supedot,1=subE subseteqq
|
|
195
|
+
0+mw=nsubE nsubseteqq,1=supE supseteqq,0+mw=nsupE nsupseteqq,1=subsim,1=supsim,3=subnE subsetneqq
|
|
196
|
+
0+1e68=varsubsetneqq vsubnE,1=supnE supsetneqq,0+1e68=varsupsetneqq vsupnE,3=csub,1=csup,1=csube,1=csupe,1=subsup
|
|
197
|
+
1=supsub,1=subsub,1=supsup,1=suphsub,1=supdsub,1=forkv,1=topfork,1=mlcp,9=Dashv DoubleLeftTee,2=Vdashl,1=Barv,1=vBar
|
|
198
|
+
1=vBarv,2=Vbar,1=Not,1=bNot,1=rnmid,1=cirmid,1=midcir,1=topcir,1=nhpar,1=parsim,a=parsl,0+6hx=nparsl,1537=fflig
|
|
199
|
+
1=filig,1=fllig,1=ffilig,1=ffllig,16zc=Ascr,2=Cscr,1=Dscr,3=Gscr,3=Jscr,1=Kscr,3=Nscr,1=Oscr,1=Pscr,1=Qscr,2=Sscr
|
|
200
|
+
1=Tscr,1=Uscr,1=Vscr,1=Wscr,1=Xscr,1=Yscr,1=Zscr,1=ascr,1=bscr,1=cscr,1=dscr,2=fscr,2=hscr,1=iscr,1=jscr,1=kscr
|
|
201
|
+
1=lscr,1=mscr,1=nscr,2=pscr,1=qscr,1=rscr,1=sscr,1=tscr,1=uscr,1=vscr,1=wscr,1=xscr,1=yscr,1=zscr,1h=Afr,1=Bfr,2=Dfr
|
|
202
|
+
1=Efr,1=Ffr,1=Gfr,3=Jfr,1=Kfr,1=Lfr,1=Mfr,1=Nfr,1=Ofr,1=Pfr,1=Qfr,2=Sfr,1=Tfr,1=Ufr,1=Vfr,1=Wfr,1=Xfr,1=Yfr,2=afr
|
|
203
|
+
1=bfr,1=cfr,1=dfr,1=efr,1=ffr,1=gfr,1=hfr,1=ifr,1=jfr,1=kfr,1=lfr,1=mfr,1=nfr,1=ofr,1=pfr,1=qfr,1=rfr,1=sfr,1=tfr
|
|
204
|
+
1=ufr,1=vfr,1=wfr,1=xfr,1=yfr,1=zfr,1=Aopf,1=Bopf,2=Dopf,1=Eopf,1=Fopf,1=Gopf,2=Iopf,1=Jopf,1=Kopf,1=Lopf,1=Mopf
|
|
205
|
+
2=Oopf,4=Sopf,1=Topf,1=Uopf,1=Vopf,1=Wopf,1=Xopf,1=Yopf,2=aopf,1=bopf,1=copf,1=dopf,1=eopf,1=fopf,1=gopf,1=hopf
|
|
206
|
+
1=iopf,1=jopf,1=kopf,1=lopf,1=mopf,1=nopf,1=oopf,1=popf,1=qopf,1=ropf,1=sopf,1=topf,1=uopf,1=vopf,1=wopf,1=xopf
|
|
207
|
+
1=yopf,1=zopf`;
|
package/src/html.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface HtmlScan {
|
|
|
22
22
|
/**
|
|
23
23
|
* The text of the HTML outside the tags, the comments and the skipped elements. Each tag, comment and skipped element
|
|
24
24
|
* gives one space, so two words in two elements stay two words. The white space and the character references stay as in the HTML.
|
|
25
|
+
* The function `decodeReferences` of the entry `./references` decodes the character references.
|
|
25
26
|
*/
|
|
26
27
|
readonly text: string;
|
|
27
28
|
/** The start tags outside the comments and the skipped elements, in the order of the HTML. The start tag of a skipped element is in the list. */
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The entry of `@mark1russell7/text`: plain text helpers. The first group is the escapes for HTML, attributes, regular
|
|
3
3
|
* expressions, Markdown and GitHub Actions workflow commands. The other groups are the English word forms, a word
|
|
4
|
-
* search and the text of a thrown value.
|
|
4
|
+
* search and the text of a thrown value.
|
|
5
|
+
*
|
|
6
|
+
* The entry `@mark1russell7/text/redact` removes secrets from a text, and the entry
|
|
5
7
|
* `@mark1russell7/text/order` has two orders of texts. The entry `@mark1russell7/text/english` adds the list join `listOf`.
|
|
6
|
-
* The entry `@mark1russell7/text/search` adds a ranked search with TF-IDF.
|
|
8
|
+
* The entry `@mark1russell7/text/search` adds a ranked search with TF-IDF. The entry `@mark1russell7/text/shell` has the
|
|
9
|
+
* escape of a POSIX shell word.
|
|
7
10
|
*/
|
|
8
11
|
export { countOf } from "./english.ts";
|
|
9
12
|
export { errorMessage } from "./error.ts";
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module decodes the character references of HTML content, with no DOM. The table of the named references has
|
|
3
|
+
* 2231 names. It is in a separate entry, so a bundle that only scans HTML does not get the table.
|
|
4
|
+
*/
|
|
5
|
+
import { NAMED_REFERENCES } from "./html-references.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The values of the code points 0x80 to 0x9F in a numeric character reference, from the table of the standard. They are
|
|
9
|
+
* the characters of windows-1252. The five code points that windows-1252 does not have stay as they are.
|
|
10
|
+
*/
|
|
11
|
+
const C1_VALUES =
|
|
12
|
+
"\u20AC\u0081\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\u008D\u017D\u008F" +
|
|
13
|
+
"\u0090\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\u009D\u017E\u0178";
|
|
14
|
+
|
|
15
|
+
/** The value of each named character reference. A name with `;` is a key, and a legacy name is also a key with no `;`. */
|
|
16
|
+
let named: Map<string, string> | undefined;
|
|
17
|
+
/** The length of the longest name, with no `;`. */
|
|
18
|
+
let longestName = 0;
|
|
19
|
+
/** The length of the longest legacy name. */
|
|
20
|
+
let longestLegacy = 0;
|
|
21
|
+
|
|
22
|
+
/** This function reads the table of the named character references one time, when the decoder first needs it. */
|
|
23
|
+
function namedReferences(): Map<string, string> {
|
|
24
|
+
if (named !== undefined) return named;
|
|
25
|
+
const table = new Map<string, string>();
|
|
26
|
+
let point = 0;
|
|
27
|
+
for (const group of NAMED_REFERENCES.split(/[,\n]/)) {
|
|
28
|
+
const equals = group.indexOf("=");
|
|
29
|
+
const [first = "", second] = group.slice(0, equals).split("+");
|
|
30
|
+
point += parseInt(first, 36);
|
|
31
|
+
const value = second === undefined ? String.fromCodePoint(point) : String.fromCodePoint(point, parseInt(second, 36));
|
|
32
|
+
for (const entry of group.slice(equals + 1).split(" ")) {
|
|
33
|
+
const legacy = entry.endsWith("*");
|
|
34
|
+
const name = legacy ? entry.slice(0, -1) : entry;
|
|
35
|
+
table.set(`${name};`, value);
|
|
36
|
+
longestName = Math.max(longestName, name.length);
|
|
37
|
+
if (legacy) {
|
|
38
|
+
table.set(name, value);
|
|
39
|
+
longestLegacy = Math.max(longestLegacy, name.length);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
named = table;
|
|
44
|
+
return table;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** This function tells if a code unit is an ASCII letter or an ASCII digit. */
|
|
48
|
+
const isAlphanumeric = (code: number): boolean => (code >= 0x30 && code <= 0x39) || ((code | 0x20) >= 0x61 && (code | 0x20) <= 0x7a);
|
|
49
|
+
|
|
50
|
+
/** This function gives the value of a code unit as a decimal or a hexadecimal digit, or -1 for a different code unit. */
|
|
51
|
+
function digitOf(code: number, hex: boolean): number {
|
|
52
|
+
if (code >= 0x30 && code <= 0x39) return code - 0x30;
|
|
53
|
+
const lower = code | 0x20;
|
|
54
|
+
return hex && lower >= 0x61 && lower <= 0x66 ? lower - 0x61 + 10 : -1;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A character reference that the decoder found: its value, and the index after its last character. */
|
|
58
|
+
interface Reference {
|
|
59
|
+
readonly value: string;
|
|
60
|
+
readonly end: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* This function reads the numeric character reference at the "&" at `amp`, with the fixes of the standard. It gives
|
|
65
|
+
* undefined when no digit follows "&#" or "&#x".
|
|
66
|
+
*/
|
|
67
|
+
function readNumeric(text: string, amp: number): Reference | undefined {
|
|
68
|
+
let at = amp + 2;
|
|
69
|
+
const hex = (text.charCodeAt(at) | 0x20) === 0x78;
|
|
70
|
+
if (hex) at += 1;
|
|
71
|
+
const start = at;
|
|
72
|
+
let point = 0;
|
|
73
|
+
for (let digit = digitOf(text.charCodeAt(at), hex); digit !== -1; digit = digitOf(text.charCodeAt(at), hex)) {
|
|
74
|
+
// A value above 0x10FFFF stays at 0x110000. Thus a long run of digits does not make a number that is too large.
|
|
75
|
+
point = Math.min(point * (hex ? 16 : 10) + digit, 0x110000);
|
|
76
|
+
at += 1;
|
|
77
|
+
}
|
|
78
|
+
if (at === start) return undefined;
|
|
79
|
+
if (text.charCodeAt(at) === 0x3b) at += 1;
|
|
80
|
+
if (point === 0 || point > 0x10ffff || (point >= 0xd800 && point <= 0xdfff)) return { value: "\uFFFD", end: at };
|
|
81
|
+
if (point >= 0x80 && point <= 0x9f) return { value: C1_VALUES.charAt(point - 0x80), end: at };
|
|
82
|
+
return { value: String.fromCodePoint(point), end: at };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* This function reads the named character reference at the "&" at `amp`. The longest name wins. It gives undefined when
|
|
87
|
+
* no name of the table follows the "&".
|
|
88
|
+
*/
|
|
89
|
+
function readNamed(text: string, amp: number): Reference | undefined {
|
|
90
|
+
const from = amp + 1;
|
|
91
|
+
if (!isAlphanumeric(text.charCodeAt(from))) return undefined;
|
|
92
|
+
const table = namedReferences();
|
|
93
|
+
// A run of letters and digits that is longer than the longest name is not a name. Thus each "&" reads few characters.
|
|
94
|
+
let at = from;
|
|
95
|
+
while (at - from <= longestName && isAlphanumeric(text.charCodeAt(at))) at += 1;
|
|
96
|
+
if (text.charCodeAt(at) === 0x3b) {
|
|
97
|
+
const value = table.get(text.slice(from, at + 1));
|
|
98
|
+
if (value !== undefined) return { value, end: at + 1 };
|
|
99
|
+
}
|
|
100
|
+
// With no `;`, only a legacy name can match: the longest legacy name at the start of the run.
|
|
101
|
+
for (let end = Math.min(at, from + longestLegacy); end > from; end -= 1) {
|
|
102
|
+
const value = table.get(text.slice(from, end));
|
|
103
|
+
if (value !== undefined) return { value, end };
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* This function decodes the character references of a text, as the tokenizer of the HTML Living Standard does in the
|
|
110
|
+
* content of an element. Use it on the `text` of a scan of `scanHtml`.
|
|
111
|
+
*
|
|
112
|
+
* - A named reference gets its value from the table of the standard. The longest name wins.
|
|
113
|
+
* - A legacy name, for example `&` or `¬`, is also correct with no semicolon. Thus `¬it;` gives `¬it;`.
|
|
114
|
+
* - A decimal or hexadecimal reference, for example `’` or `’`, gives its code point. The semicolon is optional.
|
|
115
|
+
* - The value 0, a surrogate and a value above `0x10FFFF` give U+FFFD.
|
|
116
|
+
* - The values `0x80` to `0x9F` give the characters of windows-1252, from the table of the standard.
|
|
117
|
+
* - An ampersand with no reference after it stays as text. The function changes no other character.
|
|
118
|
+
*
|
|
119
|
+
* The function does not throw, and it is linear in the length of the text. The result is not longer than the text.
|
|
120
|
+
*
|
|
121
|
+
* @param text - The text of HTML content, with its character references.
|
|
122
|
+
* @returns The text with the value of each character reference in place of the reference.
|
|
123
|
+
*/
|
|
124
|
+
export function decodeReferences(text: string): string {
|
|
125
|
+
let amp = text.indexOf("&");
|
|
126
|
+
if (amp === -1) return text;
|
|
127
|
+
const parts: string[] = [];
|
|
128
|
+
let at = 0;
|
|
129
|
+
while (amp !== -1) {
|
|
130
|
+
const reference = text.charCodeAt(amp + 1) === 0x23 ? readNumeric(text, amp) : readNamed(text, amp);
|
|
131
|
+
if (reference === undefined) amp = text.indexOf("&", amp + 1);
|
|
132
|
+
else {
|
|
133
|
+
parts.push(text.slice(at, amp), reference.value);
|
|
134
|
+
at = reference.end;
|
|
135
|
+
amp = text.indexOf("&", at);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
parts.push(text.slice(at));
|
|
139
|
+
return parts.join("");
|
|
140
|
+
}
|
package/src/shell.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The entry `@mark1russell7/text/shell`: the escape of a text for one word of a POSIX shell command. It is a separate
|
|
3
|
+
* entry, so the root entry keeps its size.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// The characters that a POSIX shell reads as plain word characters at each place of a word. It is the safe set of `shlex.quote` of Python.
|
|
7
|
+
const SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This function escapes a text for one word of a POSIX shell command, for example an argument of a command in a script.
|
|
11
|
+
* The shell reads the word as the text, with no expansion and no split into words.
|
|
12
|
+
*
|
|
13
|
+
* - A text of safe characters only (letters, digits and `_ @ % + = : , . / -`) stays as it is.
|
|
14
|
+
* - Each other text goes in single quotes. Each single quote of the text becomes `'\''`.
|
|
15
|
+
* - The empty text becomes `''`.
|
|
16
|
+
*
|
|
17
|
+
* A shell word cannot hold the NUL character. Thus the function throws a `RangeError` for a text with NUL.
|
|
18
|
+
*
|
|
19
|
+
* @param text - The plain text.
|
|
20
|
+
* @returns One word that a POSIX shell reads as the text.
|
|
21
|
+
*/
|
|
22
|
+
export function escapeShell(text: string): string {
|
|
23
|
+
if (text.includes("\0")) throw new RangeError("A shell word cannot hold the NUL character.");
|
|
24
|
+
if (SAFE.test(text)) return text;
|
|
25
|
+
return `'${text.replaceAll("'", "'\\''")}'`;
|
|
26
|
+
}
|