| [9af201e] | 1 | "use strict";
|
|---|
| 2 | /**
|
|---|
| 3 | * Character classes and associated utilities for the 5th edition of XML 1.0.
|
|---|
| 4 | *
|
|---|
| 5 | * @author Louis-Dominique Dubeau
|
|---|
| 6 | * @license MIT
|
|---|
| 7 | * @copyright Louis-Dominique Dubeau
|
|---|
| 8 | */
|
|---|
| 9 | Object.defineProperty(exports, "__esModule", { value: true });
|
|---|
| 10 | //
|
|---|
| 11 | // Fragments.
|
|---|
| 12 | //
|
|---|
| 13 | exports.CHAR = "\t\n\r -\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF";
|
|---|
| 14 | exports.S = " \t\r\n";
|
|---|
| 15 | // tslint:disable-next-line:max-line-length
|
|---|
| 16 | exports.NAME_START_CHAR = ":A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\uD800\uDC00-\uDB7F\uDFFF";
|
|---|
| 17 | exports.NAME_CHAR = "-" + exports.NAME_START_CHAR + ".0-9\u00B7\u0300-\u036F\u203F-\u2040";
|
|---|
| 18 | //
|
|---|
| 19 | // Regular expressions.
|
|---|
| 20 | //
|
|---|
| 21 | exports.CHAR_RE = new RegExp("^[" + exports.CHAR + "]$", "u");
|
|---|
| 22 | exports.S_RE = new RegExp("^[" + exports.S + "]+$", "u");
|
|---|
| 23 | exports.NAME_START_CHAR_RE = new RegExp("^[" + exports.NAME_START_CHAR + "]$", "u");
|
|---|
| 24 | exports.NAME_CHAR_RE = new RegExp("^[" + exports.NAME_CHAR + "]$", "u");
|
|---|
| 25 | exports.NAME_RE = new RegExp("^[" + exports.NAME_START_CHAR + "][" + exports.NAME_CHAR + "]*$", "u");
|
|---|
| 26 | exports.NMTOKEN_RE = new RegExp("^[" + exports.NAME_CHAR + "]+$", "u");
|
|---|
| 27 | var TAB = 9;
|
|---|
| 28 | var NL = 0xA;
|
|---|
| 29 | var CR = 0xD;
|
|---|
| 30 | var SPACE = 0x20;
|
|---|
| 31 | //
|
|---|
| 32 | // Lists.
|
|---|
| 33 | //
|
|---|
| 34 | /** All characters in the ``S`` production. */
|
|---|
| 35 | exports.S_LIST = [SPACE, NL, CR, TAB];
|
|---|
| 36 | /**
|
|---|
| 37 | * Determines whether a codepoint matches the ``CHAR`` production.
|
|---|
| 38 | *
|
|---|
| 39 | * @param c The code point.
|
|---|
| 40 | *
|
|---|
| 41 | * @returns ``true`` if the codepoint matches ``CHAR``.
|
|---|
| 42 | */
|
|---|
| 43 | function isChar(c) {
|
|---|
| 44 | return (c >= SPACE && c <= 0xD7FF) ||
|
|---|
| 45 | c === NL || c === CR || c === TAB ||
|
|---|
| 46 | (c >= 0xE000 && c <= 0xFFFD) ||
|
|---|
| 47 | (c >= 0x10000 && c <= 0x10FFFF);
|
|---|
| 48 | }
|
|---|
| 49 | exports.isChar = isChar;
|
|---|
| 50 | /**
|
|---|
| 51 | * Determines whether a codepoint matches the ``S`` (space) production.
|
|---|
| 52 | *
|
|---|
| 53 | * @param c The code point.
|
|---|
| 54 | *
|
|---|
| 55 | * @returns ``true`` if the codepoint matches ``S``.
|
|---|
| 56 | */
|
|---|
| 57 | function isS(c) {
|
|---|
| 58 | return c === SPACE || c === NL || c === CR || c === TAB;
|
|---|
| 59 | }
|
|---|
| 60 | exports.isS = isS;
|
|---|
| 61 | /**
|
|---|
| 62 | * Determines whether a codepoint matches the ``NAME_START_CHAR`` production.
|
|---|
| 63 | *
|
|---|
| 64 | * @param c The code point.
|
|---|
| 65 | *
|
|---|
| 66 | * @returns ``true`` if the codepoint matches ``NAME_START_CHAR``.
|
|---|
| 67 | */
|
|---|
| 68 | function isNameStartChar(c) {
|
|---|
| 69 | return ((c >= 0x41 && c <= 0x5A) ||
|
|---|
| 70 | (c >= 0x61 && c <= 0x7A) ||
|
|---|
| 71 | c === 0x3A ||
|
|---|
| 72 | c === 0x5F ||
|
|---|
| 73 | c === 0x200C ||
|
|---|
| 74 | c === 0x200D ||
|
|---|
| 75 | (c >= 0xC0 && c <= 0xD6) ||
|
|---|
| 76 | (c >= 0xD8 && c <= 0xF6) ||
|
|---|
| 77 | (c >= 0x00F8 && c <= 0x02FF) ||
|
|---|
| 78 | (c >= 0x0370 && c <= 0x037D) ||
|
|---|
| 79 | (c >= 0x037F && c <= 0x1FFF) ||
|
|---|
| 80 | (c >= 0x2070 && c <= 0x218F) ||
|
|---|
| 81 | (c >= 0x2C00 && c <= 0x2FEF) ||
|
|---|
| 82 | (c >= 0x3001 && c <= 0xD7FF) ||
|
|---|
| 83 | (c >= 0xF900 && c <= 0xFDCF) ||
|
|---|
| 84 | (c >= 0xFDF0 && c <= 0xFFFD) ||
|
|---|
| 85 | (c >= 0x10000 && c <= 0xEFFFF));
|
|---|
| 86 | }
|
|---|
| 87 | exports.isNameStartChar = isNameStartChar;
|
|---|
| 88 | /**
|
|---|
| 89 | * Determines whether a codepoint matches the ``NAME_CHAR`` production.
|
|---|
| 90 | *
|
|---|
| 91 | * @param c The code point.
|
|---|
| 92 | *
|
|---|
| 93 | * @returns ``true`` if the codepoint matches ``NAME_CHAR``.
|
|---|
| 94 | */
|
|---|
| 95 | function isNameChar(c) {
|
|---|
| 96 | return isNameStartChar(c) ||
|
|---|
| 97 | (c >= 0x30 && c <= 0x39) ||
|
|---|
| 98 | c === 0x2D ||
|
|---|
| 99 | c === 0x2E ||
|
|---|
| 100 | c === 0xB7 ||
|
|---|
| 101 | (c >= 0x0300 && c <= 0x036F) ||
|
|---|
| 102 | (c >= 0x203F && c <= 0x2040);
|
|---|
| 103 | }
|
|---|
| 104 | exports.isNameChar = isNameChar;
|
|---|
| 105 | //# sourceMappingURL=ed5.js.map |
|---|