Add initial 11ty website structure
This commit is contained in:
1 parent
62b6bbdcbc
commit
80214bf42d
1378 files changed
+204162
No files matched your search
+83
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"requireCurlyBraces": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"try",
|
||||
"catch"
|
||||
],
|
||||
"requireOperatorBeforeLineBreak": true,
|
||||
"requireParenthesesAroundIIFE": true,
|
||||
"requireMultipleVarDecl": "onevar",
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
"requireCamelCaseOrUpperCaseIdentifiers": true,
|
||||
"requireDotNotation": true,
|
||||
"requireSpacesInForStatement": true,
|
||||
"maximumLineLength": {
|
||||
"value": 100,
|
||||
"tabSize": 4,
|
||||
"allowUrlComments": true,
|
||||
"allowRegex": true
|
||||
},
|
||||
"validateQuoteMarks": { "mark": "\"", "escape": true },
|
||||
|
||||
"disallowMixedSpacesAndTabs": "smart",
|
||||
"disallowTrailingWhitespace": true,
|
||||
"disallowMultipleLineStrings": true,
|
||||
"disallowTrailingComma": true,
|
||||
|
||||
"requireSpaceBeforeBlockStatements": true,
|
||||
"requireSpacesInFunctionExpression": {
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"requireSpaceAfterKeywords": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"switch",
|
||||
"return",
|
||||
"try",
|
||||
"catch"
|
||||
],
|
||||
"requireSpacesInsideObjectBrackets": "all",
|
||||
"requireSpacesInsideArrayBrackets": "all",
|
||||
"requireSpacesInConditionalExpression": true,
|
||||
"requireSpaceAfterBinaryOperators": true,
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
"requireSpaceBeforeBinaryOperators": [
|
||||
"=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
|
||||
"&=", "|=", "^=", "+=",
|
||||
|
||||
"+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
|
||||
"|", "^", "&&", "||", "===", "==", ">=",
|
||||
"<=", "<", ">", "!=", "!=="
|
||||
],
|
||||
"requireSpacesInAnonymousFunctionExpression": {
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"requireSpacesInNamedFunctionExpression": {
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"validateLineBreaks": "LF",
|
||||
|
||||
"disallowKeywords": [ "with" ],
|
||||
"disallowKeywordsOnNewLine": [ "else" ],
|
||||
"disallowSpacesInFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInNamedFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInAnonymousFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
||||
"disallowSpaceBeforePostfixUnaryOperators": true,
|
||||
"disallowSpaceBeforeBinaryOperators": [ ",", ":" ],
|
||||
"disallowMultipleLineBreaks": true
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"boss": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"eqnull": true,
|
||||
"expr": true,
|
||||
"immed": true,
|
||||
"noarg": true,
|
||||
"onevar": true,
|
||||
"quotmark": "double",
|
||||
"smarttabs": true,
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
"unused": true
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
*/.DS_Store
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
node_modules
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Alex Bell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
# parse-srcset
|
||||
|
||||
A javascript parser for the [HTML5 srcset](http://www.w3.org/TR/html-srcset/) attribute, based on the [WHATWG reference algorithm](https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute). It has an extensive test suite based on the [W3C srcset conformance checker](http://w3c-test.org/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html). It conforms to the jQuery JSCS style rules.
|
||||
|
||||
Tests are written using Intern-geezer for compatibility.
|
||||
|
||||
To run the tests in console:
|
||||
|
||||
```
|
||||
$ npm test
|
||||
```
|
||||
|
||||
Or in a browser, just open the html file at:
|
||||
|
||||
```
|
||||
node_modules/intern-geezer/client.html?config=tests/intern
|
||||
```
|
||||
|
||||
I’m on twitter [@tweetywheaty](https://twitter.com/tweetywheaty).
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "parse-srcset",
|
||||
"version": "1.0.2",
|
||||
"description": "A spec-conformant JavaScript parser for the HTML5 srcset attribute",
|
||||
"main": "src/parse-srcset.js",
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "intern-client config=tests/intern"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/albell/parse-srcset.git"
|
||||
},
|
||||
"author": "Alex Bell <alex@bellandwhistle.net>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/albell/parse-srcset/issues"
|
||||
},
|
||||
"homepage": "https://github.com/albell/parse-srcset#readme",
|
||||
"devDependencies": {
|
||||
"intern-geezer": "^2.2.3"
|
||||
}
|
||||
}
|
||||
+330
@@ -0,0 +1,330 @@
|
||||
/**
|
||||
* Srcset Parser
|
||||
*
|
||||
* By Alex Bell | MIT License
|
||||
*
|
||||
* JS Parser for the string value that appears in markup <img srcset="here">
|
||||
*
|
||||
* @returns Array [{url: _, d: _, w: _, h:_}, ...]
|
||||
*
|
||||
* Based super duper closely on the reference algorithm at:
|
||||
* https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute
|
||||
*
|
||||
* Most comments are copied in directly from the spec
|
||||
* (except for comments in parens).
|
||||
*/
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define([], factory);
|
||||
} else if (typeof module === 'object' && module.exports) {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like environments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.parseSrcset = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
|
||||
// 1. Let input be the value passed to this algorithm.
|
||||
return function (input) {
|
||||
|
||||
// UTILITY FUNCTIONS
|
||||
|
||||
// Manual is faster than RegEx
|
||||
// http://bjorn.tipling.com/state-and-regular-expressions-in-javascript
|
||||
// http://jsperf.com/whitespace-character/5
|
||||
function isSpace(c) {
|
||||
return (c === "\u0020" || // space
|
||||
c === "\u0009" || // horizontal tab
|
||||
c === "\u000A" || // new line
|
||||
c === "\u000C" || // form feed
|
||||
c === "\u000D"); // carriage return
|
||||
}
|
||||
|
||||
function collectCharacters(regEx) {
|
||||
var chars,
|
||||
match = regEx.exec(input.substring(pos));
|
||||
if (match) {
|
||||
chars = match[ 0 ];
|
||||
pos += chars.length;
|
||||
return chars;
|
||||
}
|
||||
}
|
||||
|
||||
var inputLength = input.length,
|
||||
|
||||
// (Don't use \s, to avoid matching non-breaking space)
|
||||
regexLeadingSpaces = /^[ \t\n\r\u000c]+/,
|
||||
regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/,
|
||||
regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/,
|
||||
regexTrailingCommas = /[,]+$/,
|
||||
regexNonNegativeInteger = /^\d+$/,
|
||||
|
||||
// ( Positive or negative or unsigned integers or decimals, without or without exponents.
|
||||
// Must include at least one digit.
|
||||
// According to spec tests any decimal point must be followed by a digit.
|
||||
// No leading plus sign is allowed.)
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
|
||||
regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,
|
||||
|
||||
url,
|
||||
descriptors,
|
||||
currentDescriptor,
|
||||
state,
|
||||
c,
|
||||
|
||||
// 2. Let position be a pointer into input, initially pointing at the start
|
||||
// of the string.
|
||||
pos = 0,
|
||||
|
||||
// 3. Let candidates be an initially empty source set.
|
||||
candidates = [];
|
||||
|
||||
// 4. Splitting loop: Collect a sequence of characters that are space
|
||||
// characters or U+002C COMMA characters. If any U+002C COMMA characters
|
||||
// were collected, that is a parse error.
|
||||
while (true) {
|
||||
collectCharacters(regexLeadingCommasOrSpaces);
|
||||
|
||||
// 5. If position is past the end of input, return candidates and abort these steps.
|
||||
if (pos >= inputLength) {
|
||||
return candidates; // (we're done, this is the sole return path)
|
||||
}
|
||||
|
||||
// 6. Collect a sequence of characters that are not space characters,
|
||||
// and let that be url.
|
||||
url = collectCharacters(regexLeadingNotSpaces);
|
||||
|
||||
// 7. Let descriptors be a new empty list.
|
||||
descriptors = [];
|
||||
|
||||
// 8. If url ends with a U+002C COMMA character (,), follow these substeps:
|
||||
// (1). Remove all trailing U+002C COMMA characters from url. If this removed
|
||||
// more than one character, that is a parse error.
|
||||
if (url.slice(-1) === ",") {
|
||||
url = url.replace(regexTrailingCommas, "");
|
||||
// (Jump ahead to step 9 to skip tokenization and just push the candidate).
|
||||
parseDescriptors();
|
||||
|
||||
// Otherwise, follow these substeps:
|
||||
} else {
|
||||
tokenize();
|
||||
} // (close else of step 8)
|
||||
|
||||
// 16. Return to the step labeled splitting loop.
|
||||
} // (Close of big while loop.)
|
||||
|
||||
/**
|
||||
* Tokenizes descriptor properties prior to parsing
|
||||
* Returns undefined.
|
||||
*/
|
||||
function tokenize() {
|
||||
|
||||
// 8.1. Descriptor tokeniser: Skip whitespace
|
||||
collectCharacters(regexLeadingSpaces);
|
||||
|
||||
// 8.2. Let current descriptor be the empty string.
|
||||
currentDescriptor = "";
|
||||
|
||||
// 8.3. Let state be in descriptor.
|
||||
state = "in descriptor";
|
||||
|
||||
while (true) {
|
||||
|
||||
// 8.4. Let c be the character at position.
|
||||
c = input.charAt(pos);
|
||||
|
||||
// Do the following depending on the value of state.
|
||||
// For the purpose of this step, "EOF" is a special character representing
|
||||
// that position is past the end of input.
|
||||
|
||||
// In descriptor
|
||||
if (state === "in descriptor") {
|
||||
// Do the following, depending on the value of c:
|
||||
|
||||
// Space character
|
||||
// If current descriptor is not empty, append current descriptor to
|
||||
// descriptors and let current descriptor be the empty string.
|
||||
// Set state to after descriptor.
|
||||
if (isSpace(c)) {
|
||||
if (currentDescriptor) {
|
||||
descriptors.push(currentDescriptor);
|
||||
currentDescriptor = "";
|
||||
state = "after descriptor";
|
||||
}
|
||||
|
||||
// U+002C COMMA (,)
|
||||
// Advance position to the next character in input. If current descriptor
|
||||
// is not empty, append current descriptor to descriptors. Jump to the step
|
||||
// labeled descriptor parser.
|
||||
} else if (c === ",") {
|
||||
pos += 1;
|
||||
if (currentDescriptor) {
|
||||
descriptors.push(currentDescriptor);
|
||||
}
|
||||
parseDescriptors();
|
||||
return;
|
||||
|
||||
// U+0028 LEFT PARENTHESIS (()
|
||||
// Append c to current descriptor. Set state to in parens.
|
||||
} else if (c === "\u0028") {
|
||||
currentDescriptor = currentDescriptor + c;
|
||||
state = "in parens";
|
||||
|
||||
// EOF
|
||||
// If current descriptor is not empty, append current descriptor to
|
||||
// descriptors. Jump to the step labeled descriptor parser.
|
||||
} else if (c === "") {
|
||||
if (currentDescriptor) {
|
||||
descriptors.push(currentDescriptor);
|
||||
}
|
||||
parseDescriptors();
|
||||
return;
|
||||
|
||||
// Anything else
|
||||
// Append c to current descriptor.
|
||||
} else {
|
||||
currentDescriptor = currentDescriptor + c;
|
||||
}
|
||||
// (end "in descriptor"
|
||||
|
||||
// In parens
|
||||
} else if (state === "in parens") {
|
||||
|
||||
// U+0029 RIGHT PARENTHESIS ())
|
||||
// Append c to current descriptor. Set state to in descriptor.
|
||||
if (c === ")") {
|
||||
currentDescriptor = currentDescriptor + c;
|
||||
state = "in descriptor";
|
||||
|
||||
// EOF
|
||||
// Append current descriptor to descriptors. Jump to the step labeled
|
||||
// descriptor parser.
|
||||
} else if (c === "") {
|
||||
descriptors.push(currentDescriptor);
|
||||
parseDescriptors();
|
||||
return;
|
||||
|
||||
// Anything else
|
||||
// Append c to current descriptor.
|
||||
} else {
|
||||
currentDescriptor = currentDescriptor + c;
|
||||
}
|
||||
|
||||
// After descriptor
|
||||
} else if (state === "after descriptor") {
|
||||
|
||||
// Do the following, depending on the value of c:
|
||||
// Space character: Stay in this state.
|
||||
if (isSpace(c)) {
|
||||
|
||||
// EOF: Jump to the step labeled descriptor parser.
|
||||
} else if (c === "") {
|
||||
parseDescriptors();
|
||||
return;
|
||||
|
||||
// Anything else
|
||||
// Set state to in descriptor. Set position to the previous character in input.
|
||||
} else {
|
||||
state = "in descriptor";
|
||||
pos -= 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Advance position to the next character in input.
|
||||
pos += 1;
|
||||
|
||||
// Repeat this step.
|
||||
} // (close while true loop)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds descriptor properties to a candidate, pushes to the candidates array
|
||||
* @return undefined
|
||||
*/
|
||||
// Declared outside of the while loop so that it's only created once.
|
||||
function parseDescriptors() {
|
||||
|
||||
// 9. Descriptor parser: Let error be no.
|
||||
var pError = false,
|
||||
|
||||
// 10. Let width be absent.
|
||||
// 11. Let density be absent.
|
||||
// 12. Let future-compat-h be absent. (We're implementing it now as h)
|
||||
w, d, h, i,
|
||||
candidate = {},
|
||||
desc, lastChar, value, intVal, floatVal;
|
||||
|
||||
// 13. For each descriptor in descriptors, run the appropriate set of steps
|
||||
// from the following list:
|
||||
for (i = 0 ; i < descriptors.length; i++) {
|
||||
desc = descriptors[ i ];
|
||||
|
||||
lastChar = desc[ desc.length - 1 ];
|
||||
value = desc.substring(0, desc.length - 1);
|
||||
intVal = parseInt(value, 10);
|
||||
floatVal = parseFloat(value);
|
||||
|
||||
// If the descriptor consists of a valid non-negative integer followed by
|
||||
// a U+0077 LATIN SMALL LETTER W character
|
||||
if (regexNonNegativeInteger.test(value) && (lastChar === "w")) {
|
||||
|
||||
// If width and density are not both absent, then let error be yes.
|
||||
if (w || d) {pError = true;}
|
||||
|
||||
// Apply the rules for parsing non-negative integers to the descriptor.
|
||||
// If the result is zero, let error be yes.
|
||||
// Otherwise, let width be the result.
|
||||
if (intVal === 0) {pError = true;} else {w = intVal;}
|
||||
|
||||
// If the descriptor consists of a valid floating-point number followed by
|
||||
// a U+0078 LATIN SMALL LETTER X character
|
||||
} else if (regexFloatingPoint.test(value) && (lastChar === "x")) {
|
||||
|
||||
// If width, density and future-compat-h are not all absent, then let error
|
||||
// be yes.
|
||||
if (w || d || h) {pError = true;}
|
||||
|
||||
// Apply the rules for parsing floating-point number values to the descriptor.
|
||||
// If the result is less than zero, let error be yes. Otherwise, let density
|
||||
// be the result.
|
||||
if (floatVal < 0) {pError = true;} else {d = floatVal;}
|
||||
|
||||
// If the descriptor consists of a valid non-negative integer followed by
|
||||
// a U+0068 LATIN SMALL LETTER H character
|
||||
} else if (regexNonNegativeInteger.test(value) && (lastChar === "h")) {
|
||||
|
||||
// If height and density are not both absent, then let error be yes.
|
||||
if (h || d) {pError = true;}
|
||||
|
||||
// Apply the rules for parsing non-negative integers to the descriptor.
|
||||
// If the result is zero, let error be yes. Otherwise, let future-compat-h
|
||||
// be the result.
|
||||
if (intVal === 0) {pError = true;} else {h = intVal;}
|
||||
|
||||
// Anything else, Let error be yes.
|
||||
} else {pError = true;}
|
||||
} // (close step 13 for loop)
|
||||
|
||||
// 15. If error is still no, then append a new image source to candidates whose
|
||||
// URL is url, associated with a width width if not absent and a pixel
|
||||
// density density if not absent. Otherwise, there is a parse error.
|
||||
if (!pError) {
|
||||
candidate.url = url;
|
||||
if (w) { candidate.w = w;}
|
||||
if (d) { candidate.d = d;}
|
||||
if (h) { candidate.h = h;}
|
||||
candidates.push(candidate);
|
||||
} else if (console && console.log) {
|
||||
console.log("Invalid srcset descriptor found in '" +
|
||||
input + "' at '" + desc + "'.");
|
||||
}
|
||||
} // (close parseDescriptors fn)
|
||||
|
||||
}
|
||||
}));
|
||||
+329
@@ -0,0 +1,329 @@
|
||||
/*! https://mths.be/he v0.5.0 by @mathias | MIT license */
|
||||
;(function(root) {
|
||||
|
||||
// Detect free variables `exports`.
|
||||
var freeExports = typeof exports == 'object' && exports;
|
||||
|
||||
// Detect free variable `module`.
|
||||
var freeModule = typeof module == 'object' && module &&
|
||||
module.exports == freeExports && module;
|
||||
|
||||
// Detect free variable `global`, from Node.js or Browserified code,
|
||||
// and use it as `root`.
|
||||
var freeGlobal = typeof global == 'object' && global;
|
||||
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// All astral symbols.
|
||||
var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
||||
// All ASCII symbols (not just printable ASCII) except those listed in the
|
||||
// first column of the overrides table.
|
||||
// https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides
|
||||
var regexAsciiWhitelist = /[\x01-\x7F]/g;
|
||||
// All BMP symbols that are not ASCII newlines, printable ASCII symbols, or
|
||||
// code points listed in the first column of the overrides table on
|
||||
// https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides.
|
||||
var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
|
||||
|
||||
var regexEncodeNonAscii = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g;
|
||||
var encodeMap = {'\xC1':'Aacute','\xE1':'aacute','\u0102':'Abreve','\u0103':'abreve','\u223E':'ac','\u223F':'acd','\u223E\u0333':'acE','\xC2':'Acirc','\xE2':'acirc','\xB4':'acute','\u0410':'Acy','\u0430':'acy','\xC6':'AElig','\xE6':'aelig','\u2061':'af','\uD835\uDD04':'Afr','\uD835\uDD1E':'afr','\xC0':'Agrave','\xE0':'agrave','\u2135':'aleph','\u0391':'Alpha','\u03B1':'alpha','\u0100':'Amacr','\u0101':'amacr','\u2A3F':'amalg','&':'amp','\u2A55':'andand','\u2A53':'And','\u2227':'and','\u2A5C':'andd','\u2A58':'andslope','\u2A5A':'andv','\u2220':'ang','\u29A4':'ange','\u29A8':'angmsdaa','\u29A9':'angmsdab','\u29AA':'angmsdac','\u29AB':'angmsdad','\u29AC':'angmsdae','\u29AD':'angmsdaf','\u29AE':'angmsdag','\u29AF':'angmsdah','\u2221':'angmsd','\u221F':'angrt','\u22BE':'angrtvb','\u299D':'angrtvbd','\u2222':'angsph','\xC5':'angst','\u237C':'angzarr','\u0104':'Aogon','\u0105':'aogon','\uD835\uDD38':'Aopf','\uD835\uDD52':'aopf','\u2A6F':'apacir','\u2248':'ap','\u2A70':'apE','\u224A':'ape','\u224B':'apid','\'':'apos','\xE5':'aring','\uD835\uDC9C':'Ascr','\uD835\uDCB6':'ascr','\u2254':'colone','*':'ast','\u224D':'CupCap','\xC3':'Atilde','\xE3':'atilde','\xC4':'Auml','\xE4':'auml','\u2233':'awconint','\u2A11':'awint','\u224C':'bcong','\u03F6':'bepsi','\u2035':'bprime','\u223D':'bsim','\u22CD':'bsime','\u2216':'setmn','\u2AE7':'Barv','\u22BD':'barvee','\u2305':'barwed','\u2306':'Barwed','\u23B5':'bbrk','\u23B6':'bbrktbrk','\u0411':'Bcy','\u0431':'bcy','\u201E':'bdquo','\u2235':'becaus','\u29B0':'bemptyv','\u212C':'Bscr','\u0392':'Beta','\u03B2':'beta','\u2136':'beth','\u226C':'twixt','\uD835\uDD05':'Bfr','\uD835\uDD1F':'bfr','\u22C2':'xcap','\u25EF':'xcirc','\u22C3':'xcup','\u2A00':'xodot','\u2A01':'xoplus','\u2A02':'xotime','\u2A06':'xsqcup','\u2605':'starf','\u25BD':'xdtri','\u25B3':'xutri','\u2A04':'xuplus','\u22C1':'Vee','\u22C0':'Wedge','\u290D':'rbarr','\u29EB':'lozf','\u25AA':'squf','\u25B4':'utrif','\u25BE':'dtrif','\u25C2':'ltrif','\u25B8':'rtrif','\u2423':'blank','\u2592':'blk12','\u2591':'blk14','\u2593':'blk34','\u2588':'block','=\u20E5':'bne','\u2261\u20E5':'bnequiv','\u2AED':'bNot','\u2310':'bnot','\uD835\uDD39':'Bopf','\uD835\uDD53':'bopf','\u22A5':'bot','\u22C8':'bowtie','\u29C9':'boxbox','\u2510':'boxdl','\u2555':'boxdL','\u2556':'boxDl','\u2557':'boxDL','\u250C':'boxdr','\u2552':'boxdR','\u2553':'boxDr','\u2554':'boxDR','\u2500':'boxh','\u2550':'boxH','\u252C':'boxhd','\u2564':'boxHd','\u2565':'boxhD','\u2566':'boxHD','\u2534':'boxhu','\u2567':'boxHu','\u2568':'boxhU','\u2569':'boxHU','\u229F':'minusb','\u229E':'plusb','\u22A0':'timesb','\u2518':'boxul','\u255B':'boxuL','\u255C':'boxUl','\u255D':'boxUL','\u2514':'boxur','\u2558':'boxuR','\u2559':'boxUr','\u255A':'boxUR','\u2502':'boxv','\u2551':'boxV','\u253C':'boxvh','\u256A':'boxvH','\u256B':'boxVh','\u256C':'boxVH','\u2524':'boxvl','\u2561':'boxvL','\u2562':'boxVl','\u2563':'boxVL','\u251C':'boxvr','\u255E':'boxvR','\u255F':'boxVr','\u2560':'boxVR','\u02D8':'breve','\xA6':'brvbar','\uD835\uDCB7':'bscr','\u204F':'bsemi','\u29C5':'bsolb','\\':'bsol','\u27C8':'bsolhsub','\u2022':'bull','\u224E':'bump','\u2AAE':'bumpE','\u224F':'bumpe','\u0106':'Cacute','\u0107':'cacute','\u2A44':'capand','\u2A49':'capbrcup','\u2A4B':'capcap','\u2229':'cap','\u22D2':'Cap','\u2A47':'capcup','\u2A40':'capdot','\u2145':'DD','\u2229\uFE00':'caps','\u2041':'caret','\u02C7':'caron','\u212D':'Cfr','\u2A4D':'ccaps','\u010C':'Ccaron','\u010D':'ccaron','\xC7':'Ccedil','\xE7':'ccedil','\u0108':'Ccirc','\u0109':'ccirc','\u2230':'Cconint','\u2A4C':'ccups','\u2A50':'ccupssm','\u010A':'Cdot','\u010B':'cdot','\xB8':'cedil','\u29B2':'cemptyv','\xA2':'cent','\xB7':'middot','\uD835\uDD20':'cfr','\u0427':'CHcy','\u0447':'chcy','\u2713':'check','\u03A7':'Chi','\u03C7':'chi','\u02C6':'circ','\u2257':'cire','\u21BA':'olarr','\u21BB':'orarr','\u229B':'oast','\u229A':'ocir','\u229D':'odash','\u2299':'odot','\xAE':'reg','\u24C8':'oS','\u2296':'ominus','\u2295':'oplus','\u2297':'otimes','\u25CB':'cir','\u29C3':'cirE','\u2A10':'cirfnint','\u2AEF':'cirmid','\u29C2':'cirscir','\u2232':'cwconint','\u201D':'rdquo','\u2019':'rsquo','\u2663':'clubs',':':'colon','\u2237':'Colon','\u2A74':'Colone',',':'comma','@':'commat','\u2201':'comp','\u2218':'compfn','\u2102':'Copf','\u2245':'cong','\u2A6D':'congdot','\u2261':'equiv','\u222E':'oint','\u222F':'Conint','\uD835\uDD54':'copf','\u2210':'coprod','\xA9':'copy','\u2117':'copysr','\u21B5':'crarr','\u2717':'cross','\u2A2F':'Cross','\uD835\uDC9E':'Cscr','\uD835\uDCB8':'cscr','\u2ACF':'csub','\u2AD1':'csube','\u2AD0':'csup','\u2AD2':'csupe','\u22EF':'ctdot','\u2938':'cudarrl','\u2935':'cudarrr','\u22DE':'cuepr','\u22DF':'cuesc','\u21B6':'cularr','\u293D':'cularrp','\u2A48':'cupbrcap','\u2A46':'cupcap','\u222A':'cup','\u22D3':'Cup','\u2A4A':'cupcup','\u228D':'cupdot','\u2A45':'cupor','\u222A\uFE00':'cups','\u21B7':'curarr','\u293C':'curarrm','\u22CE':'cuvee','\u22CF':'cuwed','\xA4':'curren','\u2231':'cwint','\u232D':'cylcty','\u2020':'dagger','\u2021':'DaggerLine truncated
|
||||
|
||||
var regexEscape = /["&'<>`]/g;
|
||||
var escapeMap = {
|
||||
'"': '"',
|
||||
'&': '&',
|
||||
'\'': ''',
|
||||
'<': '<',
|
||||
// See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the
|
||||
// following is not strictly necessary unless it’s part of a tag or an
|
||||
// unquoted attribute value. We’re only escaping it to support those
|
||||
// situations, and for XML support.
|
||||
'>': '>',
|
||||
// In Internet Explorer ≤ 8, the backtick character can be used
|
||||
// to break out of (un)quoted attribute values or HTML comments.
|
||||
// See http://html5sec.org/#102, http://html5sec.org/#108, and
|
||||
// http://html5sec.org/#133.
|
||||
'`': '`'
|
||||
};
|
||||
|
||||
var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
|
||||
var regexInvalidRawCodePoint = /[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
||||
var regexDecode = /&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+);|&(Aacute|iacute|Uacute|plusmn|otilde|Otilde|Agrave|agrave|yacute|Yacute|oslash|Oslash|Atilde|atilde|brvbar|Ccedil|ccedil|ograve|curren|divide|Eacute|eacute|Ograve|oacute|Egrave|egrave|ugrave|frac12|frac14|frac34|Ugrave|Oacute|Iacute|ntilde|Ntilde|uacute|middot|Igrave|igrave|iquest|aacute|laquo|THORN|micro|iexcl|icirc|Icirc|Acirc|ucirc|ecirc|Ocirc|ocirc|Ecirc|Ucirc|aring|Aring|aelig|AElig|acute|pound|raquo|acirc|times|thorn|szlig|cedil|COPY|Auml|ordf|ordm|uuml|macr|Uuml|auml|Ouml|ouml|para|nbsp|Euml|quot|QUOT|euml|yuml|cent|sect|copy|sup1|sup2|sup3|Iuml|iuml|shy|eth|reg|not|yen|amp|AMP|REG|uml|ETH|deg|gt|GT|LT|lt)([=a-zA-Z0-9])?/g;
|
||||
var decodeMap = {'Aacute':'\xC1','aacute':'\xE1','Abreve':'\u0102','abreve':'\u0103','ac':'\u223E','acd':'\u223F','acE':'\u223E\u0333','Acirc':'\xC2','acirc':'\xE2','acute':'\xB4','Acy':'\u0410','acy':'\u0430','AElig':'\xC6','aelig':'\xE6','af':'\u2061','Afr':'\uD835\uDD04','afr':'\uD835\uDD1E','Agrave':'\xC0','agrave':'\xE0','alefsym':'\u2135','aleph':'\u2135','Alpha':'\u0391','alpha':'\u03B1','Amacr':'\u0100','amacr':'\u0101','amalg':'\u2A3F','amp':'&','AMP':'&','andand':'\u2A55','And':'\u2A53','and':'\u2227','andd':'\u2A5C','andslope':'\u2A58','andv':'\u2A5A','ang':'\u2220','ange':'\u29A4','angle':'\u2220','angmsdaa':'\u29A8','angmsdab':'\u29A9','angmsdac':'\u29AA','angmsdad':'\u29AB','angmsdae':'\u29AC','angmsdaf':'\u29AD','angmsdag':'\u29AE','angmsdah':'\u29AF','angmsd':'\u2221','angrt':'\u221F','angrtvb':'\u22BE','angrtvbd':'\u299D','angsph':'\u2222','angst':'\xC5','angzarr':'\u237C','Aogon':'\u0104','aogon':'\u0105','Aopf':'\uD835\uDD38','aopf':'\uD835\uDD52','apacir':'\u2A6F','ap':'\u2248','apE':'\u2A70','ape':'\u224A','apid':'\u224B','apos':'\'','ApplyFunction':'\u2061','approx':'\u2248','approxeq':'\u224A','Aring':'\xC5','aring':'\xE5','Ascr':'\uD835\uDC9C','ascr':'\uD835\uDCB6','Assign':'\u2254','ast':'*','asymp':'\u2248','asympeq':'\u224D','Atilde':'\xC3','atilde':'\xE3','Auml':'\xC4','auml':'\xE4','awconint':'\u2233','awint':'\u2A11','backcong':'\u224C','backepsilon':'\u03F6','backprime':'\u2035','backsim':'\u223D','backsimeq':'\u22CD','Backslash':'\u2216','Barv':'\u2AE7','barvee':'\u22BD','barwed':'\u2305','Barwed':'\u2306','barwedge':'\u2305','bbrk':'\u23B5','bbrktbrk':'\u23B6','bcong':'\u224C','Bcy':'\u0411','bcy':'\u0431','bdquo':'\u201E','becaus':'\u2235','because':'\u2235','Because':'\u2235','bemptyv':'\u29B0','bepsi':'\u03F6','bernou':'\u212C','Bernoullis':'\u212C','Beta':'\u0392','beta':'\u03B2','beth':'\u2136','between':'\u226C','Bfr':'\uD835\uDD05','bfr':'\uD835\uDD1F','bigcap':'\u22C2','bigcirc':'\u25EF','bigcup':'\u22C3','bigodot':'\u2A00','bigoplus':'\u2A01','bigotimes':'\u2A02','bigsqcup':'\u2A06','bigstar':'\u2605','bigtriangledown':'\u25BD','bigtriangleup':'\u25B3','biguplus':'\u2A04','bigvee':'\u22C1','bigwedge':'\u22C0','bkarow':'\u290D','blacklozenge':'\u29EB','blacksquare':'\u25AA','blacktriangle':'\u25B4','blacktriangledown':'\u25BE','blacktriangleleft':'\u25C2','blacktriangleright':'\u25B8','blank':'\u2423','blk12':'\u2592','blk14':'\u2591','blk34':'\u2593','block':'\u2588','bne':'=\u20E5','bnequiv':'\u2261\u20E5','bNot':'\u2AED','bnot':'\u2310','Bopf':'\uD835\uDD39','bopf':'\uD835\uDD53','bot':'\u22A5','bottom':'\u22A5','bowtie':'\u22C8','boxbox':'\u29C9','boxdl':'\u2510','boxdL':'\u2555','boxDl':'\u2556','boxDL':'\u2557','boxdr':'\u250C','boxdR':'\u2552','boxDr':'\u2553','boxDR':'\u2554','boxh':'\u2500','boxH':'\u2550','boxhd':'\u252C','boxHd':'\u2564','boxhD':'\u2565','boxHD':'\u2566','boxhu':'\u2534','boxHu':'\u2567','boxhU':'\u2568','boxHU':'\u2569','boxminus':'\u229F','boxplus':'\u229E','boxtimes':'\u22A0','boxul':'\u2518','boxuL':'\u255B','boxUl':'\u255C','boxUL':'\u255D','boxur':'\u2514','boxuR':'\u2558','boxUr':'\u2559','boxUR':'\u255A','boxv':'\u2502','boxV':'\u2551','boxvh':'\u253C','boxvH':'\u256A','boxVh':'\u256B','boxVH':'\u256C','boxvl':'\u2524','boxvL':'\u2561','boxVl':'\u2562','boxVL':'\u2563','boxvr':'\u251C','boxvR':'\u255E','boxVr':'\u255F','boxVR':'\u2560','bprime':'\u2035','breve':'\u02D8','Breve':'\u02D8','brvbar':'\xA6','bscr':'\uD835\uDCB7','Bscr':'\u212C','bsemi':'\u204F','bsim':'\u223D','bsime':'\u22CD','bsolb':'\u29C5','bsol':'\\','bsolhsub':'\u27C8','bull':'\u2022','bullet':'\u2022','bump':'\u224E','bumpE':'\u2AAE','bumpe':'\u224F','Bumpeq':'\u224E','bumpeq':'\u224F','Cacute':'\u0106','cacute':'\u0107','capand':'\u2A44','capbrcup':'\u2A49','capcap':'\u2A4B','cap':'\u2229','Cap':'\u22D2','capcup':'\u2A47','capdot':'\u2A40','CapitalDifferentialD':'\u2145','caps':'\u2229\uFE00','caret':'\u2041','caron':'\u02C7','Cayleys':'\u212D','ccaps':'\u2A4D','Ccaron':'\u010C','ccaron':'\u010D','Ccedil':'\xC7','ccedil':'\xE7','Ccirc':'\u0108','ccirc':'\u0109','Cconint':'\u2230','ccups':'\u2A4C','ccupssm':'\u2A50','Cdot':'\u010A','cdot':'\u010B','cedil':'\xB8','Cedilla':'\xB8','cemptyv':'\u29B2','cent':'\xA2','centerdot':'\xB7','CenterDot':'\xB7','cfr':'\uD835\uDD20','Cfr':'\u212D','CHcy':'\u0427','chcy':'\u0447','check':'\u2713','checkmark':'\u2713','Chi':'\u03A7','chi':'\u03C7','circ':'\u02C6','circeq':'\u2257','circlearrowleft':'\u21BA','circlearrowright':'\u21BB','circledast':'\u229B','circledcirc':'\u229A','circleddash':'\u229D','CircleDot':'\u2299','circledR':'\xAE','circledS':'\u24C8','CircleMinus':'\u2296','CirclePlus':'\u2295','CircleTimes':'\u2297','cir':'\u25CB','cirE':'\u29C3','cire':'\u2257','cirfnint':'\u2A10','cirmid':'\u2AEF','cirscir':'\u29C2','ClockwiseContourIntegral':'\u2232','CloseCurlyDoubleQuote':'\u201D','CloseCurlyQuote':'\u2019','clubs':'\u2663','clubsuit':'\u2663','colon':':','Colon':'\u2237','Colone':'\u2A74','colone':'\u2254','colLine truncated
|
||||
var decodeMapLegacy = {'Aacute':'\xC1','aacute':'\xE1','Acirc':'\xC2','acirc':'\xE2','acute':'\xB4','AElig':'\xC6','aelig':'\xE6','Agrave':'\xC0','agrave':'\xE0','amp':'&','AMP':'&','Aring':'\xC5','aring':'\xE5','Atilde':'\xC3','atilde':'\xE3','Auml':'\xC4','auml':'\xE4','brvbar':'\xA6','Ccedil':'\xC7','ccedil':'\xE7','cedil':'\xB8','cent':'\xA2','copy':'\xA9','COPY':'\xA9','curren':'\xA4','deg':'\xB0','divide':'\xF7','Eacute':'\xC9','eacute':'\xE9','Ecirc':'\xCA','ecirc':'\xEA','Egrave':'\xC8','egrave':'\xE8','ETH':'\xD0','eth':'\xF0','Euml':'\xCB','euml':'\xEB','frac12':'\xBD','frac14':'\xBC','frac34':'\xBE','gt':'>','GT':'>','Iacute':'\xCD','iacute':'\xED','Icirc':'\xCE','icirc':'\xEE','iexcl':'\xA1','Igrave':'\xCC','igrave':'\xEC','iquest':'\xBF','Iuml':'\xCF','iuml':'\xEF','laquo':'\xAB','lt':'<','LT':'<','macr':'\xAF','micro':'\xB5','middot':'\xB7','nbsp':'\xA0','not':'\xAC','Ntilde':'\xD1','ntilde':'\xF1','Oacute':'\xD3','oacute':'\xF3','Ocirc':'\xD4','ocirc':'\xF4','Ograve':'\xD2','ograve':'\xF2','ordf':'\xAA','ordm':'\xBA','Oslash':'\xD8','oslash':'\xF8','Otilde':'\xD5','otilde':'\xF5','Ouml':'\xD6','ouml':'\xF6','para':'\xB6','plusmn':'\xB1','pound':'\xA3','quot':'"','QUOT':'"','raquo':'\xBB','reg':'\xAE','REG':'\xAE','sect':'\xA7','shy':'\xAD','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','szlig':'\xDF','THORN':'\xDE','thorn':'\xFE','times':'\xD7','Uacute':'\xDA','uacute':'\xFA','Ucirc':'\xDB','ucirc':'\xFB','Ugrave':'\xD9','ugrave':'\xF9','uml':'\xA8','Uuml':'\xDC','uuml':'\xFC','Yacute':'\xDD','yacute':'\xFD','yen':'\xA5','yuml':'\xFF'};
|
||||
var decodeMapNumeric = {'0':'\uFFFD','128':'\u20AC','130':'\u201A','131':'\u0192','132':'\u201E','133':'\u2026','134':'\u2020','135':'\u2021','136':'\u02C6','137':'\u2030','138':'\u0160','139':'\u2039','140':'\u0152','142':'\u017D','145':'\u2018','146':'\u2019','147':'\u201C','148':'\u201D','149':'\u2022','150':'\u2013','151':'\u2014','152':'\u02DC','153':'\u2122','154':'\u0161','155':'\u203A','156':'\u0153','158':'\u017E','159':'\u0178'};
|
||||
var invalidReferenceCodePoints = [1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65000,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111];
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
var stringFromCharCode = String.fromCharCode;
|
||||
|
||||
var object = {};
|
||||
var hasOwnProperty = object.hasOwnProperty;
|
||||
var has = function(object, propertyName) {
|
||||
return hasOwnProperty.call(object, propertyName);
|
||||
};
|
||||
|
||||
var contains = function(array, value) {
|
||||
var index = -1;
|
||||
var length = array.length;
|
||||
while (++index < length) {
|
||||
if (array[index] == value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
var merge = function(options, defaults) {
|
||||
if (!options) {
|
||||
return defaults;
|
||||
}
|
||||
var result = {};
|
||||
var key;
|
||||
for (key in defaults) {
|
||||
// A `hasOwnProperty` check is not needed here, since only recognized
|
||||
// option names are used anyway. Any others are ignored.
|
||||
result[key] = has(options, key) ? options[key] : defaults[key];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// Modified version of `ucs2encode`; see https://mths.be/punycode.
|
||||
var codePointToSymbol = function(codePoint, strict) {
|
||||
var output = '';
|
||||
if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
|
||||
// See issue #4:
|
||||
// “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
|
||||
// greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
|
||||
// REPLACEMENT CHARACTER.”
|
||||
if (strict) {
|
||||
parseError('character reference outside the permissible Unicode range');
|
||||
}
|
||||
return '\uFFFD';
|
||||
}
|
||||
if (has(decodeMapNumeric, codePoint)) {
|
||||
if (strict) {
|
||||
parseError('disallowed character reference');
|
||||
}
|
||||
return decodeMapNumeric[codePoint];
|
||||
}
|
||||
if (strict && contains(invalidReferenceCodePoints, codePoint)) {
|
||||
parseError('disallowed character reference');
|
||||
}
|
||||
if (codePoint > 0xFFFF) {
|
||||
codePoint -= 0x10000;
|
||||
output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
|
||||
codePoint = 0xDC00 | codePoint & 0x3FF;
|
||||
}
|
||||
output += stringFromCharCode(codePoint);
|
||||
return output;
|
||||
};
|
||||
|
||||
var hexEscape = function(symbol) {
|
||||
return '&#x' + symbol.charCodeAt(0).toString(16).toUpperCase() + ';';
|
||||
};
|
||||
|
||||
var parseError = function(message) {
|
||||
throw Error('Parse error: ' + message);
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
var encode = function(string, options) {
|
||||
options = merge(options, encode.options);
|
||||
var strict = options.strict;
|
||||
if (strict && regexInvalidRawCodePoint.test(string)) {
|
||||
parseError('forbidden code point');
|
||||
}
|
||||
var encodeEverything = options.encodeEverything;
|
||||
var useNamedReferences = options.useNamedReferences;
|
||||
var allowUnsafeSymbols = options.allowUnsafeSymbols;
|
||||
if (encodeEverything) {
|
||||
// Encode ASCII symbols.
|
||||
string = string.replace(regexAsciiWhitelist, function(symbol) {
|
||||
// Use named references if requested & possible.
|
||||
if (useNamedReferences && has(encodeMap, symbol)) {
|
||||
return '&' + encodeMap[symbol] + ';';
|
||||
}
|
||||
return hexEscape(symbol);
|
||||
});
|
||||
// Shorten a few escapes that represent two symbols, of which at least one
|
||||
// is within the ASCII range.
|
||||
if (useNamedReferences) {
|
||||
string = string
|
||||
.replace(/>\u20D2/g, '>⃒')
|
||||
.replace(/<\u20D2/g, '<⃒')
|
||||
.replace(/fj/g, 'fj');
|
||||
}
|
||||
// Encode non-ASCII symbols.
|
||||
if (useNamedReferences) {
|
||||
// Encode non-ASCII symbols that can be replaced with a named reference.
|
||||
string = string.replace(regexEncodeNonAscii, function(string) {
|
||||
// Note: there is no need to check `has(encodeMap, string)` here.
|
||||
return '&' + encodeMap[string] + ';';
|
||||
});
|
||||
}
|
||||
// Note: any remaining non-ASCII symbols are handled outside of the `if`.
|
||||
} else if (useNamedReferences) {
|
||||
// Apply named character references.
|
||||
// Encode `<>"'&` using named character references.
|
||||
if (!allowUnsafeSymbols) {
|
||||
string = string.replace(regexEscape, function(string) {
|
||||
return '&' + encodeMap[string] + ';'; // no need to check `has()` here
|
||||
});
|
||||
}
|
||||
// Shorten escapes that represent two symbols, of which at least one is
|
||||
// `<>"'&`.
|
||||
string = string
|
||||
.replace(/>\u20D2/g, '>⃒')
|
||||
.replace(/<\u20D2/g, '<⃒');
|
||||
// Encode non-ASCII symbols that can be replaced with a named reference.
|
||||
string = string.replace(regexEncodeNonAscii, function(string) {
|
||||
// Note: there is no need to check `has(encodeMap, string)` here.
|
||||
return '&' + encodeMap[string] + ';';
|
||||
});
|
||||
} else if (!allowUnsafeSymbols) {
|
||||
// Encode `<>"'&` using hexadecimal escapes, now that they’re not handled
|
||||
// using named character references.
|
||||
string = string.replace(regexEscape, hexEscape);
|
||||
}
|
||||
return string
|
||||
// Encode astral symbols.
|
||||
.replace(regexAstralSymbols, function($0) {
|
||||
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
||||
var high = $0.charCodeAt(0);
|
||||
var low = $0.charCodeAt(1);
|
||||
var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
|
||||
return '&#x' + codePoint.toString(16).toUpperCase() + ';';
|
||||
})
|
||||
// Encode any remaining BMP symbols that are not printable ASCII symbols
|
||||
// using a hexadecimal escape.
|
||||
.replace(regexBmpWhitelist, hexEscape);
|
||||
};
|
||||
// Expose default options (so they can be overridden globally).
|
||||
encode.options = {
|
||||
'allowUnsafeSymbols': false,
|
||||
'encodeEverything': false,
|
||||
'strict': false,
|
||||
'useNamedReferences': false
|
||||
};
|
||||
|
||||
var decode = function(html, options) {
|
||||
options = merge(options, decode.options);
|
||||
var strict = options.strict;
|
||||
if (strict && regexInvalidEntity.test(html)) {
|
||||
parseError('malformed character reference');
|
||||
}
|
||||
return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7) {
|
||||
var codePoint;
|
||||
var semicolon;
|
||||
var hexDigits;
|
||||
var reference;
|
||||
var next;
|
||||
if ($1) {
|
||||
// Decode decimal escapes, e.g. `𝌆`.
|
||||
codePoint = $1;
|
||||
semicolon = $2;
|
||||
if (strict && !semicolon) {
|
||||
parseError('character reference was not terminated by a semicolon');
|
||||
}
|
||||
return codePointToSymbol(codePoint, strict);
|
||||
}
|
||||
if ($3) {
|
||||
// Decode hexadecimal escapes, e.g. `𝌆`.
|
||||
hexDigits = $3;
|
||||
semicolon = $4;
|
||||
if (strict && !semicolon) {
|
||||
parseError('character reference was not terminated by a semicolon');
|
||||
}
|
||||
codePoint = parseInt(hexDigits, 16);
|
||||
return codePointToSymbol(codePoint, strict);
|
||||
}
|
||||
if ($5) {
|
||||
// Decode named character references with trailing `;`, e.g. `©`.
|
||||
reference = $5;
|
||||
if (has(decodeMap, reference)) {
|
||||
return decodeMap[reference];
|
||||
} else {
|
||||
// Ambiguous ampersand. https://mths.be/notes/ambiguous-ampersands
|
||||
if (strict) {
|
||||
parseError(
|
||||
'named character reference was not terminated by a semicolon'
|
||||
);
|
||||
}
|
||||
return $0;
|
||||
}
|
||||
}
|
||||
// If we’re still here, it’s a legacy reference for sure. No need for an
|
||||
// extra `if` check.
|
||||
// Decode named character references without trailing `;`, e.g. `&`
|
||||
// This is only a parse error if it gets converted to `&`, or if it is
|
||||
// followed by `=` in an attribute context.
|
||||
reference = $6;
|
||||
next = $7;
|
||||
if (next && options.isAttributeValue) {
|
||||
if (strict && next == '=') {
|
||||
parseError('`&` did not start a character reference');
|
||||
}
|
||||
return $0;
|
||||
} else {
|
||||
if (strict) {
|
||||
parseError(
|
||||
'named character reference was not terminated by a semicolon'
|
||||
);
|
||||
}
|
||||
// Note: there is no need to check `has(decodeMapLegacy, reference)`.
|
||||
return decodeMapLegacy[reference] + (next || '');
|
||||
}
|
||||
});
|
||||
};
|
||||
// Expose default options (so they can be overridden globally).
|
||||
decode.options = {
|
||||
'isAttributeValue': false,
|
||||
'strict': false
|
||||
};
|
||||
|
||||
var escape = function(string) {
|
||||
return string.replace(regexEscape, function($0) {
|
||||
// Note: there is no need to check `has(escapeMap, $0)` here.
|
||||
return escapeMap[$0];
|
||||
});
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
var he = {
|
||||
'version': '0.5.0',
|
||||
'encode': encode,
|
||||
'decode': decode,
|
||||
'escape': escape,
|
||||
'unescape': decode
|
||||
};
|
||||
|
||||
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
||||
// like the following:
|
||||
if (
|
||||
typeof define == 'function' &&
|
||||
typeof define.amd == 'object' &&
|
||||
define.amd
|
||||
) {
|
||||
define(function() {
|
||||
return he;
|
||||
});
|
||||
} else if (freeExports && !freeExports.nodeType) {
|
||||
if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
|
||||
freeModule.exports = he;
|
||||
} else { // in Narwhal or RingoJS v0.7.0-
|
||||
for (var key in he) {
|
||||
has(he, key) && (freeExports[key] = he[key]);
|
||||
}
|
||||
}
|
||||
} else { // in Rhino or a web browser
|
||||
root.he = he;
|
||||
}
|
||||
|
||||
}(this));
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
// Learn more about configuring this file at
|
||||
// <https://github.com/theintern/intern/wiki/Configuring-Intern>.
|
||||
// These default settings work OK for most people. The options that *must* be
|
||||
// changed below are the packages, suites, excludeInstrumentation, and (if you
|
||||
// want functional tests) functionalSuites.
|
||||
|
||||
define({
|
||||
// The port on which the instrumenting proxy will listen
|
||||
proxyPort: 9000,
|
||||
|
||||
// A fully qualified URL to the Intern proxy
|
||||
proxyUrl: 'http://localhost:9000/',
|
||||
|
||||
// Default desired capabilities for all environments. Individual capabilities
|
||||
// can be overridden by any of the specified browser environments in the
|
||||
// `environments` array below as well. See
|
||||
// https://code.google.com/p/selenium/wiki/DesiredCapabilities
|
||||
// for standard Selenium capabilities and
|
||||
// https://saucelabs.com/docs/additional-config#desired-capabilities
|
||||
// for Sauce Labs capabilities.
|
||||
// Note that the `build` capability will be filled in with the current commit
|
||||
// ID from the Travis CI environment
|
||||
// automatically
|
||||
capabilities: {
|
||||
'selenium-version': '2.41.0'
|
||||
},
|
||||
|
||||
// Browsers to run integration testing against. Note that version numbers must
|
||||
// be strings if used with Sauce OnDemand. Options that will be permutated are
|
||||
// browserName, version, platform, and platformVersion; any other capabilities
|
||||
// options specified for an environment will be copied as-is.
|
||||
environments: [
|
||||
{ browserName: 'internet explorer', version: '11', platform: 'Windows 8.1' },
|
||||
{ browserName: 'internet explorer', version: '10', platform: 'Windows 8' },
|
||||
{ browserName: 'internet explorer', version: '9', platform: 'Windows 7' },
|
||||
{ browserName: 'firefox', version: '28', platform: [ 'OS X 10.9', 'Windows 7', 'Linux' ] },
|
||||
{ browserName: 'chrome', version: '34', platform: [ 'OS X 10.9', 'Windows 7', 'Linux' ] },
|
||||
{ browserName: 'safari', version: '6', platform: 'OS X 10.8' },
|
||||
{ browserName: 'safari', version: '7', platform: 'OS X 10.9' }
|
||||
],
|
||||
|
||||
// Maximum number of simultaneous integration tests that should be executed on
|
||||
// the remote WebDriver service.
|
||||
maxConcurrency: 3,
|
||||
|
||||
// Name of the tunnel class to use for WebDriver tests
|
||||
tunnel: 'SauceLabsTunnel',
|
||||
|
||||
// The desired AMD loader to use when running unit tests (client.html/client.js).
|
||||
// Omit to use the default Dojo loader.
|
||||
useLoader: {
|
||||
'host-node': 'dojo/dojo',
|
||||
'host-browser': 'node_modules/dojo/dojo.js'
|
||||
},
|
||||
|
||||
// Configuration options for the module loader; any AMD configuration options
|
||||
// supported by the specified AMD loader can be used here.
|
||||
loader: {
|
||||
// Packages that should be registered with the loader in each testing environment
|
||||
packages: [
|
||||
{ name: 'app', location: 'src/' },
|
||||
{ name: 'tests', location: 'tests/' }
|
||||
]
|
||||
},
|
||||
|
||||
// Non-functional test suite(s) to run in each browser
|
||||
suites: [ 'tests/unit/ps' ],
|
||||
|
||||
// Functional test suite(s) to run in each browser once non-functional tests are completed
|
||||
functionalSuites: [ /* 'myPackage/tests/functional' */ ],
|
||||
|
||||
// A regular expression matching URLs to files that should not be included in code coverage analysis
|
||||
excludeInstrumentation: /^(?:tests|node_modules)\//
|
||||
});
|
||||
+345
@@ -0,0 +1,345 @@
|
||||
define(function (require) {
|
||||
var tdd = require('intern!tdd');
|
||||
|
||||
// Not really Chai but a Chai-compatible "assert" library for old IE.
|
||||
var assert = require('intern/chai!assert');
|
||||
|
||||
// parse-srcset is an AMD module.
|
||||
var parseSrcset = require('../../src/parse-srcset');
|
||||
|
||||
var he = require('tests/he');
|
||||
|
||||
tdd.suite('Parse Srcset', function() {
|
||||
|
||||
// Adapted from the W3C srcset conformance checker at:
|
||||
// http://w3c-test.org/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html
|
||||
var w3Ctests = [
|
||||
{
|
||||
groupName: "Splitting Loop",
|
||||
testArray: [
|
||||
{srcset: '', expect: '', desc: 'empty string'},
|
||||
{srcset: ',' , expect: '', desc: 'single comma'},
|
||||
{srcset: ',,,', expect: '', desc: 'three commas'},
|
||||
{srcset: '		data:,a		1x		', expect: 'data:,a', desc: 'tabs'},
|
||||
{srcset: '

data:,a

1x

', expect: 'data:,a', desc: 'line feeds'},
|
||||
{srcset: 'data:,a1x', expect: 'data:,a1x', desc: 'line tab'},
|
||||
{srcset: 'data:,a1x', expect: 'data:,a', desc: 'form feed U+000C'},
|
||||
{srcset: '

data:,a

1x

', expect: 'data:,a', desc: 'carriage return U+000D'},
|
||||
{srcset: 'data:,a1x', expect: 'data:,a1x', desc: 'shift out U+000E'},
|
||||
{srcset: 'data:,a1x', expect: 'data:,a1x', desc: 'shift in U+000F' },
|
||||
{srcset: 'data:,a1x', expect: 'data:,a1x', desc: 'data link escape U+0010' },
|
||||
{srcset: 'data:,a', expect: 'data:,a', desc:'plain url'},
|
||||
{srcset: 'data:,a ', expect: 'data:,a', desc:'trailing space'},
|
||||
{srcset: 'data:,a ,', expect: 'data:,a', desc:'trailing space and comma'},
|
||||
{srcset: 'data:,a,', expect: 'data:,a', desc:'trailing comma'},
|
||||
{srcset: 'data:,a, ', expect: 'data:,a', desc:'trailing comma and space'},
|
||||
{srcset: 'data:,a,,,', expect: 'data:,a', desc:'trailing three commas'},
|
||||
{srcset: 'data:,a,, , ', expect: 'data:,a', desc:'trailing two commas space comma space'},
|
||||
{srcset: ' data:,a', expect: 'data:,a', desc:'leading space'},
|
||||
{srcset: ',,,data:,a', expect: 'data:,a', desc:'leading three commas'},
|
||||
{srcset: ' , ,,data:,a', expect: 'data:,a', desc:'leading space comma space comma comma'},
|
||||
{srcset: ' data:,a', expect: ' data:,a', desc:'leading non-breaking space'},
|
||||
{srcset: 'data:,a ', expect: 'data:,a ', desc:'trailing non-breaking space'}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
groupName: "Descriptor Tokenizer",
|
||||
testArray: [
|
||||
{srcset: 'data:,a 1x', expect: 'data:,a', desc: 'plain url with descriptor'},
|
||||
{srcset: 'data:,a 1x ', expect: 'data:,a', desc: 'trailing space'},
|
||||
{srcset: 'data:,a 1x,', expect: 'data:,a', desc: 'trailing comma'},
|
||||
{srcset: 'data:,a ( , data:,b 1x, ), data:,c', expect: 'data:,c', desc: 'irregular parens 1'},
|
||||
{srcset: 'data:,a ((( , data:,b 1x, ), data:,c', expect: 'data:,c', desc: 'irregular parens 2'},
|
||||
{srcset: 'data:,a [ , data:,b 1x, ], data:,c', expect: 'data:,b', desc: 'brackets'},
|
||||
{srcset: 'data:,a { , data:,b 1x, }, data:,c', expect: 'data:,b', desc: 'braces'},
|
||||
{srcset: 'data:,a " , data:,b 1x, ", data:,c', expect: 'data:,b', desc: 'double quotes'},
|
||||
{srcset: 'data:,a \\,data:;\\,b, data:,c', expect: 'data:;\\,b', desc: 'backslashes'},
|
||||
{srcset: 'data:,a, data:,b (', expect: 'data:,a', desc: 'trailing unclosed paren'},
|
||||
{srcset: 'data:,a, data:,b ( ', expect: 'data:,a', desc: 'unclosed paren space'},
|
||||
{srcset: 'data:,a, data:,b (,', expect: 'data:,a', desc: 'unclosed paren comma'},
|
||||
{srcset: 'data:,a, data:,b (x', expect: 'data:,a', desc: 'unclosed paren x'},
|
||||
{srcset: 'data:,a, data:,b ()', expect: 'data:,a', desc: 'parens, no descriptor'},
|
||||
{srcset: 'data:,a (, data:,b', expect: '', desc: 'unclosed paren'},
|
||||
{srcset: 'data:,a /*, data:,b, data:,c */', expect: 'data:,b', desc: 'block comments'},
|
||||
{srcset: 'data:,a //, data:,b', expect: 'data:,b', desc: 'double slash like a comment'}
|
||||
]
|
||||
},
|
||||
|
||||
{ groupName: "Descriptor Parser",
|
||||
testArray : [
|
||||
{srcset: 'data:,a foo', expect: '', desc: 'trailing foo'},
|
||||
{srcset: 'data:,a foo foo', expect: '', desc: 'trailing foo foo'},
|
||||
{srcset: 'data:,a foo 1x', expect: '', desc: 'trailing foo 1x'},
|
||||
{srcset: 'data:,a foo 1x foo', expect: '', desc: 'trailing 1x foo'},
|
||||
{srcset: 'data:,a foo 1w', expect: '', desc: 'trailing foo 1w'},
|
||||
{srcset: 'data:,a foo 1w foo', expect: '', desc: 'trailing foo 1w foo'},
|
||||
{srcset: 'data:,a 1x 1x', expect: '', desc: 'two density descriptors'},
|
||||
{srcset: 'data:,a 1w 1w', expect: '', desc: 'two width descriptors'},
|
||||
{srcset: 'data:,a 1h 1h', expect: '', desc: 'two height descriptors'},
|
||||
{srcset: 'data:,a 1w 1x', expect: '', desc: 'width then density'},
|
||||
{srcset: 'data:,a 1x 1w', expect: '', desc: 'density then width'},
|
||||
{srcset: 'data:,a 1w 1h', expect: 'data:,a', desc: 'width then height'},
|
||||
{srcset: 'data:,a 1h 1w', expect: 'data:,a', desc: 'height then width'},
|
||||
{srcset: 'data:,a 1h 1x', expect: '', desc: 'height then density'},
|
||||
{srcset: 'data:,a 1h 1w 1x', expect: '', desc: 'height then width then density'},
|
||||
{srcset: 'data:,a 1x 1w 1h', expect: '', desc: 'density then width then height'},
|
||||
{srcset: 'data:,a 1h foo', expect: '', desc: 'trailing 1h foo'},
|
||||
{srcset: 'data:,a foo 1h', expect: '', desc: 'trailing foo 1h'},
|
||||
{srcset: 'data:,a 0w', expect: '', desc: 'zero width'},
|
||||
{srcset: 'data:,a -1w', expect: '', desc: 'negative width'},
|
||||
{srcset: 'data:,a 1w -1w', expect: '', desc: 'positive width, negative width'},
|
||||
{srcset: 'data:,a 1.0w', expect: '', desc: 'floating point width'},
|
||||
{srcset: 'data:,a 1w 1.0w', expect: '', desc: 'integer width, floating point width'},
|
||||
{srcset: 'data:,a 1e0w', expect: '', desc: 'exponent width'},
|
||||
{srcset: 'data:,a 1w 1e0w', expect: '', desc: 'integer width, exponent width'},
|
||||
{srcset: 'data:,a 1www', expect: '', desc: '1www'},
|
||||
{srcset: 'data:,a 1w 1www', expect: '', desc: '1w 1www'},
|
||||
{srcset: 'data:,a 1w +1w', expect: '', desc: '1w +1w'},
|
||||
{srcset: 'data:,a 1W', expect: '', desc: 'capital W descriptor'},
|
||||
{srcset: 'data:,a 1w 1W', expect: '', desc: 'lowercase w, capital W descriptors'},
|
||||
{srcset: 'data:,a Infinityw', expect: '', desc: 'Infinityw'},
|
||||
{srcset: 'data:,a 1w Infinityw', expect: '', desc: '1w Infinityw'},
|
||||
{srcset: 'data:,a NaNw', expect: '', desc: 'Nanw'},
|
||||
{srcset: 'data:,a 1w NaNw', expect: '', desc: '1w Nanw'},
|
||||
{srcset: 'data:,a 0x1w', expect: '', desc: 'ox1w'},
|
||||
{srcset: 'data:,a 1w', expect: '', desc: 'trailing U+0001'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+00A0'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+1680'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2000'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2001'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2002'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2003'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2004'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2005'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2006'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2007'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2008'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2009'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+200A'},
|
||||
{srcset: 'data:,a 1‌w', expect: '', desc: 'trailing U+200C'},
|
||||
{srcset: 'data:,a 1‍w', expect: '', desc: 'trailing U+200D'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+202F'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+205F'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+3000'},
|
||||
{srcset: 'data:,a 1w', expect: '', desc: 'trailing U+FEFF'},
|
||||
{srcset: 'data:,a 1w' , expect: '', desc: 'leading U+0001'},
|
||||
// {srcset: 'data:,a 1w' , expect: '', desc: 'leading U+00A0 width'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+1680'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2000'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2001'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2002'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2003'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2004'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2005'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2006'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2007'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2008'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2009'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+200A'},
|
||||
{srcset: 'data:,a ‌1w', expect: '', desc: 'leading U+200C'},
|
||||
{srcset: 'data:,a ‍1w', expect: '', desc: 'leading U+200D'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+202F'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+205F'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+3000'},
|
||||
{srcset: 'data:,a 1w', expect: '', desc: 'leading U+FEFF'},
|
||||
{srcset: 'data:,a 0x', expect: 'data:,a', desc: 'zero density'},
|
||||
{srcset: 'data:,a -0x' , expect: 'data:,a', desc: 'negative zero density'},
|
||||
{srcset: 'data:,a 1x -0x', expect: '', desc: '1x -0x'},
|
||||
{srcset: 'data:,a -1x', expect: '', desc: '-1x'},
|
||||
{srcset: 'data:,a 1x -1x', expect: '', desc: '1x -1x'},
|
||||
{srcset: 'data:,a 1e0x', expect: 'data:,a', desc: '1e0x'},
|
||||
{srcset: 'data:,a 1E0x', expect: 'data:,a', desc: '1E0x'},
|
||||
{srcset: 'data:,a 1e-1x', expect: 'data:,a', desc: '1e-1x'},
|
||||
{srcset: 'data:,a 1.5e1x', expect: 'data:,a', desc: '1.5e1x'},
|
||||
{srcset: 'data:,a -x', expect: '', desc: 'negative density with no digits'},
|
||||
{srcset: 'data:,a .x', expect: '', desc: 'decimal density with no digits'},
|
||||
{srcset: 'data:,a -.x', expect: '', desc: '-.x'},
|
||||
{srcset: 'data:,a 1.x', expect: '', desc: '1.x'},
|
||||
{srcset: 'data:,a .5x', expect: 'data:,a', desc: 'floating point density descriptor'},
|
||||
{srcset: 'data:,a .5e1x', expect: 'data:,a', desc: '.5e1x'},
|
||||
{srcset: 'data:,a 1x 1.5e1x', expect: '', desc: '1x 1.5e1x'},
|
||||
{srcset: 'data:,a 1x 1e1.5x', expect: '', desc: '1x 1e1.5x'},
|
||||
{srcset: 'data:,a 1.0x', expect: 'data:,a', desc: '1.0x'},
|
||||
{srcset: 'data:,a 1x 1.0x', expect: '', desc: '1x 1.0x'},
|
||||
{srcset: 'data:,a +1x', expect: '', desc: 'no plus sign allowed on floating point number'},
|
||||
{srcset: 'data:,a 1X', expect: '', desc: 'Capital X descriptor'},
|
||||
{srcset: 'data:,a Infinityx', expect: '', desc: 'Infinityx'},
|
||||
{srcset: 'data:,a NaNx', expect: '', desc: 'NaNx'},
|
||||
{srcset: 'data:,a 0x1x', expect: '', desc: '0X1x'},
|
||||
{srcset: 'data:,a 0X1x', expect: '', desc: '1x'},
|
||||
{srcset: 'data:,a 1x', expect: '', desc: 'trailing U+0001'},
|
||||
{srcset: 'data:,a 1 x' , expect: '', desc: 'trailing U+00A0 density'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+1680'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2000'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2001'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2002'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2003'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2004'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2005'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2006'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2007'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2008'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2009'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+200A'},
|
||||
{srcset: 'data:,a 1‌x', expect: '', desc: 'trailing U+200C'},
|
||||
{srcset: 'data:,a 1‍x', expect: '', desc: 'trailing U+200D'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+202F'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+205F'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+3000'},
|
||||
{srcset: 'data:,a 1x', expect: '', desc: 'trailing U+FEFF'},
|
||||
{srcset: 'data:,a 1x' , expect: '', desc: 'leading U+0001'},
|
||||
{srcset: 'data:,a 1x' , expect: '', desc: 'leading U+00A0 density'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+1680'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2000'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2001'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2002'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2003'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2004'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2005'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2006'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2007'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2008'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2009'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+200A'},
|
||||
{srcset: 'data:,a ‌1x', expect: '', desc: 'leading U+200C'},
|
||||
{srcset: 'data:,a ‍1x', expect: '', desc: 'leading U+200D'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+202F'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+205F'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+3000'},
|
||||
{srcset: 'data:,a 1x', expect: '', desc: 'leading U+FEFF'},
|
||||
{srcset: 'data:,a 1w 0h', expect: '', desc: '1w 0h'},
|
||||
{srcset: 'data:,a 1w -1h', expect: '', desc: '1w -1h'},
|
||||
{srcset: 'data:,a 1w 1.0h', expect: '', desc: '1w 1.0h'},
|
||||
{srcset: 'data:,a 1w 1e0h', expect: '', desc: '1w 1e0h'},
|
||||
{srcset: 'data:,a 1w 1hhh', expect: '', desc: '1w 1hhh'},
|
||||
{srcset: 'data:,a 1w 1H', expect: '', desc: '1w 1H'},
|
||||
{srcset: 'data:,a 1w Infinityh', expect: '', desc: '1w Infinityh'},
|
||||
{srcset: 'data:,a 1w NaNh', expect: '', desc: '1w NaNh'},
|
||||
{srcset: 'data:,a 0x1h', expect: '', desc: '0x1h'},
|
||||
{srcset: 'data:,a 0X1h', expect: '', desc: '0X1h'},
|
||||
{srcset: 'data:,a 1w 1h', expect: '', desc: 'trailing U+0001'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+00A0'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+1680'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2000'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2001'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2002'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2003'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2004'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2005'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2006'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2007'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2008'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2009'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+200A'},
|
||||
{srcset: 'data:,a 1w 1‌h', expect: '', desc: 'trailing U+200C'},
|
||||
{srcset: 'data:,a 1w 1‍h', expect: '', desc: 'trailing U+200D'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+202F'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+205F'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+3000'},
|
||||
{srcset: 'data:,a 1w 1h', expect: '', desc: 'trailing U+FEFF'},
|
||||
{srcset: 'data:,a 1w 1h', expect: '', desc: 'leading U+0001'},
|
||||
{srcset: 'data:,a 1w 1h', expect: '', desc: 'leading U+00A0'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+1680'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2000'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2001'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2002'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2003'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2004'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2005'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2006'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2007'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2008'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2009'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+200A'},
|
||||
{srcset: 'data:,a 1w ‌1h', expect: '', desc: 'leading U+200C'},
|
||||
{srcset: 'data:,a 1w ‍1h', expect: '', desc: 'leading U+200D'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+202F'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+205F'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+3000'},
|
||||
{srcset: 'data:,a 1w 1h', expect: '', desc: 'leading U+FEFF'}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// HTML Entities are much easier to troubleshoot in console.
|
||||
he.encode.options.useNamedReferences = true;
|
||||
|
||||
function runTest(test) {
|
||||
var origAttr = test.srcset;
|
||||
var attrDecoded = he.decode(origAttr);
|
||||
var parsed = parseSrcset(attrDecoded);
|
||||
|
||||
var firstCandidate = parsed[0];
|
||||
|
||||
var url = "";
|
||||
var encodedUrl = "";
|
||||
|
||||
if (firstCandidate) {
|
||||
url = firstCandidate.url;
|
||||
}
|
||||
|
||||
// Must re-encode url prior to comparison with expected string.
|
||||
if (url) {
|
||||
encodedUrl = he.encode(url);
|
||||
}
|
||||
|
||||
console.log("");
|
||||
console.log(test.desc);
|
||||
console.log("origAttr: '" + origAttr + "'");
|
||||
console.log("attrDecoded: '" + attrDecoded + "'");
|
||||
console.log("parsed: ", parsed);
|
||||
console.log("url: '" + url + "'");
|
||||
console.log("encodedUrl: '" + encodedUrl + "'");
|
||||
|
||||
|
||||
tdd.test( test.desc , function() {
|
||||
assert.strictEqual(encodedUrl, test.expect, "passed" );
|
||||
});
|
||||
}
|
||||
|
||||
function runTestGroup(testGroup) {
|
||||
var j;
|
||||
var testArray = testGroup.testArray;
|
||||
|
||||
// Group Tests
|
||||
tdd.suite(testGroup.groupName, function() {
|
||||
|
||||
for (j = 0; j < testArray.length; j++) {
|
||||
runTest(testArray[j]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var i;
|
||||
var w3CtestsLength = w3Ctests.length;
|
||||
|
||||
for (i = 0; i < w3CtestsLength; i++) {
|
||||
runTestGroup(w3Ctests[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// tdd.test('First Test', function () {
|
||||
// var parsed = parseSrcset('data:,a 1x');
|
||||
// var url = parsed[0].url;
|
||||
//
|
||||
// console.log("parsed: ", parsed);
|
||||
// console.log("url: ", url);
|
||||
//
|
||||
// assert.strictEqual(parsed, parsed, 'should be');
|
||||
//
|
||||
// // assert.strictEqual(url, 'data:,a', 'should be');
|
||||
// });
|
||||
|
||||
// assert.strictEqual(parseSrcset('data:,a 1x')[0], 'data:,a', 'plain url with descriptor');
|
||||
|
||||
// tdd.test('Second Test', function () {
|
||||
// assert.strictEqual(5, 5, '5 is itself, right?');
|
||||
// });
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user