1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-03 12:20:04 +02:00

update node modules

This commit is contained in:
s2
2019-03-29 15:56:41 +01:00
parent f114871153
commit 89c32fb4e6
8347 changed files with 390123 additions and 159877 deletions

19
node_modules/parse5/LICENSE generated vendored
View File

@@ -1,19 +0,0 @@
Copyright (c) 2013-2016 Ivan Nikulin (ifaaan@gmail.com, https://github.com/inikulin)
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.

42
node_modules/parse5/README.md generated vendored
View File

@@ -4,31 +4,29 @@
</a>
</p>
<div align="center">
<h1>parse5</h1>
<i><b>HTML parser and serializer.</b></i>
</div>
<br>
<div align="center">
<code>npm install --save parse5</code>
</div>
<br>
<p align="center">
<i>HTML parsing/serialization toolset for Node.js. <a href="https://html.spec.whatwg.org/multipage/">WHATWG HTML Living Standard (aka HTML5)</a>-compliant.</i>
📖 <a href="https://github.com/inikulin/parse5/tree/master/packages/parse5/docs/index.md"><b>Documentation</b></a> 📖
</p>
---
<p align="center">
<a href="https://github.com/inikulin/parse5/tree/master/docs/list-of-packages.md">List of parse5 toolset packages</a>
</p>
<p align="center">
<a href="https://travis-ci.org/inikulin/parse5"><img alt="Build Status" src="https://api.travis-ci.org/inikulin/parse5.svg"></a>
<a href="https://www.npmjs.com/package/parse5"><img alt="NPM Version" src="https://img.shields.io/npm/v/parse5.svg"></a>
<a href="https://npmjs.org/package/parse5"><img alt="Downloads" src="http://img.shields.io/npm/dm/parse5.svg"></a>
<a href="https://npmjs.org/package/parse5"><img alt="Downloads total" src="http://img.shields.io/npm/dt/parse5.svg"></a>
</p>
<p align="center">
<b><i>parse5</i></b> provides nearly everything you may need when dealing with HTML. It's the fastest spec-compliant HTML parser
for Node to date. It parses HTML the way the latest version of your browser does. It has proven itself reliable in such projects
as <a href="https://github.com/tmpvar/jsdom">jsdom</a>, <a href="https://github.com/angular/angular">Angular2</a>, <a href="https://www.polymer-project.org">Polymer</a> and many more.
</p>
----
<p align="center">
<a href="http://inikulin.github.io/parse5">Documentation</a>
</p>
<p align="center">
<a href="http://inikulin.github.io/parse5#version-history">Version history</a>
<a href="https://github.com/inikulin/parse5">GitHub</a>
</p>
<p align="center">
@@ -36,5 +34,5 @@ as <a href="https://github.com/tmpvar/jsdom">jsdom</a>, <a href="https://github.
</p>
<p align="center">
<a href="https://github.com/inikulin/parse5/issues">Issue tracker</a>
<a href="https://github.com/inikulin/parse5/tree/master/docs/version-history.md">Version history</a>
</p>

View File

@@ -1,156 +1,173 @@
'use strict';
var DOCUMENT_MODE = require('./html').DOCUMENT_MODE;
const { DOCUMENT_MODE } = require('./html');
//Const
var VALID_DOCTYPE_NAME = 'html',
QUIRKS_MODE_SYSTEM_ID = 'http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd',
QUIRKS_MODE_PUBLIC_ID_PREFIXES = [
'+//silmaril//dtd html pro v0r11 19970101//en',
'-//advasoft ltd//dtd html 3.0 aswedit + extensions//en',
'-//as//dtd html 3.0 aswedit + extensions//en',
'-//ietf//dtd html 2.0 level 1//en',
'-//ietf//dtd html 2.0 level 2//en',
'-//ietf//dtd html 2.0 strict level 1//en',
'-//ietf//dtd html 2.0 strict level 2//en',
'-//ietf//dtd html 2.0 strict//en',
'-//ietf//dtd html 2.0//en',
'-//ietf//dtd html 2.1e//en',
'-//ietf//dtd html 3.0//en',
'-//ietf//dtd html 3.0//en//',
'-//ietf//dtd html 3.2 final//en',
'-//ietf//dtd html 3.2//en',
'-//ietf//dtd html 3//en',
'-//ietf//dtd html level 0//en',
'-//ietf//dtd html level 0//en//2.0',
'-//ietf//dtd html level 1//en',
'-//ietf//dtd html level 1//en//2.0',
'-//ietf//dtd html level 2//en',
'-//ietf//dtd html level 2//en//2.0',
'-//ietf//dtd html level 3//en',
'-//ietf//dtd html level 3//en//3.0',
'-//ietf//dtd html strict level 0//en',
'-//ietf//dtd html strict level 0//en//2.0',
'-//ietf//dtd html strict level 1//en',
'-//ietf//dtd html strict level 1//en//2.0',
'-//ietf//dtd html strict level 2//en',
'-//ietf//dtd html strict level 2//en//2.0',
'-//ietf//dtd html strict level 3//en',
'-//ietf//dtd html strict level 3//en//3.0',
'-//ietf//dtd html strict//en',
'-//ietf//dtd html strict//en//2.0',
'-//ietf//dtd html strict//en//3.0',
'-//ietf//dtd html//en',
'-//ietf//dtd html//en//2.0',
'-//ietf//dtd html//en//3.0',
'-//metrius//dtd metrius presentational//en',
'-//microsoft//dtd internet explorer 2.0 html strict//en',
'-//microsoft//dtd internet explorer 2.0 html//en',
'-//microsoft//dtd internet explorer 2.0 tables//en',
'-//microsoft//dtd internet explorer 3.0 html strict//en',
'-//microsoft//dtd internet explorer 3.0 html//en',
'-//microsoft//dtd internet explorer 3.0 tables//en',
'-//netscape comm. corp.//dtd html//en',
'-//netscape comm. corp.//dtd strict html//en',
'-//o\'reilly and associates//dtd html 2.0//en',
'-//o\'reilly and associates//dtd html extended 1.0//en',
'-//spyglass//dtd html 2.0 extended//en',
'-//sq//dtd html 2.0 hotmetal + extensions//en',
'-//sun microsystems corp.//dtd hotjava html//en',
'-//sun microsystems corp.//dtd hotjava strict html//en',
'-//w3c//dtd html 3 1995-03-24//en',
'-//w3c//dtd html 3.2 draft//en',
'-//w3c//dtd html 3.2 final//en',
'-//w3c//dtd html 3.2//en',
'-//w3c//dtd html 3.2s draft//en',
'-//w3c//dtd html 4.0 frameset//en',
'-//w3c//dtd html 4.0 transitional//en',
'-//w3c//dtd html experimental 19960712//en',
'-//w3c//dtd html experimental 970421//en',
'-//w3c//dtd w3 html//en',
'-//w3o//dtd w3 html 3.0//en',
'-//w3o//dtd w3 html 3.0//en//',
'-//webtechs//dtd mozilla html 2.0//en',
'-//webtechs//dtd mozilla html//en'
],
QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES = QUIRKS_MODE_PUBLIC_ID_PREFIXES.concat([
'-//w3c//dtd html 4.01 frameset//',
'-//w3c//dtd html 4.01 transitional//'
]),
QUIRKS_MODE_PUBLIC_IDS = [
'-//w3o//dtd w3 html strict 3.0//en//',
'-/w3c/dtd html 4.0 transitional/en',
'html'
],
LIMITED_QUIRKS_PUBLIC_ID_PREFIXES = [
'-//W3C//DTD XHTML 1.0 Frameset//',
'-//W3C//DTD XHTML 1.0 Transitional//'
],
LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES = LIMITED_QUIRKS_PUBLIC_ID_PREFIXES.concat([
'-//W3C//DTD HTML 4.01 Frameset//',
'-//W3C//DTD HTML 4.01 Transitional//'
]);
const VALID_DOCTYPE_NAME = 'html';
const VALID_SYSTEM_ID = 'about:legacy-compat';
const QUIRKS_MODE_SYSTEM_ID = 'http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd';
const QUIRKS_MODE_PUBLIC_ID_PREFIXES = [
'+//silmaril//dtd html pro v0r11 19970101//en',
'-//advasoft ltd//dtd html 3.0 aswedit + extensions//en',
'-//as//dtd html 3.0 aswedit + extensions//en',
'-//ietf//dtd html 2.0 level 1//en',
'-//ietf//dtd html 2.0 level 2//en',
'-//ietf//dtd html 2.0 strict level 1//en',
'-//ietf//dtd html 2.0 strict level 2//en',
'-//ietf//dtd html 2.0 strict//en',
'-//ietf//dtd html 2.0//en',
'-//ietf//dtd html 2.1e//en',
'-//ietf//dtd html 3.0//en',
'-//ietf//dtd html 3.0//en//',
'-//ietf//dtd html 3.2 final//en',
'-//ietf//dtd html 3.2//en',
'-//ietf//dtd html 3//en',
'-//ietf//dtd html level 0//en',
'-//ietf//dtd html level 0//en//2.0',
'-//ietf//dtd html level 1//en',
'-//ietf//dtd html level 1//en//2.0',
'-//ietf//dtd html level 2//en',
'-//ietf//dtd html level 2//en//2.0',
'-//ietf//dtd html level 3//en',
'-//ietf//dtd html level 3//en//3.0',
'-//ietf//dtd html strict level 0//en',
'-//ietf//dtd html strict level 0//en//2.0',
'-//ietf//dtd html strict level 1//en',
'-//ietf//dtd html strict level 1//en//2.0',
'-//ietf//dtd html strict level 2//en',
'-//ietf//dtd html strict level 2//en//2.0',
'-//ietf//dtd html strict level 3//en',
'-//ietf//dtd html strict level 3//en//3.0',
'-//ietf//dtd html strict//en',
'-//ietf//dtd html strict//en//2.0',
'-//ietf//dtd html strict//en//3.0',
'-//ietf//dtd html//en',
'-//ietf//dtd html//en//2.0',
'-//ietf//dtd html//en//3.0',
'-//metrius//dtd metrius presentational//en',
'-//microsoft//dtd internet explorer 2.0 html strict//en',
'-//microsoft//dtd internet explorer 2.0 html//en',
'-//microsoft//dtd internet explorer 2.0 tables//en',
'-//microsoft//dtd internet explorer 3.0 html strict//en',
'-//microsoft//dtd internet explorer 3.0 html//en',
'-//microsoft//dtd internet explorer 3.0 tables//en',
'-//netscape comm. corp.//dtd html//en',
'-//netscape comm. corp.//dtd strict html//en',
"-//o'reilly and associates//dtd html 2.0//en",
"-//o'reilly and associates//dtd html extended 1.0//en",
'-//spyglass//dtd html 2.0 extended//en',
'-//sq//dtd html 2.0 hotmetal + extensions//en',
'-//sun microsystems corp.//dtd hotjava html//en',
'-//sun microsystems corp.//dtd hotjava strict html//en',
'-//w3c//dtd html 3 1995-03-24//en',
'-//w3c//dtd html 3.2 draft//en',
'-//w3c//dtd html 3.2 final//en',
'-//w3c//dtd html 3.2//en',
'-//w3c//dtd html 3.2s draft//en',
'-//w3c//dtd html 4.0 frameset//en',
'-//w3c//dtd html 4.0 transitional//en',
'-//w3c//dtd html experimental 19960712//en',
'-//w3c//dtd html experimental 970421//en',
'-//w3c//dtd w3 html//en',
'-//w3o//dtd w3 html 3.0//en',
'-//w3o//dtd w3 html 3.0//en//',
'-//webtechs//dtd mozilla html 2.0//en',
'-//webtechs//dtd mozilla html//en'
];
const QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES = QUIRKS_MODE_PUBLIC_ID_PREFIXES.concat([
'-//w3c//dtd html 4.01 frameset//',
'-//w3c//dtd html 4.01 transitional//'
]);
const QUIRKS_MODE_PUBLIC_IDS = ['-//w3o//dtd w3 html strict 3.0//en//', '-/w3c/dtd html 4.0 transitional/en', 'html'];
const LIMITED_QUIRKS_PUBLIC_ID_PREFIXES = ['-//W3C//DTD XHTML 1.0 Frameset//', '-//W3C//DTD XHTML 1.0 Transitional//'];
const LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES = LIMITED_QUIRKS_PUBLIC_ID_PREFIXES.concat([
'-//W3C//DTD HTML 4.01 Frameset//',
'-//W3C//DTD HTML 4.01 Transitional//'
]);
//Utils
function enquoteDoctypeId(id) {
var quote = id.indexOf('"') !== -1 ? '\'' : '"';
const quote = id.indexOf('"') !== -1 ? "'" : '"';
return quote + id + quote;
}
function hasPrefix(publicId, prefixes) {
for (var i = 0; i < prefixes.length; i++) {
if (publicId.indexOf(prefixes[i]) === 0)
for (let i = 0; i < prefixes.length; i++) {
if (publicId.indexOf(prefixes[i]) === 0) {
return true;
}
}
return false;
}
//API
exports.getDocumentMode = function (name, publicId, systemId) {
if (name !== VALID_DOCTYPE_NAME)
return DOCUMENT_MODE.QUIRKS;
exports.isConforming = function(token) {
return (
token.name === VALID_DOCTYPE_NAME &&
token.publicId === null &&
(token.systemId === null || token.systemId === VALID_SYSTEM_ID)
);
};
if (systemId && systemId.toLowerCase() === QUIRKS_MODE_SYSTEM_ID)
exports.getDocumentMode = function(token) {
if (token.name !== VALID_DOCTYPE_NAME) {
return DOCUMENT_MODE.QUIRKS;
}
const systemId = token.systemId;
if (systemId && systemId.toLowerCase() === QUIRKS_MODE_SYSTEM_ID) {
return DOCUMENT_MODE.QUIRKS;
}
let publicId = token.publicId;
if (publicId !== null) {
publicId = publicId.toLowerCase();
if (QUIRKS_MODE_PUBLIC_IDS.indexOf(publicId) > -1)
if (QUIRKS_MODE_PUBLIC_IDS.indexOf(publicId) > -1) {
return DOCUMENT_MODE.QUIRKS;
}
var prefixes = systemId === null ? QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES : QUIRKS_MODE_PUBLIC_ID_PREFIXES;
let prefixes = systemId === null ? QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES : QUIRKS_MODE_PUBLIC_ID_PREFIXES;
if (hasPrefix(publicId, prefixes))
if (hasPrefix(publicId, prefixes)) {
return DOCUMENT_MODE.QUIRKS;
}
prefixes = systemId === null ? LIMITED_QUIRKS_PUBLIC_ID_PREFIXES : LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES;
prefixes =
systemId === null ? LIMITED_QUIRKS_PUBLIC_ID_PREFIXES : LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES;
if (hasPrefix(publicId, prefixes))
if (hasPrefix(publicId, prefixes)) {
return DOCUMENT_MODE.LIMITED_QUIRKS;
}
}
return DOCUMENT_MODE.NO_QUIRKS;
};
exports.serializeContent = function (name, publicId, systemId) {
var str = '!DOCTYPE ';
exports.serializeContent = function(name, publicId, systemId) {
let str = '!DOCTYPE ';
if (name)
if (name) {
str += name;
}
if (publicId !== null)
if (publicId) {
str += ' PUBLIC ' + enquoteDoctypeId(publicId);
else if (systemId !== null)
} else if (systemId) {
str += ' SYSTEM';
}
if (systemId !== null)
if (systemId !== null) {
str += ' ' + enquoteDoctypeId(systemId);
}
return str;
};

65
node_modules/parse5/lib/common/error-codes.js generated vendored Normal file
View File

@@ -0,0 +1,65 @@
'use strict';
module.exports = {
controlCharacterInInputStream: 'control-character-in-input-stream',
noncharacterInInputStream: 'noncharacter-in-input-stream',
surrogateInInputStream: 'surrogate-in-input-stream',
nonVoidHtmlElementStartTagWithTrailingSolidus: 'non-void-html-element-start-tag-with-trailing-solidus',
endTagWithAttributes: 'end-tag-with-attributes',
endTagWithTrailingSolidus: 'end-tag-with-trailing-solidus',
unexpectedSolidusInTag: 'unexpected-solidus-in-tag',
unexpectedNullCharacter: 'unexpected-null-character',
unexpectedQuestionMarkInsteadOfTagName: 'unexpected-question-mark-instead-of-tag-name',
invalidFirstCharacterOfTagName: 'invalid-first-character-of-tag-name',
unexpectedEqualsSignBeforeAttributeName: 'unexpected-equals-sign-before-attribute-name',
missingEndTagName: 'missing-end-tag-name',
unexpectedCharacterInAttributeName: 'unexpected-character-in-attribute-name',
unknownNamedCharacterReference: 'unknown-named-character-reference',
missingSemicolonAfterCharacterReference: 'missing-semicolon-after-character-reference',
unexpectedCharacterAfterDoctypeSystemIdentifier: 'unexpected-character-after-doctype-system-identifier',
unexpectedCharacterInUnquotedAttributeValue: 'unexpected-character-in-unquoted-attribute-value',
eofBeforeTagName: 'eof-before-tag-name',
eofInTag: 'eof-in-tag',
missingAttributeValue: 'missing-attribute-value',
missingWhitespaceBetweenAttributes: 'missing-whitespace-between-attributes',
missingWhitespaceAfterDoctypePublicKeyword: 'missing-whitespace-after-doctype-public-keyword',
missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:
'missing-whitespace-between-doctype-public-and-system-identifiers',
missingWhitespaceAfterDoctypeSystemKeyword: 'missing-whitespace-after-doctype-system-keyword',
missingQuoteBeforeDoctypePublicIdentifier: 'missing-quote-before-doctype-public-identifier',
missingQuoteBeforeDoctypeSystemIdentifier: 'missing-quote-before-doctype-system-identifier',
missingDoctypePublicIdentifier: 'missing-doctype-public-identifier',
missingDoctypeSystemIdentifier: 'missing-doctype-system-identifier',
abruptDoctypePublicIdentifier: 'abrupt-doctype-public-identifier',
abruptDoctypeSystemIdentifier: 'abrupt-doctype-system-identifier',
cdataInHtmlContent: 'cdata-in-html-content',
incorrectlyOpenedComment: 'incorrectly-opened-comment',
eofInScriptHtmlCommentLikeText: 'eof-in-script-html-comment-like-text',
eofInDoctype: 'eof-in-doctype',
nestedComment: 'nested-comment',
abruptClosingOfEmptyComment: 'abrupt-closing-of-empty-comment',
eofInComment: 'eof-in-comment',
incorrectlyClosedComment: 'incorrectly-closed-comment',
eofInCdata: 'eof-in-cdata',
absenceOfDigitsInNumericCharacterReference: 'absence-of-digits-in-numeric-character-reference',
nullCharacterReference: 'null-character-reference',
surrogateCharacterReference: 'surrogate-character-reference',
characterReferenceOutsideUnicodeRange: 'character-reference-outside-unicode-range',
controlCharacterReference: 'control-character-reference',
noncharacterCharacterReference: 'noncharacter-character-reference',
missingWhitespaceBeforeDoctypeName: 'missing-whitespace-before-doctype-name',
missingDoctypeName: 'missing-doctype-name',
invalidCharacterSequenceAfterDoctypeName: 'invalid-character-sequence-after-doctype-name',
duplicateAttribute: 'duplicate-attribute',
nonConformingDoctype: 'non-conforming-doctype',
missingDoctype: 'missing-doctype',
misplacedDoctype: 'misplaced-doctype',
endTagWithoutMatchingOpenElement: 'end-tag-without-matching-open-element',
closingOfElementWithOpenChildElements: 'closing-of-element-with-open-child-elements',
disallowedContentInNoscriptInHead: 'disallowed-content-in-noscript-in-head',
openElementsLeftAfterEof: 'open-elements-left-after-eof',
abandonedHeadElementChild: 'abandoned-head-element-child',
misplacedStartTagForHeadElement: 'misplaced-start-tag-for-head-element',
nestedNoscriptInHead: 'nested-noscript-in-head',
eofInElementThatCanContainOnlyText: 'eof-in-element-that-can-contain-only-text'
};

265
node_modules/parse5/lib/common/foreign-content.js generated vendored Normal file
View File

@@ -0,0 +1,265 @@
'use strict';
const Tokenizer = require('../tokenizer');
const HTML = require('./html');
//Aliases
const $ = HTML.TAG_NAMES;
const NS = HTML.NAMESPACES;
const ATTRS = HTML.ATTRS;
//MIME types
const MIME_TYPES = {
TEXT_HTML: 'text/html',
APPLICATION_XML: 'application/xhtml+xml'
};
//Attributes
const DEFINITION_URL_ATTR = 'definitionurl';
const ADJUSTED_DEFINITION_URL_ATTR = 'definitionURL';
const SVG_ATTRS_ADJUSTMENT_MAP = {
attributename: 'attributeName',
attributetype: 'attributeType',
basefrequency: 'baseFrequency',
baseprofile: 'baseProfile',
calcmode: 'calcMode',
clippathunits: 'clipPathUnits',
diffuseconstant: 'diffuseConstant',
edgemode: 'edgeMode',
filterunits: 'filterUnits',
glyphref: 'glyphRef',
gradienttransform: 'gradientTransform',
gradientunits: 'gradientUnits',
kernelmatrix: 'kernelMatrix',
kernelunitlength: 'kernelUnitLength',
keypoints: 'keyPoints',
keysplines: 'keySplines',
keytimes: 'keyTimes',
lengthadjust: 'lengthAdjust',
limitingconeangle: 'limitingConeAngle',
markerheight: 'markerHeight',
markerunits: 'markerUnits',
markerwidth: 'markerWidth',
maskcontentunits: 'maskContentUnits',
maskunits: 'maskUnits',
numoctaves: 'numOctaves',
pathlength: 'pathLength',
patterncontentunits: 'patternContentUnits',
patterntransform: 'patternTransform',
patternunits: 'patternUnits',
pointsatx: 'pointsAtX',
pointsaty: 'pointsAtY',
pointsatz: 'pointsAtZ',
preservealpha: 'preserveAlpha',
preserveaspectratio: 'preserveAspectRatio',
primitiveunits: 'primitiveUnits',
refx: 'refX',
refy: 'refY',
repeatcount: 'repeatCount',
repeatdur: 'repeatDur',
requiredextensions: 'requiredExtensions',
requiredfeatures: 'requiredFeatures',
specularconstant: 'specularConstant',
specularexponent: 'specularExponent',
spreadmethod: 'spreadMethod',
startoffset: 'startOffset',
stddeviation: 'stdDeviation',
stitchtiles: 'stitchTiles',
surfacescale: 'surfaceScale',
systemlanguage: 'systemLanguage',
tablevalues: 'tableValues',
targetx: 'targetX',
targety: 'targetY',
textlength: 'textLength',
viewbox: 'viewBox',
viewtarget: 'viewTarget',
xchannelselector: 'xChannelSelector',
ychannelselector: 'yChannelSelector',
zoomandpan: 'zoomAndPan'
};
const XML_ATTRS_ADJUSTMENT_MAP = {
'xlink:actuate': { prefix: 'xlink', name: 'actuate', namespace: NS.XLINK },
'xlink:arcrole': { prefix: 'xlink', name: 'arcrole', namespace: NS.XLINK },
'xlink:href': { prefix: 'xlink', name: 'href', namespace: NS.XLINK },
'xlink:role': { prefix: 'xlink', name: 'role', namespace: NS.XLINK },
'xlink:show': { prefix: 'xlink', name: 'show', namespace: NS.XLINK },
'xlink:title': { prefix: 'xlink', name: 'title', namespace: NS.XLINK },
'xlink:type': { prefix: 'xlink', name: 'type', namespace: NS.XLINK },
'xml:base': { prefix: 'xml', name: 'base', namespace: NS.XML },
'xml:lang': { prefix: 'xml', name: 'lang', namespace: NS.XML },
'xml:space': { prefix: 'xml', name: 'space', namespace: NS.XML },
xmlns: { prefix: '', name: 'xmlns', namespace: NS.XMLNS },
'xmlns:xlink': { prefix: 'xmlns', name: 'xlink', namespace: NS.XMLNS }
};
//SVG tag names adjustment map
const SVG_TAG_NAMES_ADJUSTMENT_MAP = (exports.SVG_TAG_NAMES_ADJUSTMENT_MAP = {
altglyph: 'altGlyph',
altglyphdef: 'altGlyphDef',
altglyphitem: 'altGlyphItem',
animatecolor: 'animateColor',
animatemotion: 'animateMotion',
animatetransform: 'animateTransform',
clippath: 'clipPath',
feblend: 'feBlend',
fecolormatrix: 'feColorMatrix',
fecomponenttransfer: 'feComponentTransfer',
fecomposite: 'feComposite',
feconvolvematrix: 'feConvolveMatrix',
fediffuselighting: 'feDiffuseLighting',
fedisplacementmap: 'feDisplacementMap',
fedistantlight: 'feDistantLight',
feflood: 'feFlood',
fefunca: 'feFuncA',
fefuncb: 'feFuncB',
fefuncg: 'feFuncG',
fefuncr: 'feFuncR',
fegaussianblur: 'feGaussianBlur',
feimage: 'feImage',
femerge: 'feMerge',
femergenode: 'feMergeNode',
femorphology: 'feMorphology',
feoffset: 'feOffset',
fepointlight: 'fePointLight',
fespecularlighting: 'feSpecularLighting',
fespotlight: 'feSpotLight',
fetile: 'feTile',
feturbulence: 'feTurbulence',
foreignobject: 'foreignObject',
glyphref: 'glyphRef',
lineargradient: 'linearGradient',
radialgradient: 'radialGradient',
textpath: 'textPath'
});
//Tags that causes exit from foreign content
const EXITS_FOREIGN_CONTENT = {
[$.B]: true,
[$.BIG]: true,
[$.BLOCKQUOTE]: true,
[$.BODY]: true,
[$.BR]: true,
[$.CENTER]: true,
[$.CODE]: true,
[$.DD]: true,
[$.DIV]: true,
[$.DL]: true,
[$.DT]: true,
[$.EM]: true,
[$.EMBED]: true,
[$.H1]: true,
[$.H2]: true,
[$.H3]: true,
[$.H4]: true,
[$.H5]: true,
[$.H6]: true,
[$.HEAD]: true,
[$.HR]: true,
[$.I]: true,
[$.IMG]: true,
[$.LI]: true,
[$.LISTING]: true,
[$.MENU]: true,
[$.META]: true,
[$.NOBR]: true,
[$.OL]: true,
[$.P]: true,
[$.PRE]: true,
[$.RUBY]: true,
[$.S]: true,
[$.SMALL]: true,
[$.SPAN]: true,
[$.STRONG]: true,
[$.STRIKE]: true,
[$.SUB]: true,
[$.SUP]: true,
[$.TABLE]: true,
[$.TT]: true,
[$.U]: true,
[$.UL]: true,
[$.VAR]: true
};
//Check exit from foreign content
exports.causesExit = function(startTagToken) {
const tn = startTagToken.tagName;
const isFontWithAttrs =
tn === $.FONT &&
(Tokenizer.getTokenAttr(startTagToken, ATTRS.COLOR) !== null ||
Tokenizer.getTokenAttr(startTagToken, ATTRS.SIZE) !== null ||
Tokenizer.getTokenAttr(startTagToken, ATTRS.FACE) !== null);
return isFontWithAttrs ? true : EXITS_FOREIGN_CONTENT[tn];
};
//Token adjustments
exports.adjustTokenMathMLAttrs = function(token) {
for (let i = 0; i < token.attrs.length; i++) {
if (token.attrs[i].name === DEFINITION_URL_ATTR) {
token.attrs[i].name = ADJUSTED_DEFINITION_URL_ATTR;
break;
}
}
};
exports.adjustTokenSVGAttrs = function(token) {
for (let i = 0; i < token.attrs.length; i++) {
const adjustedAttrName = SVG_ATTRS_ADJUSTMENT_MAP[token.attrs[i].name];
if (adjustedAttrName) {
token.attrs[i].name = adjustedAttrName;
}
}
};
exports.adjustTokenXMLAttrs = function(token) {
for (let i = 0; i < token.attrs.length; i++) {
const adjustedAttrEntry = XML_ATTRS_ADJUSTMENT_MAP[token.attrs[i].name];
if (adjustedAttrEntry) {
token.attrs[i].prefix = adjustedAttrEntry.prefix;
token.attrs[i].name = adjustedAttrEntry.name;
token.attrs[i].namespace = adjustedAttrEntry.namespace;
}
}
};
exports.adjustTokenSVGTagName = function(token) {
const adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP[token.tagName];
if (adjustedTagName) {
token.tagName = adjustedTagName;
}
};
//Integration points
function isMathMLTextIntegrationPoint(tn, ns) {
return ns === NS.MATHML && (tn === $.MI || tn === $.MO || tn === $.MN || tn === $.MS || tn === $.MTEXT);
}
function isHtmlIntegrationPoint(tn, ns, attrs) {
if (ns === NS.MATHML && tn === $.ANNOTATION_XML) {
for (let i = 0; i < attrs.length; i++) {
if (attrs[i].name === ATTRS.ENCODING) {
const value = attrs[i].value.toLowerCase();
return value === MIME_TYPES.TEXT_HTML || value === MIME_TYPES.APPLICATION_XML;
}
}
}
return ns === NS.SVG && (tn === $.FOREIGN_OBJECT || tn === $.DESC || tn === $.TITLE);
}
exports.isIntegrationPoint = function(tn, ns, attrs, foreignNS) {
if ((!foreignNS || foreignNS === NS.HTML) && isHtmlIntegrationPoint(tn, ns, attrs)) {
return true;
}
if ((!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns)) {
return true;
}
return false;
};

View File

@@ -1,260 +0,0 @@
'use strict';
var Tokenizer = require('../tokenizer'),
HTML = require('./html');
//Aliases
var $ = HTML.TAG_NAMES,
NS = HTML.NAMESPACES,
ATTRS = HTML.ATTRS;
//MIME types
var MIME_TYPES = {
TEXT_HTML: 'text/html',
APPLICATION_XML: 'application/xhtml+xml'
};
//Attributes
var DEFINITION_URL_ATTR = 'definitionurl',
ADJUSTED_DEFINITION_URL_ATTR = 'definitionURL',
SVG_ATTRS_ADJUSTMENT_MAP = {
'attributename': 'attributeName',
'attributetype': 'attributeType',
'basefrequency': 'baseFrequency',
'baseprofile': 'baseProfile',
'calcmode': 'calcMode',
'clippathunits': 'clipPathUnits',
'diffuseconstant': 'diffuseConstant',
'edgemode': 'edgeMode',
'filterunits': 'filterUnits',
'glyphref': 'glyphRef',
'gradienttransform': 'gradientTransform',
'gradientunits': 'gradientUnits',
'kernelmatrix': 'kernelMatrix',
'kernelunitlength': 'kernelUnitLength',
'keypoints': 'keyPoints',
'keysplines': 'keySplines',
'keytimes': 'keyTimes',
'lengthadjust': 'lengthAdjust',
'limitingconeangle': 'limitingConeAngle',
'markerheight': 'markerHeight',
'markerunits': 'markerUnits',
'markerwidth': 'markerWidth',
'maskcontentunits': 'maskContentUnits',
'maskunits': 'maskUnits',
'numoctaves': 'numOctaves',
'pathlength': 'pathLength',
'patterncontentunits': 'patternContentUnits',
'patterntransform': 'patternTransform',
'patternunits': 'patternUnits',
'pointsatx': 'pointsAtX',
'pointsaty': 'pointsAtY',
'pointsatz': 'pointsAtZ',
'preservealpha': 'preserveAlpha',
'preserveaspectratio': 'preserveAspectRatio',
'primitiveunits': 'primitiveUnits',
'refx': 'refX',
'refy': 'refY',
'repeatcount': 'repeatCount',
'repeatdur': 'repeatDur',
'requiredextensions': 'requiredExtensions',
'requiredfeatures': 'requiredFeatures',
'specularconstant': 'specularConstant',
'specularexponent': 'specularExponent',
'spreadmethod': 'spreadMethod',
'startoffset': 'startOffset',
'stddeviation': 'stdDeviation',
'stitchtiles': 'stitchTiles',
'surfacescale': 'surfaceScale',
'systemlanguage': 'systemLanguage',
'tablevalues': 'tableValues',
'targetx': 'targetX',
'targety': 'targetY',
'textlength': 'textLength',
'viewbox': 'viewBox',
'viewtarget': 'viewTarget',
'xchannelselector': 'xChannelSelector',
'ychannelselector': 'yChannelSelector',
'zoomandpan': 'zoomAndPan'
},
XML_ATTRS_ADJUSTMENT_MAP = {
'xlink:actuate': {prefix: 'xlink', name: 'actuate', namespace: NS.XLINK},
'xlink:arcrole': {prefix: 'xlink', name: 'arcrole', namespace: NS.XLINK},
'xlink:href': {prefix: 'xlink', name: 'href', namespace: NS.XLINK},
'xlink:role': {prefix: 'xlink', name: 'role', namespace: NS.XLINK},
'xlink:show': {prefix: 'xlink', name: 'show', namespace: NS.XLINK},
'xlink:title': {prefix: 'xlink', name: 'title', namespace: NS.XLINK},
'xlink:type': {prefix: 'xlink', name: 'type', namespace: NS.XLINK},
'xml:base': {prefix: 'xml', name: 'base', namespace: NS.XML},
'xml:lang': {prefix: 'xml', name: 'lang', namespace: NS.XML},
'xml:space': {prefix: 'xml', name: 'space', namespace: NS.XML},
'xmlns': {prefix: '', name: 'xmlns', namespace: NS.XMLNS},
'xmlns:xlink': {prefix: 'xmlns', name: 'xlink', namespace: NS.XMLNS}
};
//SVG tag names adjustment map
var SVG_TAG_NAMES_ADJUSTMENT_MAP = exports.SVG_TAG_NAMES_ADJUSTMENT_MAP = {
'altglyph': 'altGlyph',
'altglyphdef': 'altGlyphDef',
'altglyphitem': 'altGlyphItem',
'animatecolor': 'animateColor',
'animatemotion': 'animateMotion',
'animatetransform': 'animateTransform',
'clippath': 'clipPath',
'feblend': 'feBlend',
'fecolormatrix': 'feColorMatrix',
'fecomponenttransfer': 'feComponentTransfer',
'fecomposite': 'feComposite',
'feconvolvematrix': 'feConvolveMatrix',
'fediffuselighting': 'feDiffuseLighting',
'fedisplacementmap': 'feDisplacementMap',
'fedistantlight': 'feDistantLight',
'feflood': 'feFlood',
'fefunca': 'feFuncA',
'fefuncb': 'feFuncB',
'fefuncg': 'feFuncG',
'fefuncr': 'feFuncR',
'fegaussianblur': 'feGaussianBlur',
'feimage': 'feImage',
'femerge': 'feMerge',
'femergenode': 'feMergeNode',
'femorphology': 'feMorphology',
'feoffset': 'feOffset',
'fepointlight': 'fePointLight',
'fespecularlighting': 'feSpecularLighting',
'fespotlight': 'feSpotLight',
'fetile': 'feTile',
'feturbulence': 'feTurbulence',
'foreignobject': 'foreignObject',
'glyphref': 'glyphRef',
'lineargradient': 'linearGradient',
'radialgradient': 'radialGradient',
'textpath': 'textPath'
};
//Tags that causes exit from foreign content
var EXITS_FOREIGN_CONTENT = Object.create(null);
EXITS_FOREIGN_CONTENT[$.B] = true;
EXITS_FOREIGN_CONTENT[$.BIG] = true;
EXITS_FOREIGN_CONTENT[$.BLOCKQUOTE] = true;
EXITS_FOREIGN_CONTENT[$.BODY] = true;
EXITS_FOREIGN_CONTENT[$.BR] = true;
EXITS_FOREIGN_CONTENT[$.CENTER] = true;
EXITS_FOREIGN_CONTENT[$.CODE] = true;
EXITS_FOREIGN_CONTENT[$.DD] = true;
EXITS_FOREIGN_CONTENT[$.DIV] = true;
EXITS_FOREIGN_CONTENT[$.DL] = true;
EXITS_FOREIGN_CONTENT[$.DT] = true;
EXITS_FOREIGN_CONTENT[$.EM] = true;
EXITS_FOREIGN_CONTENT[$.EMBED] = true;
EXITS_FOREIGN_CONTENT[$.H1] = true;
EXITS_FOREIGN_CONTENT[$.H2] = true;
EXITS_FOREIGN_CONTENT[$.H3] = true;
EXITS_FOREIGN_CONTENT[$.H4] = true;
EXITS_FOREIGN_CONTENT[$.H5] = true;
EXITS_FOREIGN_CONTENT[$.H6] = true;
EXITS_FOREIGN_CONTENT[$.HEAD] = true;
EXITS_FOREIGN_CONTENT[$.HR] = true;
EXITS_FOREIGN_CONTENT[$.I] = true;
EXITS_FOREIGN_CONTENT[$.IMG] = true;
EXITS_FOREIGN_CONTENT[$.LI] = true;
EXITS_FOREIGN_CONTENT[$.LISTING] = true;
EXITS_FOREIGN_CONTENT[$.MENU] = true;
EXITS_FOREIGN_CONTENT[$.META] = true;
EXITS_FOREIGN_CONTENT[$.NOBR] = true;
EXITS_FOREIGN_CONTENT[$.OL] = true;
EXITS_FOREIGN_CONTENT[$.P] = true;
EXITS_FOREIGN_CONTENT[$.PRE] = true;
EXITS_FOREIGN_CONTENT[$.RUBY] = true;
EXITS_FOREIGN_CONTENT[$.S] = true;
EXITS_FOREIGN_CONTENT[$.SMALL] = true;
EXITS_FOREIGN_CONTENT[$.SPAN] = true;
EXITS_FOREIGN_CONTENT[$.STRONG] = true;
EXITS_FOREIGN_CONTENT[$.STRIKE] = true;
EXITS_FOREIGN_CONTENT[$.SUB] = true;
EXITS_FOREIGN_CONTENT[$.SUP] = true;
EXITS_FOREIGN_CONTENT[$.TABLE] = true;
EXITS_FOREIGN_CONTENT[$.TT] = true;
EXITS_FOREIGN_CONTENT[$.U] = true;
EXITS_FOREIGN_CONTENT[$.UL] = true;
EXITS_FOREIGN_CONTENT[$.VAR] = true;
//Check exit from foreign content
exports.causesExit = function (startTagToken) {
var tn = startTagToken.tagName;
var isFontWithAttrs = tn === $.FONT && (Tokenizer.getTokenAttr(startTagToken, ATTRS.COLOR) !== null ||
Tokenizer.getTokenAttr(startTagToken, ATTRS.SIZE) !== null ||
Tokenizer.getTokenAttr(startTagToken, ATTRS.FACE) !== null);
return isFontWithAttrs ? true : EXITS_FOREIGN_CONTENT[tn];
};
//Token adjustments
exports.adjustTokenMathMLAttrs = function (token) {
for (var i = 0; i < token.attrs.length; i++) {
if (token.attrs[i].name === DEFINITION_URL_ATTR) {
token.attrs[i].name = ADJUSTED_DEFINITION_URL_ATTR;
break;
}
}
};
exports.adjustTokenSVGAttrs = function (token) {
for (var i = 0; i < token.attrs.length; i++) {
var adjustedAttrName = SVG_ATTRS_ADJUSTMENT_MAP[token.attrs[i].name];
if (adjustedAttrName)
token.attrs[i].name = adjustedAttrName;
}
};
exports.adjustTokenXMLAttrs = function (token) {
for (var i = 0; i < token.attrs.length; i++) {
var adjustedAttrEntry = XML_ATTRS_ADJUSTMENT_MAP[token.attrs[i].name];
if (adjustedAttrEntry) {
token.attrs[i].prefix = adjustedAttrEntry.prefix;
token.attrs[i].name = adjustedAttrEntry.name;
token.attrs[i].namespace = adjustedAttrEntry.namespace;
}
}
};
exports.adjustTokenSVGTagName = function (token) {
var adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP[token.tagName];
if (adjustedTagName)
token.tagName = adjustedTagName;
};
//Integration points
function isMathMLTextIntegrationPoint(tn, ns) {
return ns === NS.MATHML && (tn === $.MI || tn === $.MO || tn === $.MN || tn === $.MS || tn === $.MTEXT);
}
function isHtmlIntegrationPoint(tn, ns, attrs) {
if (ns === NS.MATHML && tn === $.ANNOTATION_XML) {
for (var i = 0; i < attrs.length; i++) {
if (attrs[i].name === ATTRS.ENCODING) {
var value = attrs[i].value.toLowerCase();
return value === MIME_TYPES.TEXT_HTML || value === MIME_TYPES.APPLICATION_XML;
}
}
}
return ns === NS.SVG && (tn === $.FOREIGN_OBJECT || tn === $.DESC || tn === $.TITLE);
}
exports.isIntegrationPoint = function (tn, ns, attrs, foreignNS) {
if ((!foreignNS || foreignNS === NS.HTML) && isHtmlIntegrationPoint(tn, ns, attrs))
return true;
if ((!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns))
return true;
return false;
};

View File

@@ -1,13 +1,13 @@
'use strict';
var NS = exports.NAMESPACES = {
const NS = (exports.NAMESPACES = {
HTML: 'http://www.w3.org/1999/xhtml',
MATHML: 'http://www.w3.org/1998/Math/MathML',
SVG: 'http://www.w3.org/2000/svg',
XLINK: 'http://www.w3.org/1999/xlink',
XML: 'http://www.w3.org/XML/1998/namespace',
XMLNS: 'http://www.w3.org/2000/xmlns/'
};
});
exports.ATTRS = {
TYPE: 'type',
@@ -26,7 +26,7 @@ exports.DOCUMENT_MODE = {
LIMITED_QUIRKS: 'limited-quirks'
};
var $ = exports.TAG_NAMES = {
const $ = (exports.TAG_NAMES = {
A: 'a',
ADDRESS: 'address',
ANNOTATION_XML: 'annotation-xml',
@@ -103,7 +103,6 @@ var $ = exports.TAG_NAMES = {
MARQUEE: 'marquee',
MATH: 'math',
MENU: 'menu',
MENUITEM: 'menuitem',
META: 'meta',
MGLYPH: 'mglyph',
MI: 'mi',
@@ -171,102 +170,103 @@ var $ = exports.TAG_NAMES = {
WBR: 'wbr',
XMP: 'xmp'
});
exports.SPECIAL_ELEMENTS = {
[NS.HTML]: {
[$.ADDRESS]: true,
[$.APPLET]: true,
[$.AREA]: true,
[$.ARTICLE]: true,
[$.ASIDE]: true,
[$.BASE]: true,
[$.BASEFONT]: true,
[$.BGSOUND]: true,
[$.BLOCKQUOTE]: true,
[$.BODY]: true,
[$.BR]: true,
[$.BUTTON]: true,
[$.CAPTION]: true,
[$.CENTER]: true,
[$.COL]: true,
[$.COLGROUP]: true,
[$.DD]: true,
[$.DETAILS]: true,
[$.DIR]: true,
[$.DIV]: true,
[$.DL]: true,
[$.DT]: true,
[$.EMBED]: true,
[$.FIELDSET]: true,
[$.FIGCAPTION]: true,
[$.FIGURE]: true,
[$.FOOTER]: true,
[$.FORM]: true,
[$.FRAME]: true,
[$.FRAMESET]: true,
[$.H1]: true,
[$.H2]: true,
[$.H3]: true,
[$.H4]: true,
[$.H5]: true,
[$.H6]: true,
[$.HEAD]: true,
[$.HEADER]: true,
[$.HGROUP]: true,
[$.HR]: true,
[$.HTML]: true,
[$.IFRAME]: true,
[$.IMG]: true,
[$.INPUT]: true,
[$.LI]: true,
[$.LINK]: true,
[$.LISTING]: true,
[$.MAIN]: true,
[$.MARQUEE]: true,
[$.MENU]: true,
[$.META]: true,
[$.NAV]: true,
[$.NOEMBED]: true,
[$.NOFRAMES]: true,
[$.NOSCRIPT]: true,
[$.OBJECT]: true,
[$.OL]: true,
[$.P]: true,
[$.PARAM]: true,
[$.PLAINTEXT]: true,
[$.PRE]: true,
[$.SCRIPT]: true,
[$.SECTION]: true,
[$.SELECT]: true,
[$.SOURCE]: true,
[$.STYLE]: true,
[$.SUMMARY]: true,
[$.TABLE]: true,
[$.TBODY]: true,
[$.TD]: true,
[$.TEMPLATE]: true,
[$.TEXTAREA]: true,
[$.TFOOT]: true,
[$.TH]: true,
[$.THEAD]: true,
[$.TITLE]: true,
[$.TR]: true,
[$.TRACK]: true,
[$.UL]: true,
[$.WBR]: true,
[$.XMP]: true
},
[NS.MATHML]: {
[$.MI]: true,
[$.MO]: true,
[$.MN]: true,
[$.MS]: true,
[$.MTEXT]: true,
[$.ANNOTATION_XML]: true
},
[NS.SVG]: {
[$.TITLE]: true,
[$.FOREIGN_OBJECT]: true,
[$.DESC]: true
}
};
var SPECIAL_ELEMENTS = exports.SPECIAL_ELEMENTS = Object.create(null);
SPECIAL_ELEMENTS[NS.HTML] = Object.create(null);
SPECIAL_ELEMENTS[NS.HTML][$.ADDRESS] = true;
SPECIAL_ELEMENTS[NS.HTML][$.APPLET] = true;
SPECIAL_ELEMENTS[NS.HTML][$.AREA] = true;
SPECIAL_ELEMENTS[NS.HTML][$.ARTICLE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.ASIDE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.BASE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.BASEFONT] = true;
SPECIAL_ELEMENTS[NS.HTML][$.BGSOUND] = true;
SPECIAL_ELEMENTS[NS.HTML][$.BLOCKQUOTE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.BODY] = true;
SPECIAL_ELEMENTS[NS.HTML][$.BR] = true;
SPECIAL_ELEMENTS[NS.HTML][$.BUTTON] = true;
SPECIAL_ELEMENTS[NS.HTML][$.CAPTION] = true;
SPECIAL_ELEMENTS[NS.HTML][$.CENTER] = true;
SPECIAL_ELEMENTS[NS.HTML][$.COL] = true;
SPECIAL_ELEMENTS[NS.HTML][$.COLGROUP] = true;
SPECIAL_ELEMENTS[NS.HTML][$.DD] = true;
SPECIAL_ELEMENTS[NS.HTML][$.DETAILS] = true;
SPECIAL_ELEMENTS[NS.HTML][$.DIR] = true;
SPECIAL_ELEMENTS[NS.HTML][$.DIV] = true;
SPECIAL_ELEMENTS[NS.HTML][$.DL] = true;
SPECIAL_ELEMENTS[NS.HTML][$.DT] = true;
SPECIAL_ELEMENTS[NS.HTML][$.EMBED] = true;
SPECIAL_ELEMENTS[NS.HTML][$.FIELDSET] = true;
SPECIAL_ELEMENTS[NS.HTML][$.FIGCAPTION] = true;
SPECIAL_ELEMENTS[NS.HTML][$.FIGURE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.FOOTER] = true;
SPECIAL_ELEMENTS[NS.HTML][$.FORM] = true;
SPECIAL_ELEMENTS[NS.HTML][$.FRAME] = true;
SPECIAL_ELEMENTS[NS.HTML][$.FRAMESET] = true;
SPECIAL_ELEMENTS[NS.HTML][$.H1] = true;
SPECIAL_ELEMENTS[NS.HTML][$.H2] = true;
SPECIAL_ELEMENTS[NS.HTML][$.H3] = true;
SPECIAL_ELEMENTS[NS.HTML][$.H4] = true;
SPECIAL_ELEMENTS[NS.HTML][$.H5] = true;
SPECIAL_ELEMENTS[NS.HTML][$.H6] = true;
SPECIAL_ELEMENTS[NS.HTML][$.HEAD] = true;
SPECIAL_ELEMENTS[NS.HTML][$.HEADER] = true;
SPECIAL_ELEMENTS[NS.HTML][$.HGROUP] = true;
SPECIAL_ELEMENTS[NS.HTML][$.HR] = true;
SPECIAL_ELEMENTS[NS.HTML][$.HTML] = true;
SPECIAL_ELEMENTS[NS.HTML][$.IFRAME] = true;
SPECIAL_ELEMENTS[NS.HTML][$.IMG] = true;
SPECIAL_ELEMENTS[NS.HTML][$.INPUT] = true;
SPECIAL_ELEMENTS[NS.HTML][$.LI] = true;
SPECIAL_ELEMENTS[NS.HTML][$.LINK] = true;
SPECIAL_ELEMENTS[NS.HTML][$.LISTING] = true;
SPECIAL_ELEMENTS[NS.HTML][$.MAIN] = true;
SPECIAL_ELEMENTS[NS.HTML][$.MARQUEE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.MENU] = true;
SPECIAL_ELEMENTS[NS.HTML][$.META] = true;
SPECIAL_ELEMENTS[NS.HTML][$.NAV] = true;
SPECIAL_ELEMENTS[NS.HTML][$.NOEMBED] = true;
SPECIAL_ELEMENTS[NS.HTML][$.NOFRAMES] = true;
SPECIAL_ELEMENTS[NS.HTML][$.NOSCRIPT] = true;
SPECIAL_ELEMENTS[NS.HTML][$.OBJECT] = true;
SPECIAL_ELEMENTS[NS.HTML][$.OL] = true;
SPECIAL_ELEMENTS[NS.HTML][$.P] = true;
SPECIAL_ELEMENTS[NS.HTML][$.PARAM] = true;
SPECIAL_ELEMENTS[NS.HTML][$.PLAINTEXT] = true;
SPECIAL_ELEMENTS[NS.HTML][$.PRE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.SCRIPT] = true;
SPECIAL_ELEMENTS[NS.HTML][$.SECTION] = true;
SPECIAL_ELEMENTS[NS.HTML][$.SELECT] = true;
SPECIAL_ELEMENTS[NS.HTML][$.SOURCE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.STYLE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.SUMMARY] = true;
SPECIAL_ELEMENTS[NS.HTML][$.TABLE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.TBODY] = true;
SPECIAL_ELEMENTS[NS.HTML][$.TD] = true;
SPECIAL_ELEMENTS[NS.HTML][$.TEMPLATE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.TEXTAREA] = true;
SPECIAL_ELEMENTS[NS.HTML][$.TFOOT] = true;
SPECIAL_ELEMENTS[NS.HTML][$.TH] = true;
SPECIAL_ELEMENTS[NS.HTML][$.THEAD] = true;
SPECIAL_ELEMENTS[NS.HTML][$.TITLE] = true;
SPECIAL_ELEMENTS[NS.HTML][$.TR] = true;
SPECIAL_ELEMENTS[NS.HTML][$.TRACK] = true;
SPECIAL_ELEMENTS[NS.HTML][$.UL] = true;
SPECIAL_ELEMENTS[NS.HTML][$.WBR] = true;
SPECIAL_ELEMENTS[NS.HTML][$.XMP] = true;
SPECIAL_ELEMENTS[NS.MATHML] = Object.create(null);
SPECIAL_ELEMENTS[NS.MATHML][$.MI] = true;
SPECIAL_ELEMENTS[NS.MATHML][$.MO] = true;
SPECIAL_ELEMENTS[NS.MATHML][$.MN] = true;
SPECIAL_ELEMENTS[NS.MATHML][$.MS] = true;
SPECIAL_ELEMENTS[NS.MATHML][$.MTEXT] = true;
SPECIAL_ELEMENTS[NS.MATHML][$.ANNOTATION_XML] = true;
SPECIAL_ELEMENTS[NS.SVG] = Object.create(null);
SPECIAL_ELEMENTS[NS.SVG][$.TITLE] = true;
SPECIAL_ELEMENTS[NS.SVG][$.FOREIGN_OBJECT] = true;
SPECIAL_ELEMENTS[NS.SVG][$.DESC] = true;

View File

@@ -1,47 +1,109 @@
'use strict';
const UNDEFINED_CODE_POINTS = [
0xfffe,
0xffff,
0x1fffe,
0x1ffff,
0x2fffe,
0x2ffff,
0x3fffe,
0x3ffff,
0x4fffe,
0x4ffff,
0x5fffe,
0x5ffff,
0x6fffe,
0x6ffff,
0x7fffe,
0x7ffff,
0x8fffe,
0x8ffff,
0x9fffe,
0x9ffff,
0xafffe,
0xaffff,
0xbfffe,
0xbffff,
0xcfffe,
0xcffff,
0xdfffe,
0xdffff,
0xefffe,
0xeffff,
0xffffe,
0xfffff,
0x10fffe,
0x10ffff
];
exports.REPLACEMENT_CHARACTER = '\uFFFD';
exports.CODE_POINTS = {
EOF: -1,
NULL: 0x00,
TABULATION: 0x09,
CARRIAGE_RETURN: 0x0D,
LINE_FEED: 0x0A,
FORM_FEED: 0x0C,
CARRIAGE_RETURN: 0x0d,
LINE_FEED: 0x0a,
FORM_FEED: 0x0c,
SPACE: 0x20,
EXCLAMATION_MARK: 0x21,
QUOTATION_MARK: 0x22,
NUMBER_SIGN: 0x23,
AMPERSAND: 0x26,
APOSTROPHE: 0x27,
HYPHEN_MINUS: 0x2D,
SOLIDUS: 0x2F,
HYPHEN_MINUS: 0x2d,
SOLIDUS: 0x2f,
DIGIT_0: 0x30,
DIGIT_9: 0x39,
SEMICOLON: 0x3B,
LESS_THAN_SIGN: 0x3C,
EQUALS_SIGN: 0x3D,
GREATER_THAN_SIGN: 0x3E,
QUESTION_MARK: 0x3F,
SEMICOLON: 0x3b,
LESS_THAN_SIGN: 0x3c,
EQUALS_SIGN: 0x3d,
GREATER_THAN_SIGN: 0x3e,
QUESTION_MARK: 0x3f,
LATIN_CAPITAL_A: 0x41,
LATIN_CAPITAL_F: 0x46,
LATIN_CAPITAL_X: 0x58,
LATIN_CAPITAL_Z: 0x5A,
LATIN_CAPITAL_Z: 0x5a,
RIGHT_SQUARE_BRACKET: 0x5d,
GRAVE_ACCENT: 0x60,
LATIN_SMALL_A: 0x61,
LATIN_SMALL_F: 0x66,
LATIN_SMALL_X: 0x78,
LATIN_SMALL_Z: 0x7A,
REPLACEMENT_CHARACTER: 0xFFFD
LATIN_SMALL_Z: 0x7a,
REPLACEMENT_CHARACTER: 0xfffd
};
exports.CODE_POINT_SEQUENCES = {
DASH_DASH_STRING: [0x2D, 0x2D], //--
DOCTYPE_STRING: [0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45], //DOCTYPE
CDATA_START_STRING: [0x5B, 0x43, 0x44, 0x41, 0x54, 0x41, 0x5B], //[CDATA[
CDATA_END_STRING: [0x5D, 0x5D, 0x3E], //]]>
DASH_DASH_STRING: [0x2d, 0x2d], //--
DOCTYPE_STRING: [0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45], //DOCTYPE
CDATA_START_STRING: [0x5b, 0x43, 0x44, 0x41, 0x54, 0x41, 0x5b], //[CDATA[
SCRIPT_STRING: [0x73, 0x63, 0x72, 0x69, 0x70, 0x74], //script
PUBLIC_STRING: [0x50, 0x55, 0x42, 0x4C, 0x49, 0x43], //PUBLIC
SYSTEM_STRING: [0x53, 0x59, 0x53, 0x54, 0x45, 0x4D] //SYSTEM
PUBLIC_STRING: [0x50, 0x55, 0x42, 0x4c, 0x49, 0x43], //PUBLIC
SYSTEM_STRING: [0x53, 0x59, 0x53, 0x54, 0x45, 0x4d] //SYSTEM
};
//Surrogates
exports.isSurrogate = function(cp) {
return cp >= 0xd800 && cp <= 0xdfff;
};
exports.isSurrogatePair = function(cp) {
return cp >= 0xdc00 && cp <= 0xdfff;
};
exports.getSurrogatePairCodePoint = function(cp1, cp2) {
return (cp1 - 0xd800) * 0x400 + 0x2400 + cp2;
};
//NOTE: excluding NULL and ASCII whitespace
exports.isControlCodePoint = function(cp) {
return (
(cp !== 0x20 && cp !== 0x0a && cp !== 0x0d && cp !== 0x09 && cp !== 0x0c && cp >= 0x01 && cp <= 0x1f) ||
(cp >= 0x7f && cp <= 0x9f)
);
};
exports.isUndefinedCodePoint = function(cp) {
return (cp >= 0xfdd0 && cp <= 0xfdef) || UNDEFINED_CODE_POINTS.indexOf(cp) > -1;
};

View File

@@ -0,0 +1,43 @@
'use strict';
const Mixin = require('../../utils/mixin');
class ErrorReportingMixinBase extends Mixin {
constructor(host, opts) {
super(host);
this.posTracker = null;
this.onParseError = opts.onParseError;
}
_setErrorLocation(err) {
err.startLine = err.endLine = this.posTracker.line;
err.startCol = err.endCol = this.posTracker.col;
err.startOffset = err.endOffset = this.posTracker.offset;
}
_reportError(code) {
const err = {
code: code,
startLine: -1,
startCol: -1,
startOffset: -1,
endLine: -1,
endCol: -1,
endOffset: -1
};
this._setErrorLocation(err);
this.onParseError(err);
}
_getOverriddenMethods(mxn) {
return {
_err(code) {
mxn._reportError(code);
}
};
}
}
module.exports = ErrorReportingMixinBase;

View File

@@ -0,0 +1,52 @@
'use strict';
const ErrorReportingMixinBase = require('./mixin-base');
const ErrorReportingTokenizerMixin = require('./tokenizer-mixin');
const LocationInfoTokenizerMixin = require('../location-info/tokenizer-mixin');
const Mixin = require('../../utils/mixin');
class ErrorReportingParserMixin extends ErrorReportingMixinBase {
constructor(parser, opts) {
super(parser, opts);
this.opts = opts;
this.ctLoc = null;
this.locBeforeToken = false;
}
_setErrorLocation(err) {
if (this.ctLoc) {
err.startLine = this.ctLoc.startLine;
err.startCol = this.ctLoc.startCol;
err.startOffset = this.ctLoc.startOffset;
err.endLine = this.locBeforeToken ? this.ctLoc.startLine : this.ctLoc.endLine;
err.endCol = this.locBeforeToken ? this.ctLoc.startCol : this.ctLoc.endCol;
err.endOffset = this.locBeforeToken ? this.ctLoc.startOffset : this.ctLoc.endOffset;
}
}
_getOverriddenMethods(mxn, orig) {
return {
_bootstrap(document, fragmentContext) {
orig._bootstrap.call(this, document, fragmentContext);
Mixin.install(this.tokenizer, ErrorReportingTokenizerMixin, mxn.opts);
Mixin.install(this.tokenizer, LocationInfoTokenizerMixin);
},
_processInputToken(token) {
mxn.ctLoc = token.location;
orig._processInputToken.call(this, token);
},
_err(code, options) {
mxn.locBeforeToken = options && options.beforeToken;
mxn._reportError(code);
}
};
}
}
module.exports = ErrorReportingParserMixin;

View File

@@ -0,0 +1,24 @@
'use strict';
const ErrorReportingMixinBase = require('./mixin-base');
const PositionTrackingPreprocessorMixin = require('../position-tracking/preprocessor-mixin');
const Mixin = require('../../utils/mixin');
class ErrorReportingPreprocessorMixin extends ErrorReportingMixinBase {
constructor(preprocessor, opts) {
super(preprocessor, opts);
this.posTracker = Mixin.install(preprocessor, PositionTrackingPreprocessorMixin);
this.lastErrOffset = -1;
}
_reportError(code) {
//NOTE: avoid reporting error twice on advance/retreat
if (this.lastErrOffset !== this.posTracker.offset) {
this.lastErrOffset = this.posTracker.offset;
super._reportError(code);
}
}
}
module.exports = ErrorReportingPreprocessorMixin;

View File

@@ -0,0 +1,17 @@
'use strict';
const ErrorReportingMixinBase = require('./mixin-base');
const ErrorReportingPreprocessorMixin = require('./preprocessor-mixin');
const Mixin = require('../../utils/mixin');
class ErrorReportingTokenizerMixin extends ErrorReportingMixinBase {
constructor(tokenizer, opts) {
super(tokenizer, opts);
const preprocessorMixin = Mixin.install(tokenizer.preprocessor, ErrorReportingPreprocessorMixin, opts);
this.posTracker = preprocessorMixin.posTracker;
}
}
module.exports = ErrorReportingTokenizerMixin;

View File

@@ -0,0 +1,35 @@
'use strict';
const Mixin = require('../../utils/mixin');
class LocationInfoOpenElementStackMixin extends Mixin {
constructor(stack, opts) {
super(stack);
this.onItemPop = opts.onItemPop;
}
_getOverriddenMethods(mxn, orig) {
return {
pop() {
mxn.onItemPop(this.current);
orig.pop.call(this);
},
popAllUpToHtmlElement() {
for (let i = this.stackTop; i > 0; i--) {
mxn.onItemPop(this.items[i]);
}
orig.popAllUpToHtmlElement.call(this);
},
remove(element) {
mxn.onItemPop(this.current);
orig.remove.call(this, element);
}
};
}
}
module.exports = LocationInfoOpenElementStackMixin;

View File

@@ -0,0 +1,222 @@
'use strict';
const Mixin = require('../../utils/mixin');
const Tokenizer = require('../../tokenizer');
const LocationInfoTokenizerMixin = require('./tokenizer-mixin');
const LocationInfoOpenElementStackMixin = require('./open-element-stack-mixin');
const HTML = require('../../common/html');
//Aliases
const $ = HTML.TAG_NAMES;
class LocationInfoParserMixin extends Mixin {
constructor(parser) {
super(parser);
this.parser = parser;
this.treeAdapter = this.parser.treeAdapter;
this.posTracker = null;
this.lastStartTagToken = null;
this.lastFosterParentingLocation = null;
this.currentToken = null;
}
_setStartLocation(element) {
let loc = null;
if (this.lastStartTagToken) {
loc = Object.assign({}, this.lastStartTagToken.location);
loc.startTag = this.lastStartTagToken.location;
}
this.treeAdapter.setNodeSourceCodeLocation(element, loc);
}
_setEndLocation(element, closingToken) {
const loc = this.treeAdapter.getNodeSourceCodeLocation(element);
if (loc) {
if (closingToken.location) {
const ctLoc = closingToken.location;
const tn = this.treeAdapter.getTagName(element);
// NOTE: For cases like <p> <p> </p> - First 'p' closes without a closing
// tag and for cases like <td> <p> </td> - 'p' closes without a closing tag.
const isClosingEndTag = closingToken.type === Tokenizer.END_TAG_TOKEN && tn === closingToken.tagName;
if (isClosingEndTag) {
loc.endTag = Object.assign({}, ctLoc);
loc.endLine = ctLoc.endLine;
loc.endCol = ctLoc.endCol;
loc.endOffset = ctLoc.endOffset;
} else {
loc.endLine = ctLoc.startLine;
loc.endCol = ctLoc.startCol;
loc.endOffset = ctLoc.startOffset;
}
}
}
}
_getOverriddenMethods(mxn, orig) {
return {
_bootstrap(document, fragmentContext) {
orig._bootstrap.call(this, document, fragmentContext);
mxn.lastStartTagToken = null;
mxn.lastFosterParentingLocation = null;
mxn.currentToken = null;
const tokenizerMixin = Mixin.install(this.tokenizer, LocationInfoTokenizerMixin);
mxn.posTracker = tokenizerMixin.posTracker;
Mixin.install(this.openElements, LocationInfoOpenElementStackMixin, {
onItemPop: function(element) {
mxn._setEndLocation(element, mxn.currentToken);
}
});
},
_runParsingLoop(scriptHandler) {
orig._runParsingLoop.call(this, scriptHandler);
// NOTE: generate location info for elements
// that remains on open element stack
for (let i = this.openElements.stackTop; i >= 0; i--) {
mxn._setEndLocation(this.openElements.items[i], mxn.currentToken);
}
},
//Token processing
_processTokenInForeignContent(token) {
mxn.currentToken = token;
orig._processTokenInForeignContent.call(this, token);
},
_processToken(token) {
mxn.currentToken = token;
orig._processToken.call(this, token);
//NOTE: <body> and <html> are never popped from the stack, so we need to updated
//their end location explicitly.
const requireExplicitUpdate =
token.type === Tokenizer.END_TAG_TOKEN &&
(token.tagName === $.HTML || (token.tagName === $.BODY && this.openElements.hasInScope($.BODY)));
if (requireExplicitUpdate) {
for (let i = this.openElements.stackTop; i >= 0; i--) {
const element = this.openElements.items[i];
if (this.treeAdapter.getTagName(element) === token.tagName) {
mxn._setEndLocation(element, token);
break;
}
}
}
},
//Doctype
_setDocumentType(token) {
orig._setDocumentType.call(this, token);
const documentChildren = this.treeAdapter.getChildNodes(this.document);
const cnLength = documentChildren.length;
for (let i = 0; i < cnLength; i++) {
const node = documentChildren[i];
if (this.treeAdapter.isDocumentTypeNode(node)) {
this.treeAdapter.setNodeSourceCodeLocation(node, token.location);
break;
}
}
},
//Elements
_attachElementToTree(element) {
//NOTE: _attachElementToTree is called from _appendElement, _insertElement and _insertTemplate methods.
//So we will use token location stored in this methods for the element.
mxn._setStartLocation(element);
mxn.lastStartTagToken = null;
orig._attachElementToTree.call(this, element);
},
_appendElement(token, namespaceURI) {
mxn.lastStartTagToken = token;
orig._appendElement.call(this, token, namespaceURI);
},
_insertElement(token, namespaceURI) {
mxn.lastStartTagToken = token;
orig._insertElement.call(this, token, namespaceURI);
},
_insertTemplate(token) {
mxn.lastStartTagToken = token;
orig._insertTemplate.call(this, token);
const tmplContent = this.treeAdapter.getTemplateContent(this.openElements.current);
this.treeAdapter.setNodeSourceCodeLocation(tmplContent, null);
},
_insertFakeRootElement() {
orig._insertFakeRootElement.call(this);
this.treeAdapter.setNodeSourceCodeLocation(this.openElements.current, null);
},
//Comments
_appendCommentNode(token, parent) {
orig._appendCommentNode.call(this, token, parent);
const children = this.treeAdapter.getChildNodes(parent);
const commentNode = children[children.length - 1];
this.treeAdapter.setNodeSourceCodeLocation(commentNode, token.location);
},
//Text
_findFosterParentingLocation() {
//NOTE: store last foster parenting location, so we will be able to find inserted text
//in case of foster parenting
mxn.lastFosterParentingLocation = orig._findFosterParentingLocation.call(this);
return mxn.lastFosterParentingLocation;
},
_insertCharacters(token) {
orig._insertCharacters.call(this, token);
const hasFosterParent = this._shouldFosterParentOnInsertion();
const parent =
(hasFosterParent && mxn.lastFosterParentingLocation.parent) ||
this.openElements.currentTmplContent ||
this.openElements.current;
const siblings = this.treeAdapter.getChildNodes(parent);
const textNodeIdx =
hasFosterParent && mxn.lastFosterParentingLocation.beforeElement
? siblings.indexOf(mxn.lastFosterParentingLocation.beforeElement) - 1
: siblings.length - 1;
const textNode = siblings[textNodeIdx];
//NOTE: if we have location assigned by another token, then just update end position
const tnLoc = this.treeAdapter.getNodeSourceCodeLocation(textNode);
if (tnLoc) {
tnLoc.endLine = token.location.endLine;
tnLoc.endCol = token.location.endCol;
tnLoc.endOffset = token.location.endOffset;
} else {
this.treeAdapter.setNodeSourceCodeLocation(textNode, token.location);
}
}
};
}
}
module.exports = LocationInfoParserMixin;

View File

@@ -0,0 +1,146 @@
'use strict';
const Mixin = require('../../utils/mixin');
const Tokenizer = require('../../tokenizer');
const PositionTrackingPreprocessorMixin = require('../position-tracking/preprocessor-mixin');
class LocationInfoTokenizerMixin extends Mixin {
constructor(tokenizer) {
super(tokenizer);
this.tokenizer = tokenizer;
this.posTracker = Mixin.install(tokenizer.preprocessor, PositionTrackingPreprocessorMixin);
this.currentAttrLocation = null;
this.ctLoc = null;
}
_getCurrentLocation() {
return {
startLine: this.posTracker.line,
startCol: this.posTracker.col,
startOffset: this.posTracker.offset,
endLine: -1,
endCol: -1,
endOffset: -1
};
}
_attachCurrentAttrLocationInfo() {
this.currentAttrLocation.endLine = this.posTracker.line;
this.currentAttrLocation.endCol = this.posTracker.col;
this.currentAttrLocation.endOffset = this.posTracker.offset;
const currentToken = this.tokenizer.currentToken;
const currentAttr = this.tokenizer.currentAttr;
if (!currentToken.location.attrs) {
currentToken.location.attrs = Object.create(null);
}
currentToken.location.attrs[currentAttr.name] = this.currentAttrLocation;
}
_getOverriddenMethods(mxn, orig) {
const methods = {
_createStartTagToken() {
orig._createStartTagToken.call(this);
this.currentToken.location = mxn.ctLoc;
},
_createEndTagToken() {
orig._createEndTagToken.call(this);
this.currentToken.location = mxn.ctLoc;
},
_createCommentToken() {
orig._createCommentToken.call(this);
this.currentToken.location = mxn.ctLoc;
},
_createDoctypeToken(initialName) {
orig._createDoctypeToken.call(this, initialName);
this.currentToken.location = mxn.ctLoc;
},
_createCharacterToken(type, ch) {
orig._createCharacterToken.call(this, type, ch);
this.currentCharacterToken.location = mxn.ctLoc;
},
_createEOFToken() {
orig._createEOFToken.call(this);
this.currentToken.location = mxn._getCurrentLocation();
},
_createAttr(attrNameFirstCh) {
orig._createAttr.call(this, attrNameFirstCh);
mxn.currentAttrLocation = mxn._getCurrentLocation();
},
_leaveAttrName(toState) {
orig._leaveAttrName.call(this, toState);
mxn._attachCurrentAttrLocationInfo();
},
_leaveAttrValue(toState) {
orig._leaveAttrValue.call(this, toState);
mxn._attachCurrentAttrLocationInfo();
},
_emitCurrentToken() {
const ctLoc = this.currentToken.location;
//NOTE: if we have pending character token make it's end location equal to the
//current token's start location.
if (this.currentCharacterToken) {
this.currentCharacterToken.location.endLine = ctLoc.startLine;
this.currentCharacterToken.location.endCol = ctLoc.startCol;
this.currentCharacterToken.location.endOffset = ctLoc.startOffset;
}
if (this.currentToken.type === Tokenizer.EOF_TOKEN) {
ctLoc.endLine = ctLoc.startLine;
ctLoc.endCol = ctLoc.startCol;
ctLoc.endOffset = ctLoc.startOffset;
} else {
ctLoc.endLine = mxn.posTracker.line;
ctLoc.endCol = mxn.posTracker.col + 1;
ctLoc.endOffset = mxn.posTracker.offset + 1;
}
orig._emitCurrentToken.call(this);
},
_emitCurrentCharacterToken() {
const ctLoc = this.currentCharacterToken && this.currentCharacterToken.location;
//NOTE: if we have character token and it's location wasn't set in the _emitCurrentToken(),
//then set it's location at the current preprocessor position.
//We don't need to increment preprocessor position, since character token
//emission is always forced by the start of the next character token here.
//So, we already have advanced position.
if (ctLoc && ctLoc.endOffset === -1) {
ctLoc.endLine = mxn.posTracker.line;
ctLoc.endCol = mxn.posTracker.col;
ctLoc.endOffset = mxn.posTracker.offset;
}
orig._emitCurrentCharacterToken.call(this);
}
};
//NOTE: patch initial states for each mode to obtain token start position
Object.keys(Tokenizer.MODE).forEach(modeName => {
const state = Tokenizer.MODE[modeName];
methods[state] = function(cp) {
mxn.ctLoc = mxn._getCurrentLocation();
orig[state].call(this, cp);
};
});
return methods;
}
}
module.exports = LocationInfoTokenizerMixin;

View File

@@ -1,34 +0,0 @@
'use strict';
var Mixin = require('../../utils/mixin'),
inherits = require('util').inherits;
var LocationInfoOpenElementStackMixin = module.exports = function (stack, options) {
Mixin.call(this, stack);
this.onItemPop = options.onItemPop;
};
inherits(LocationInfoOpenElementStackMixin, Mixin);
LocationInfoOpenElementStackMixin.prototype._getOverriddenMethods = function (mxn, orig) {
return {
pop: function () {
mxn.onItemPop(this.current);
orig.pop.call(this);
},
popAllUpToHtmlElement: function () {
for (var i = this.stackTop; i > 0; i--)
mxn.onItemPop(this.items[i]);
orig.popAllUpToHtmlElement.call(this);
},
remove: function (element) {
mxn.onItemPop(this.current);
orig.remove.call(this, element);
}
};
};

View File

@@ -1,213 +0,0 @@
'use strict';
var Mixin = require('../../utils/mixin'),
Tokenizer = require('../../tokenizer'),
LocationInfoTokenizerMixin = require('./tokenizer_mixin'),
PositionTrackingPreprocessorMixin = require('../position_tracking/preprocessor_mixin'),
LocationInfoOpenElementStackMixin = require('./open_element_stack_mixin'),
HTML = require('../../common/html'),
inherits = require('util').inherits;
//Aliases
var $ = HTML.TAG_NAMES;
var LocationInfoParserMixin = module.exports = function (parser) {
Mixin.call(this, parser);
this.parser = parser;
this.posTracker = null;
this.lastStartTagToken = null;
this.lastFosterParentingLocation = null;
this.currentToken = null;
};
inherits(LocationInfoParserMixin, Mixin);
LocationInfoParserMixin.prototype._setStartLocation = function (element) {
if (this.lastStartTagToken) {
element.__location = Object.create(this.lastStartTagToken.location);
element.__location.startTag = this.lastStartTagToken.location;
}
else
element.__location = null;
};
LocationInfoParserMixin.prototype._setEndLocation = function (element, closingToken) {
var loc = element.__location;
if (loc) {
if (closingToken.location) {
var ctLoc = closingToken.location,
tn = this.parser.treeAdapter.getTagName(element);
// NOTE: For cases like <p> <p> </p> - First 'p' closes without a closing
// tag and for cases like <td> <p> </td> - 'p' closes without a closing tag.
var isClosingEndTag = closingToken.type === Tokenizer.END_TAG_TOKEN && tn === closingToken.tagName;
if (isClosingEndTag) {
loc.endTag = Object.create(ctLoc);
loc.endOffset = ctLoc.endOffset;
}
else
loc.endOffset = ctLoc.startOffset;
}
else if (closingToken.type === Tokenizer.EOF_TOKEN)
loc.endOffset = this.posTracker.offset;
}
};
LocationInfoParserMixin.prototype._getOverriddenMethods = function (mxn, orig) {
return {
_bootstrap: function (document, fragmentContext) {
orig._bootstrap.call(this, document, fragmentContext);
mxn.lastStartTagToken = null;
mxn.lastFosterParentingLocation = null;
mxn.currentToken = null;
mxn.posTracker = new PositionTrackingPreprocessorMixin(this.tokenizer.preprocessor);
new LocationInfoTokenizerMixin(this.tokenizer);
new LocationInfoOpenElementStackMixin(this.openElements, {
onItemPop: function (element) {
mxn._setEndLocation(element, mxn.currentToken);
}
});
},
_runParsingLoop: function (scriptHandler) {
orig._runParsingLoop.call(this, scriptHandler);
// NOTE: generate location info for elements
// that remains on open element stack
for (var i = this.openElements.stackTop; i >= 0; i--)
mxn._setEndLocation(this.openElements.items[i], mxn.currentToken);
},
//Token processing
_processTokenInForeignContent: function (token) {
mxn.currentToken = token;
orig._processTokenInForeignContent.call(this, token);
},
_processToken: function (token) {
mxn.currentToken = token;
orig._processToken.call(this, token);
//NOTE: <body> and <html> are never popped from the stack, so we need to updated
//their end location explicitly.
var requireExplicitUpdate = token.type === Tokenizer.END_TAG_TOKEN &&
(token.tagName === $.HTML ||
token.tagName === $.BODY && this.openElements.hasInScope($.BODY));
if (requireExplicitUpdate) {
for (var i = this.openElements.stackTop; i >= 0; i--) {
var element = this.openElements.items[i];
if (this.treeAdapter.getTagName(element) === token.tagName) {
mxn._setEndLocation(element, token);
break;
}
}
}
},
//Doctype
_setDocumentType: function (token) {
orig._setDocumentType.call(this, token);
var documentChildren = this.treeAdapter.getChildNodes(this.document),
cnLength = documentChildren.length;
for (var i = 0; i < cnLength; i++) {
var node = documentChildren[i];
if (this.treeAdapter.isDocumentTypeNode(node)) {
node.__location = token.location;
break;
}
}
},
//Elements
_attachElementToTree: function (element) {
//NOTE: _attachElementToTree is called from _appendElement, _insertElement and _insertTemplate methods.
//So we will use token location stored in this methods for the element.
mxn._setStartLocation(element);
mxn.lastStartTagToken = null;
orig._attachElementToTree.call(this, element);
},
_appendElement: function (token, namespaceURI) {
mxn.lastStartTagToken = token;
orig._appendElement.call(this, token, namespaceURI);
},
_insertElement: function (token, namespaceURI) {
mxn.lastStartTagToken = token;
orig._insertElement.call(this, token, namespaceURI);
},
_insertTemplate: function (token) {
mxn.lastStartTagToken = token;
orig._insertTemplate.call(this, token);
var tmplContent = this.treeAdapter.getTemplateContent(this.openElements.current);
tmplContent.__location = null;
},
_insertFakeRootElement: function () {
orig._insertFakeRootElement.call(this);
this.openElements.current.__location = null;
},
//Comments
_appendCommentNode: function (token, parent) {
orig._appendCommentNode.call(this, token, parent);
var children = this.treeAdapter.getChildNodes(parent),
commentNode = children[children.length - 1];
commentNode.__location = token.location;
},
//Text
_findFosterParentingLocation: function () {
//NOTE: store last foster parenting location, so we will be able to find inserted text
//in case of foster parenting
mxn.lastFosterParentingLocation = orig._findFosterParentingLocation.call(this);
return mxn.lastFosterParentingLocation;
},
_insertCharacters: function (token) {
orig._insertCharacters.call(this, token);
var hasFosterParent = this._shouldFosterParentOnInsertion(),
parent = hasFosterParent && mxn.lastFosterParentingLocation.parent ||
this.openElements.currentTmplContent ||
this.openElements.current,
siblings = this.treeAdapter.getChildNodes(parent),
textNodeIdx = hasFosterParent && mxn.lastFosterParentingLocation.beforeElement ?
siblings.indexOf(mxn.lastFosterParentingLocation.beforeElement) - 1 :
siblings.length - 1,
textNode = siblings[textNodeIdx];
//NOTE: if we have location assigned by another token, then just update end position
if (textNode.__location)
textNode.__location.endOffset = token.location.endOffset;
else
textNode.__location = token.location;
}
};
};

View File

@@ -1,117 +0,0 @@
'use strict';
var Mixin = require('../../utils/mixin'),
Tokenizer = require('../../tokenizer'),
PositionTrackingPreprocessorMixin = require('../position_tracking/preprocessor_mixin'),
inherits = require('util').inherits;
var LocationInfoTokenizerMixin = module.exports = function (tokenizer) {
Mixin.call(this, tokenizer);
this.tokenizer = tokenizer;
this.posTracker = new PositionTrackingPreprocessorMixin(tokenizer.preprocessor);
this.currentAttrLocation = null;
this.currentTokenLocation = null;
};
inherits(LocationInfoTokenizerMixin, Mixin);
LocationInfoTokenizerMixin.prototype._getCurrentLocation = function () {
return {
line: this.posTracker.line,
col: this.posTracker.col,
startOffset: this.posTracker.offset,
endOffset: -1
};
};
LocationInfoTokenizerMixin.prototype._attachCurrentAttrLocationInfo = function () {
this.currentAttrLocation.endOffset = this.posTracker.offset;
var currentToken = this.tokenizer.currentToken,
currentAttr = this.tokenizer.currentAttr;
if (!currentToken.location.attrs)
currentToken.location.attrs = Object.create(null);
currentToken.location.attrs[currentAttr.name] = this.currentAttrLocation;
};
LocationInfoTokenizerMixin.prototype._getOverriddenMethods = function (mxn, orig) {
var methods = {
_createStartTagToken: function () {
orig._createStartTagToken.call(this);
this.currentToken.location = mxn.currentTokenLocation;
},
_createEndTagToken: function () {
orig._createEndTagToken.call(this);
this.currentToken.location = mxn.currentTokenLocation;
},
_createCommentToken: function () {
orig._createCommentToken.call(this);
this.currentToken.location = mxn.currentTokenLocation;
},
_createDoctypeToken: function (initialName) {
orig._createDoctypeToken.call(this, initialName);
this.currentToken.location = mxn.currentTokenLocation;
},
_createCharacterToken: function (type, ch) {
orig._createCharacterToken.call(this, type, ch);
this.currentCharacterToken.location = mxn.currentTokenLocation;
},
_createAttr: function (attrNameFirstCh) {
orig._createAttr.call(this, attrNameFirstCh);
mxn.currentAttrLocation = mxn._getCurrentLocation();
},
_leaveAttrName: function (toState) {
orig._leaveAttrName.call(this, toState);
mxn._attachCurrentAttrLocationInfo();
},
_leaveAttrValue: function (toState) {
orig._leaveAttrValue.call(this, toState);
mxn._attachCurrentAttrLocationInfo();
},
_emitCurrentToken: function () {
//NOTE: if we have pending character token make it's end location equal to the
//current token's start location.
if (this.currentCharacterToken)
this.currentCharacterToken.location.endOffset = this.currentToken.location.startOffset;
this.currentToken.location.endOffset = mxn.posTracker.offset + 1;
orig._emitCurrentToken.call(this);
},
_emitCurrentCharacterToken: function () {
//NOTE: if we have character token and it's location wasn't set in the _emitCurrentToken(),
//then set it's location at the current preprocessor position.
//We don't need to increment preprocessor position, since character token
//emission is always forced by the start of the next character token here.
//So, we already have advanced position.
if (this.currentCharacterToken && this.currentCharacterToken.location.endOffset === -1)
this.currentCharacterToken.location.endOffset = mxn.posTracker.offset;
orig._emitCurrentCharacterToken.call(this);
}
};
//NOTE: patch initial states for each mode to obtain token start position
Object.keys(Tokenizer.MODE).forEach(function (modeName) {
var state = Tokenizer.MODE[modeName];
methods[state] = function (cp) {
mxn.currentTokenLocation = mxn._getCurrentLocation();
orig[state].call(this, cp);
};
});
return methods;
};

View File

@@ -0,0 +1,64 @@
'use strict';
const Mixin = require('../../utils/mixin');
class PositionTrackingPreprocessorMixin extends Mixin {
constructor(preprocessor) {
super(preprocessor);
this.preprocessor = preprocessor;
this.isEol = false;
this.lineStartPos = 0;
this.droppedBufferSize = 0;
this.offset = 0;
this.col = 0;
this.line = 1;
}
_getOverriddenMethods(mxn, orig) {
return {
advance() {
const pos = this.pos + 1;
const ch = this.html[pos];
//NOTE: LF should be in the last column of the line
if (mxn.isEol) {
mxn.isEol = false;
mxn.line++;
mxn.lineStartPos = pos;
}
if (ch === '\n' || (ch === '\r' && this.html[pos + 1] !== '\n')) {
mxn.isEol = true;
}
mxn.col = pos - mxn.lineStartPos + 1;
mxn.offset = mxn.droppedBufferSize + pos;
return orig.advance.call(this);
},
retreat() {
orig.retreat.call(this);
mxn.isEol = false;
mxn.col = this.pos - mxn.lineStartPos + 1;
},
dropParsedChunk() {
const prevPos = this.pos;
orig.dropParsedChunk.call(this);
const reduction = prevPos - this.pos;
mxn.lineStartPos -= reduction;
mxn.droppedBufferSize += reduction;
mxn.offset = mxn.droppedBufferSize + this.pos;
}
};
}
}
module.exports = PositionTrackingPreprocessorMixin;

View File

@@ -1,72 +0,0 @@
'use strict';
var Mixin = require('../../utils/mixin'),
inherits = require('util').inherits,
UNICODE = require('../../common/unicode');
//Aliases
var $ = UNICODE.CODE_POINTS;
var PositionTrackingPreprocessorMixin = module.exports = function (preprocessor) {
// NOTE: avoid installing tracker twice
if (!preprocessor.__locTracker) {
preprocessor.__locTracker = this;
Mixin.call(this, preprocessor);
this.preprocessor = preprocessor;
this.isEol = false;
this.lineStartPos = 0;
this.droppedBufferSize = 0;
this.col = -1;
this.line = 1;
}
return preprocessor.__locTracker;
};
inherits(PositionTrackingPreprocessorMixin, Mixin);
Object.defineProperty(PositionTrackingPreprocessorMixin.prototype, 'offset', {
get: function () {
return this.droppedBufferSize + this.preprocessor.pos;
}
});
PositionTrackingPreprocessorMixin.prototype._getOverriddenMethods = function (mxn, orig) {
return {
advance: function () {
var cp = orig.advance.call(this);
//NOTE: LF should be in the last column of the line
if (mxn.isEol) {
mxn.isEol = false;
mxn.line++;
mxn.lineStartPos = mxn.offset;
}
if (cp === $.LINE_FEED)
mxn.isEol = true;
mxn.col = mxn.offset - mxn.lineStartPos + 1;
return cp;
},
retreat: function () {
orig.retreat.call(this);
mxn.isEol = false;
mxn.col = mxn.offset - mxn.lineStartPos + 1;
},
dropParsedChunk: function () {
var prevPos = this.pos;
orig.dropParsedChunk.call(this);
mxn.droppedBufferSize += prevPos - this.pos;
}
};
};

1085
node_modules/parse5/lib/index.d.ts generated vendored

File diff suppressed because it is too large Load Diff

49
node_modules/parse5/lib/index.js generated vendored
View File

@@ -1,12 +1,11 @@
'use strict';
var Parser = require('./parser'),
Serializer = require('./serializer');
const Parser = require('./parser');
const Serializer = require('./serializer');
// Shorthands
exports.parse = function parse(html, options) {
var parser = new Parser(options);
const parser = new Parser(options);
return parser.parse(html);
};
@@ -18,49 +17,13 @@ exports.parseFragment = function parseFragment(fragmentContext, html, options) {
fragmentContext = null;
}
var parser = new Parser(options);
const parser = new Parser(options);
return parser.parseFragment(html, fragmentContext);
};
exports.serialize = function (node, options) {
var serializer = new Serializer(node, options);
exports.serialize = function(node, options) {
const serializer = new Serializer(node, options);
return serializer.serialize();
};
// Tree adapters
exports.treeAdapters = {
default: require('./tree_adapters/default'),
htmlparser2: require('./tree_adapters/htmlparser2')
};
// Streaming
// NOTE: streaming API is lazy loadable to enable bundling for platforms
// that are different from Node.js.
// See https://github.com/inikulin/parse5/issues/235.
var streamingAPI = {
ParserStream: './parser/parser_stream',
PlainTextConversionStream: './parser/plain_text_conversion_stream',
SerializerStream: './serializer/serializer_stream',
SAXParser: './sax'
};
Object.keys(streamingAPI).forEach(function (cls) {
Object.defineProperty(exports, cls, {
get: function () {
try {
return require(streamingAPI[cls]);
}
catch (e) {
throw new Error(
cls + ' is supported only for Node.js.' +
'See https://github.com/inikulin/parse5/issues/235 for the details.'
);
}
}
});
});

View File

@@ -0,0 +1,181 @@
'use strict';
//Const
const NOAH_ARK_CAPACITY = 3;
//List of formatting elements
class FormattingElementList {
constructor(treeAdapter) {
this.length = 0;
this.entries = [];
this.treeAdapter = treeAdapter;
this.bookmark = null;
}
//Noah Ark's condition
//OPTIMIZATION: at first we try to find possible candidates for exclusion using
//lightweight heuristics without thorough attributes check.
_getNoahArkConditionCandidates(newElement) {
const candidates = [];
if (this.length >= NOAH_ARK_CAPACITY) {
const neAttrsLength = this.treeAdapter.getAttrList(newElement).length;
const neTagName = this.treeAdapter.getTagName(newElement);
const neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement);
for (let i = this.length - 1; i >= 0; i--) {
const entry = this.entries[i];
if (entry.type === FormattingElementList.MARKER_ENTRY) {
break;
}
const element = entry.element;
const elementAttrs = this.treeAdapter.getAttrList(element);
const isCandidate =
this.treeAdapter.getTagName(element) === neTagName &&
this.treeAdapter.getNamespaceURI(element) === neNamespaceURI &&
elementAttrs.length === neAttrsLength;
if (isCandidate) {
candidates.push({ idx: i, attrs: elementAttrs });
}
}
}
return candidates.length < NOAH_ARK_CAPACITY ? [] : candidates;
}
_ensureNoahArkCondition(newElement) {
const candidates = this._getNoahArkConditionCandidates(newElement);
let cLength = candidates.length;
if (cLength) {
const neAttrs = this.treeAdapter.getAttrList(newElement);
const neAttrsLength = neAttrs.length;
const neAttrsMap = Object.create(null);
//NOTE: build attrs map for the new element so we can perform fast lookups
for (let i = 0; i < neAttrsLength; i++) {
const neAttr = neAttrs[i];
neAttrsMap[neAttr.name] = neAttr.value;
}
for (let i = 0; i < neAttrsLength; i++) {
for (let j = 0; j < cLength; j++) {
const cAttr = candidates[j].attrs[i];
if (neAttrsMap[cAttr.name] !== cAttr.value) {
candidates.splice(j, 1);
cLength--;
}
if (candidates.length < NOAH_ARK_CAPACITY) {
return;
}
}
}
//NOTE: remove bottommost candidates until Noah's Ark condition will not be met
for (let i = cLength - 1; i >= NOAH_ARK_CAPACITY - 1; i--) {
this.entries.splice(candidates[i].idx, 1);
this.length--;
}
}
}
//Mutations
insertMarker() {
this.entries.push({ type: FormattingElementList.MARKER_ENTRY });
this.length++;
}
pushElement(element, token) {
this._ensureNoahArkCondition(element);
this.entries.push({
type: FormattingElementList.ELEMENT_ENTRY,
element: element,
token: token
});
this.length++;
}
insertElementAfterBookmark(element, token) {
let bookmarkIdx = this.length - 1;
for (; bookmarkIdx >= 0; bookmarkIdx--) {
if (this.entries[bookmarkIdx] === this.bookmark) {
break;
}
}
this.entries.splice(bookmarkIdx + 1, 0, {
type: FormattingElementList.ELEMENT_ENTRY,
element: element,
token: token
});
this.length++;
}
removeEntry(entry) {
for (let i = this.length - 1; i >= 0; i--) {
if (this.entries[i] === entry) {
this.entries.splice(i, 1);
this.length--;
break;
}
}
}
clearToLastMarker() {
while (this.length) {
const entry = this.entries.pop();
this.length--;
if (entry.type === FormattingElementList.MARKER_ENTRY) {
break;
}
}
}
//Search
getElementEntryInScopeWithTagName(tagName) {
for (let i = this.length - 1; i >= 0; i--) {
const entry = this.entries[i];
if (entry.type === FormattingElementList.MARKER_ENTRY) {
return null;
}
if (this.treeAdapter.getTagName(entry.element) === tagName) {
return entry;
}
}
return null;
}
getElementEntry(element) {
for (let i = this.length - 1; i >= 0; i--) {
const entry = this.entries[i];
if (entry.type === FormattingElementList.ELEMENT_ENTRY && entry.element === element) {
return entry;
}
}
return null;
}
}
//Entry types
FormattingElementList.MARKER_ENTRY = 'MARKER_ENTRY';
FormattingElementList.ELEMENT_ENTRY = 'ELEMENT_ENTRY';
module.exports = FormattingElementList;

View File

@@ -1,167 +0,0 @@
'use strict';
//Const
var NOAH_ARK_CAPACITY = 3;
//List of formatting elements
var FormattingElementList = module.exports = function (treeAdapter) {
this.length = 0;
this.entries = [];
this.treeAdapter = treeAdapter;
this.bookmark = null;
};
//Entry types
FormattingElementList.MARKER_ENTRY = 'MARKER_ENTRY';
FormattingElementList.ELEMENT_ENTRY = 'ELEMENT_ENTRY';
//Noah Ark's condition
//OPTIMIZATION: at first we try to find possible candidates for exclusion using
//lightweight heuristics without thorough attributes check.
FormattingElementList.prototype._getNoahArkConditionCandidates = function (newElement) {
var candidates = [];
if (this.length >= NOAH_ARK_CAPACITY) {
var neAttrsLength = this.treeAdapter.getAttrList(newElement).length,
neTagName = this.treeAdapter.getTagName(newElement),
neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement);
for (var i = this.length - 1; i >= 0; i--) {
var entry = this.entries[i];
if (entry.type === FormattingElementList.MARKER_ENTRY)
break;
var element = entry.element,
elementAttrs = this.treeAdapter.getAttrList(element),
isCandidate = this.treeAdapter.getTagName(element) === neTagName &&
this.treeAdapter.getNamespaceURI(element) === neNamespaceURI &&
elementAttrs.length === neAttrsLength;
if (isCandidate)
candidates.push({idx: i, attrs: elementAttrs});
}
}
return candidates.length < NOAH_ARK_CAPACITY ? [] : candidates;
};
FormattingElementList.prototype._ensureNoahArkCondition = function (newElement) {
var candidates = this._getNoahArkConditionCandidates(newElement),
cLength = candidates.length;
if (cLength) {
var neAttrs = this.treeAdapter.getAttrList(newElement),
neAttrsLength = neAttrs.length,
neAttrsMap = Object.create(null);
//NOTE: build attrs map for the new element so we can perform fast lookups
for (var i = 0; i < neAttrsLength; i++) {
var neAttr = neAttrs[i];
neAttrsMap[neAttr.name] = neAttr.value;
}
for (i = 0; i < neAttrsLength; i++) {
for (var j = 0; j < cLength; j++) {
var cAttr = candidates[j].attrs[i];
if (neAttrsMap[cAttr.name] !== cAttr.value) {
candidates.splice(j, 1);
cLength--;
}
if (candidates.length < NOAH_ARK_CAPACITY)
return;
}
}
//NOTE: remove bottommost candidates until Noah's Ark condition will not be met
for (i = cLength - 1; i >= NOAH_ARK_CAPACITY - 1; i--) {
this.entries.splice(candidates[i].idx, 1);
this.length--;
}
}
};
//Mutations
FormattingElementList.prototype.insertMarker = function () {
this.entries.push({type: FormattingElementList.MARKER_ENTRY});
this.length++;
};
FormattingElementList.prototype.pushElement = function (element, token) {
this._ensureNoahArkCondition(element);
this.entries.push({
type: FormattingElementList.ELEMENT_ENTRY,
element: element,
token: token
});
this.length++;
};
FormattingElementList.prototype.insertElementAfterBookmark = function (element, token) {
var bookmarkIdx = this.length - 1;
for (; bookmarkIdx >= 0; bookmarkIdx--) {
if (this.entries[bookmarkIdx] === this.bookmark)
break;
}
this.entries.splice(bookmarkIdx + 1, 0, {
type: FormattingElementList.ELEMENT_ENTRY,
element: element,
token: token
});
this.length++;
};
FormattingElementList.prototype.removeEntry = function (entry) {
for (var i = this.length - 1; i >= 0; i--) {
if (this.entries[i] === entry) {
this.entries.splice(i, 1);
this.length--;
break;
}
}
};
FormattingElementList.prototype.clearToLastMarker = function () {
while (this.length) {
var entry = this.entries.pop();
this.length--;
if (entry.type === FormattingElementList.MARKER_ENTRY)
break;
}
};
//Search
FormattingElementList.prototype.getElementEntryInScopeWithTagName = function (tagName) {
for (var i = this.length - 1; i >= 0; i--) {
var entry = this.entries[i];
if (entry.type === FormattingElementList.MARKER_ENTRY)
return null;
if (this.treeAdapter.getTagName(entry.element) === tagName)
return entry;
}
return null;
};
FormattingElementList.prototype.getElementEntry = function (element) {
for (var i = this.length - 1; i >= 0; i--) {
var entry = this.entries[i];
if (entry.type === FormattingElementList.ELEMENT_ENTRY && entry.element === element)
return entry;
}
return null;
};

2917
node_modules/parse5/lib/parser/index.js generated vendored

File diff suppressed because it is too large Load Diff

482
node_modules/parse5/lib/parser/open-element-stack.js generated vendored Normal file
View File

@@ -0,0 +1,482 @@
'use strict';
const HTML = require('../common/html');
//Aliases
const $ = HTML.TAG_NAMES;
const NS = HTML.NAMESPACES;
//Element utils
//OPTIMIZATION: Integer comparisons are low-cost, so we can use very fast tag name length filters here.
//It's faster than using dictionary.
function isImpliedEndTagRequired(tn) {
switch (tn.length) {
case 1:
return tn === $.P;
case 2:
return tn === $.RB || tn === $.RP || tn === $.RT || tn === $.DD || tn === $.DT || tn === $.LI;
case 3:
return tn === $.RTC;
case 6:
return tn === $.OPTION;
case 8:
return tn === $.OPTGROUP;
}
return false;
}
function isImpliedEndTagRequiredThoroughly(tn) {
switch (tn.length) {
case 1:
return tn === $.P;
case 2:
return (
tn === $.RB ||
tn === $.RP ||
tn === $.RT ||
tn === $.DD ||
tn === $.DT ||
tn === $.LI ||
tn === $.TD ||
tn === $.TH ||
tn === $.TR
);
case 3:
return tn === $.RTC;
case 5:
return tn === $.TBODY || tn === $.TFOOT || tn === $.THEAD;
case 6:
return tn === $.OPTION;
case 7:
return tn === $.CAPTION;
case 8:
return tn === $.OPTGROUP || tn === $.COLGROUP;
}
return false;
}
function isScopingElement(tn, ns) {
switch (tn.length) {
case 2:
if (tn === $.TD || tn === $.TH) {
return ns === NS.HTML;
} else if (tn === $.MI || tn === $.MO || tn === $.MN || tn === $.MS) {
return ns === NS.MATHML;
}
break;
case 4:
if (tn === $.HTML) {
return ns === NS.HTML;
} else if (tn === $.DESC) {
return ns === NS.SVG;
}
break;
case 5:
if (tn === $.TABLE) {
return ns === NS.HTML;
} else if (tn === $.MTEXT) {
return ns === NS.MATHML;
} else if (tn === $.TITLE) {
return ns === NS.SVG;
}
break;
case 6:
return (tn === $.APPLET || tn === $.OBJECT) && ns === NS.HTML;
case 7:
return (tn === $.CAPTION || tn === $.MARQUEE) && ns === NS.HTML;
case 8:
return tn === $.TEMPLATE && ns === NS.HTML;
case 13:
return tn === $.FOREIGN_OBJECT && ns === NS.SVG;
case 14:
return tn === $.ANNOTATION_XML && ns === NS.MATHML;
}
return false;
}
//Stack of open elements
class OpenElementStack {
constructor(document, treeAdapter) {
this.stackTop = -1;
this.items = [];
this.current = document;
this.currentTagName = null;
this.currentTmplContent = null;
this.tmplCount = 0;
this.treeAdapter = treeAdapter;
}
//Index of element
_indexOf(element) {
let idx = -1;
for (let i = this.stackTop; i >= 0; i--) {
if (this.items[i] === element) {
idx = i;
break;
}
}
return idx;
}
//Update current element
_isInTemplate() {
return this.currentTagName === $.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML;
}
_updateCurrentElement() {
this.current = this.items[this.stackTop];
this.currentTagName = this.current && this.treeAdapter.getTagName(this.current);
this.currentTmplContent = this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : null;
}
//Mutations
push(element) {
this.items[++this.stackTop] = element;
this._updateCurrentElement();
if (this._isInTemplate()) {
this.tmplCount++;
}
}
pop() {
this.stackTop--;
if (this.tmplCount > 0 && this._isInTemplate()) {
this.tmplCount--;
}
this._updateCurrentElement();
}
replace(oldElement, newElement) {
const idx = this._indexOf(oldElement);
this.items[idx] = newElement;
if (idx === this.stackTop) {
this._updateCurrentElement();
}
}
insertAfter(referenceElement, newElement) {
const insertionIdx = this._indexOf(referenceElement) + 1;
this.items.splice(insertionIdx, 0, newElement);
if (insertionIdx === ++this.stackTop) {
this._updateCurrentElement();
}
}
popUntilTagNamePopped(tagName) {
while (this.stackTop > -1) {
const tn = this.currentTagName;
const ns = this.treeAdapter.getNamespaceURI(this.current);
this.pop();
if (tn === tagName && ns === NS.HTML) {
break;
}
}
}
popUntilElementPopped(element) {
while (this.stackTop > -1) {
const poppedElement = this.current;
this.pop();
if (poppedElement === element) {
break;
}
}
}
popUntilNumberedHeaderPopped() {
while (this.stackTop > -1) {
const tn = this.currentTagName;
const ns = this.treeAdapter.getNamespaceURI(this.current);
this.pop();
if (
tn === $.H1 ||
tn === $.H2 ||
tn === $.H3 ||
tn === $.H4 ||
tn === $.H5 ||
(tn === $.H6 && ns === NS.HTML)
) {
break;
}
}
}
popUntilTableCellPopped() {
while (this.stackTop > -1) {
const tn = this.currentTagName;
const ns = this.treeAdapter.getNamespaceURI(this.current);
this.pop();
if (tn === $.TD || (tn === $.TH && ns === NS.HTML)) {
break;
}
}
}
popAllUpToHtmlElement() {
//NOTE: here we assume that root <html> element is always first in the open element stack, so
//we perform this fast stack clean up.
this.stackTop = 0;
this._updateCurrentElement();
}
clearBackToTableContext() {
while (
(this.currentTagName !== $.TABLE && this.currentTagName !== $.TEMPLATE && this.currentTagName !== $.HTML) ||
this.treeAdapter.getNamespaceURI(this.current) !== NS.HTML
) {
this.pop();
}
}
clearBackToTableBodyContext() {
while (
(this.currentTagName !== $.TBODY &&
this.currentTagName !== $.TFOOT &&
this.currentTagName !== $.THEAD &&
this.currentTagName !== $.TEMPLATE &&
this.currentTagName !== $.HTML) ||
this.treeAdapter.getNamespaceURI(this.current) !== NS.HTML
) {
this.pop();
}
}
clearBackToTableRowContext() {
while (
(this.currentTagName !== $.TR && this.currentTagName !== $.TEMPLATE && this.currentTagName !== $.HTML) ||
this.treeAdapter.getNamespaceURI(this.current) !== NS.HTML
) {
this.pop();
}
}
remove(element) {
for (let i = this.stackTop; i >= 0; i--) {
if (this.items[i] === element) {
this.items.splice(i, 1);
this.stackTop--;
this._updateCurrentElement();
break;
}
}
}
//Search
tryPeekProperlyNestedBodyElement() {
//Properly nested <body> element (should be second element in stack).
const element = this.items[1];
return element && this.treeAdapter.getTagName(element) === $.BODY ? element : null;
}
contains(element) {
return this._indexOf(element) > -1;
}
getCommonAncestor(element) {
let elementIdx = this._indexOf(element);
return --elementIdx >= 0 ? this.items[elementIdx] : null;
}
isRootHtmlElementCurrent() {
return this.stackTop === 0 && this.currentTagName === $.HTML;
}
//Element in scope
hasInScope(tagName) {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.treeAdapter.getTagName(this.items[i]);
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (tn === tagName && ns === NS.HTML) {
return true;
}
if (isScopingElement(tn, ns)) {
return false;
}
}
return true;
}
hasNumberedHeaderInScope() {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.treeAdapter.getTagName(this.items[i]);
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (
(tn === $.H1 || tn === $.H2 || tn === $.H3 || tn === $.H4 || tn === $.H5 || tn === $.H6) &&
ns === NS.HTML
) {
return true;
}
if (isScopingElement(tn, ns)) {
return false;
}
}
return true;
}
hasInListItemScope(tagName) {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.treeAdapter.getTagName(this.items[i]);
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (tn === tagName && ns === NS.HTML) {
return true;
}
if (((tn === $.UL || tn === $.OL) && ns === NS.HTML) || isScopingElement(tn, ns)) {
return false;
}
}
return true;
}
hasInButtonScope(tagName) {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.treeAdapter.getTagName(this.items[i]);
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (tn === tagName && ns === NS.HTML) {
return true;
}
if ((tn === $.BUTTON && ns === NS.HTML) || isScopingElement(tn, ns)) {
return false;
}
}
return true;
}
hasInTableScope(tagName) {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.treeAdapter.getTagName(this.items[i]);
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (ns !== NS.HTML) {
continue;
}
if (tn === tagName) {
return true;
}
if (tn === $.TABLE || tn === $.TEMPLATE || tn === $.HTML) {
return false;
}
}
return true;
}
hasTableBodyContextInTableScope() {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.treeAdapter.getTagName(this.items[i]);
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (ns !== NS.HTML) {
continue;
}
if (tn === $.TBODY || tn === $.THEAD || tn === $.TFOOT) {
return true;
}
if (tn === $.TABLE || tn === $.HTML) {
return false;
}
}
return true;
}
hasInSelectScope(tagName) {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.treeAdapter.getTagName(this.items[i]);
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (ns !== NS.HTML) {
continue;
}
if (tn === tagName) {
return true;
}
if (tn !== $.OPTION && tn !== $.OPTGROUP) {
return false;
}
}
return true;
}
//Implied end tags
generateImpliedEndTags() {
while (isImpliedEndTagRequired(this.currentTagName)) {
this.pop();
}
}
generateImpliedEndTagsThoroughly() {
while (isImpliedEndTagRequiredThoroughly(this.currentTagName)) {
this.pop();
}
}
generateImpliedEndTagsWithExclusion(exclusionTagName) {
while (isImpliedEndTagRequired(this.currentTagName) && this.currentTagName !== exclusionTagName) {
this.pop();
}
}
}
module.exports = OpenElementStack;

View File

@@ -1,395 +0,0 @@
'use strict';
var HTML = require('../common/html');
//Aliases
var $ = HTML.TAG_NAMES,
NS = HTML.NAMESPACES;
//Element utils
//OPTIMIZATION: Integer comparisons are low-cost, so we can use very fast tag name length filters here.
//It's faster than using dictionary.
function isImpliedEndTagRequired(tn) {
switch (tn.length) {
case 1:
return tn === $.P;
case 2:
return tn === $.RB || tn === $.RP || tn === $.RT || tn === $.DD || tn === $.DT || tn === $.LI;
case 3:
return tn === $.RTC;
case 6:
return tn === $.OPTION;
case 8:
return tn === $.OPTGROUP || tn === $.MENUITEM;
}
return false;
}
function isScopingElement(tn, ns) {
switch (tn.length) {
case 2:
if (tn === $.TD || tn === $.TH)
return ns === NS.HTML;
else if (tn === $.MI || tn === $.MO || tn === $.MN || tn === $.MS)
return ns === NS.MATHML;
break;
case 4:
if (tn === $.HTML)
return ns === NS.HTML;
else if (tn === $.DESC)
return ns === NS.SVG;
break;
case 5:
if (tn === $.TABLE)
return ns === NS.HTML;
else if (tn === $.MTEXT)
return ns === NS.MATHML;
else if (tn === $.TITLE)
return ns === NS.SVG;
break;
case 6:
return (tn === $.APPLET || tn === $.OBJECT) && ns === NS.HTML;
case 7:
return (tn === $.CAPTION || tn === $.MARQUEE) && ns === NS.HTML;
case 8:
return tn === $.TEMPLATE && ns === NS.HTML;
case 13:
return tn === $.FOREIGN_OBJECT && ns === NS.SVG;
case 14:
return tn === $.ANNOTATION_XML && ns === NS.MATHML;
}
return false;
}
//Stack of open elements
var OpenElementStack = module.exports = function (document, treeAdapter) {
this.stackTop = -1;
this.items = [];
this.current = document;
this.currentTagName = null;
this.currentTmplContent = null;
this.tmplCount = 0;
this.treeAdapter = treeAdapter;
};
//Index of element
OpenElementStack.prototype._indexOf = function (element) {
var idx = -1;
for (var i = this.stackTop; i >= 0; i--) {
if (this.items[i] === element) {
idx = i;
break;
}
}
return idx;
};
//Update current element
OpenElementStack.prototype._isInTemplate = function () {
return this.currentTagName === $.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML;
};
OpenElementStack.prototype._updateCurrentElement = function () {
this.current = this.items[this.stackTop];
this.currentTagName = this.current && this.treeAdapter.getTagName(this.current);
this.currentTmplContent = this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : null;
};
//Mutations
OpenElementStack.prototype.push = function (element) {
this.items[++this.stackTop] = element;
this._updateCurrentElement();
if (this._isInTemplate())
this.tmplCount++;
};
OpenElementStack.prototype.pop = function () {
this.stackTop--;
if (this.tmplCount > 0 && this._isInTemplate())
this.tmplCount--;
this._updateCurrentElement();
};
OpenElementStack.prototype.replace = function (oldElement, newElement) {
var idx = this._indexOf(oldElement);
this.items[idx] = newElement;
if (idx === this.stackTop)
this._updateCurrentElement();
};
OpenElementStack.prototype.insertAfter = function (referenceElement, newElement) {
var insertionIdx = this._indexOf(referenceElement) + 1;
this.items.splice(insertionIdx, 0, newElement);
if (insertionIdx === ++this.stackTop)
this._updateCurrentElement();
};
OpenElementStack.prototype.popUntilTagNamePopped = function (tagName) {
while (this.stackTop > -1) {
var tn = this.currentTagName,
ns = this.treeAdapter.getNamespaceURI(this.current);
this.pop();
if (tn === tagName && ns === NS.HTML)
break;
}
};
OpenElementStack.prototype.popUntilElementPopped = function (element) {
while (this.stackTop > -1) {
var poppedElement = this.current;
this.pop();
if (poppedElement === element)
break;
}
};
OpenElementStack.prototype.popUntilNumberedHeaderPopped = function () {
while (this.stackTop > -1) {
var tn = this.currentTagName,
ns = this.treeAdapter.getNamespaceURI(this.current);
this.pop();
if (tn === $.H1 || tn === $.H2 || tn === $.H3 || tn === $.H4 || tn === $.H5 || tn === $.H6 && ns === NS.HTML)
break;
}
};
OpenElementStack.prototype.popUntilTableCellPopped = function () {
while (this.stackTop > -1) {
var tn = this.currentTagName,
ns = this.treeAdapter.getNamespaceURI(this.current);
this.pop();
if (tn === $.TD || tn === $.TH && ns === NS.HTML)
break;
}
};
OpenElementStack.prototype.popAllUpToHtmlElement = function () {
//NOTE: here we assume that root <html> element is always first in the open element stack, so
//we perform this fast stack clean up.
this.stackTop = 0;
this._updateCurrentElement();
};
OpenElementStack.prototype.clearBackToTableContext = function () {
while (this.currentTagName !== $.TABLE &&
this.currentTagName !== $.TEMPLATE &&
this.currentTagName !== $.HTML ||
this.treeAdapter.getNamespaceURI(this.current) !== NS.HTML)
this.pop();
};
OpenElementStack.prototype.clearBackToTableBodyContext = function () {
while (this.currentTagName !== $.TBODY &&
this.currentTagName !== $.TFOOT &&
this.currentTagName !== $.THEAD &&
this.currentTagName !== $.TEMPLATE &&
this.currentTagName !== $.HTML ||
this.treeAdapter.getNamespaceURI(this.current) !== NS.HTML)
this.pop();
};
OpenElementStack.prototype.clearBackToTableRowContext = function () {
while (this.currentTagName !== $.TR &&
this.currentTagName !== $.TEMPLATE &&
this.currentTagName !== $.HTML ||
this.treeAdapter.getNamespaceURI(this.current) !== NS.HTML)
this.pop();
};
OpenElementStack.prototype.remove = function (element) {
for (var i = this.stackTop; i >= 0; i--) {
if (this.items[i] === element) {
this.items.splice(i, 1);
this.stackTop--;
this._updateCurrentElement();
break;
}
}
};
//Search
OpenElementStack.prototype.tryPeekProperlyNestedBodyElement = function () {
//Properly nested <body> element (should be second element in stack).
var element = this.items[1];
return element && this.treeAdapter.getTagName(element) === $.BODY ? element : null;
};
OpenElementStack.prototype.contains = function (element) {
return this._indexOf(element) > -1;
};
OpenElementStack.prototype.getCommonAncestor = function (element) {
var elementIdx = this._indexOf(element);
return --elementIdx >= 0 ? this.items[elementIdx] : null;
};
OpenElementStack.prototype.isRootHtmlElementCurrent = function () {
return this.stackTop === 0 && this.currentTagName === $.HTML;
};
//Element in scope
OpenElementStack.prototype.hasInScope = function (tagName) {
for (var i = this.stackTop; i >= 0; i--) {
var tn = this.treeAdapter.getTagName(this.items[i]),
ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (tn === tagName && ns === NS.HTML)
return true;
if (isScopingElement(tn, ns))
return false;
}
return true;
};
OpenElementStack.prototype.hasNumberedHeaderInScope = function () {
for (var i = this.stackTop; i >= 0; i--) {
var tn = this.treeAdapter.getTagName(this.items[i]),
ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if ((tn === $.H1 || tn === $.H2 || tn === $.H3 || tn === $.H4 || tn === $.H5 || tn === $.H6) && ns === NS.HTML)
return true;
if (isScopingElement(tn, ns))
return false;
}
return true;
};
OpenElementStack.prototype.hasInListItemScope = function (tagName) {
for (var i = this.stackTop; i >= 0; i--) {
var tn = this.treeAdapter.getTagName(this.items[i]),
ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (tn === tagName && ns === NS.HTML)
return true;
if ((tn === $.UL || tn === $.OL) && ns === NS.HTML || isScopingElement(tn, ns))
return false;
}
return true;
};
OpenElementStack.prototype.hasInButtonScope = function (tagName) {
for (var i = this.stackTop; i >= 0; i--) {
var tn = this.treeAdapter.getTagName(this.items[i]),
ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (tn === tagName && ns === NS.HTML)
return true;
if (tn === $.BUTTON && ns === NS.HTML || isScopingElement(tn, ns))
return false;
}
return true;
};
OpenElementStack.prototype.hasInTableScope = function (tagName) {
for (var i = this.stackTop; i >= 0; i--) {
var tn = this.treeAdapter.getTagName(this.items[i]),
ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (ns !== NS.HTML)
continue;
if (tn === tagName)
return true;
if (tn === $.TABLE || tn === $.TEMPLATE || tn === $.HTML)
return false;
}
return true;
};
OpenElementStack.prototype.hasTableBodyContextInTableScope = function () {
for (var i = this.stackTop; i >= 0; i--) {
var tn = this.treeAdapter.getTagName(this.items[i]),
ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (ns !== NS.HTML)
continue;
if (tn === $.TBODY || tn === $.THEAD || tn === $.TFOOT)
return true;
if (tn === $.TABLE || tn === $.HTML)
return false;
}
return true;
};
OpenElementStack.prototype.hasInSelectScope = function (tagName) {
for (var i = this.stackTop; i >= 0; i--) {
var tn = this.treeAdapter.getTagName(this.items[i]),
ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (ns !== NS.HTML)
continue;
if (tn === tagName)
return true;
if (tn !== $.OPTION && tn !== $.OPTGROUP)
return false;
}
return true;
};
//Implied end tags
OpenElementStack.prototype.generateImpliedEndTags = function () {
while (isImpliedEndTagRequired(this.currentTagName))
this.pop();
};
OpenElementStack.prototype.generateImpliedEndTagsWithExclusion = function (exclusionTagName) {
while (isImpliedEndTagRequired(this.currentTagName) && this.currentTagName !== exclusionTagName)
this.pop();
};

View File

@@ -1,76 +0,0 @@
'use strict';
var WritableStream = require('stream').Writable,
inherits = require('util').inherits,
Parser = require('./index');
var ParserStream = module.exports = function (options) {
WritableStream.call(this);
this.parser = new Parser(options);
this.lastChunkWritten = false;
this.writeCallback = null;
this.pausedByScript = false;
this.document = this.parser.treeAdapter.createDocument();
this.pendingHtmlInsertions = [];
this._resume = this._resume.bind(this);
this._documentWrite = this._documentWrite.bind(this);
this._scriptHandler = this._scriptHandler.bind(this);
this.parser._bootstrap(this.document, null);
};
inherits(ParserStream, WritableStream);
//WritableStream implementation
ParserStream.prototype._write = function (chunk, encoding, callback) {
this.writeCallback = callback;
this.parser.tokenizer.write(chunk.toString('utf8'), this.lastChunkWritten);
this._runParsingLoop();
};
ParserStream.prototype.end = function (chunk, encoding, callback) {
this.lastChunkWritten = true;
WritableStream.prototype.end.call(this, chunk || '', encoding, callback);
};
//Scriptable parser implementation
ParserStream.prototype._runParsingLoop = function () {
this.parser.runParsingLoopForCurrentChunk(this.writeCallback, this._scriptHandler);
};
ParserStream.prototype._resume = function () {
if (!this.pausedByScript)
throw new Error('Parser was already resumed');
while (this.pendingHtmlInsertions.length) {
var html = this.pendingHtmlInsertions.pop();
this.parser.tokenizer.insertHtmlAtCurrentPos(html);
}
this.pausedByScript = false;
//NOTE: keep parsing if we don't wait for the next input chunk
if (this.parser.tokenizer.active)
this._runParsingLoop();
};
ParserStream.prototype._documentWrite = function (html) {
if (!this.parser.stopped)
this.pendingHtmlInsertions.push(html);
};
ParserStream.prototype._scriptHandler = function (scriptElement) {
if (this.listeners('script').length) {
this.pausedByScript = true;
this.emit('script', scriptElement, this._documentWrite, this._resume);
}
else
this._runParsingLoop();
};

View File

@@ -1,20 +0,0 @@
'use strict';
var ParserStream = require('./parser_stream'),
inherits = require('util').inherits,
$ = require('../common/html').TAG_NAMES;
var PlainTextConversionStream = module.exports = function (options) {
ParserStream.call(this, options);
// NOTE: see https://html.spec.whatwg.org/#read-text
this.parser._insertFakeElement($.HTML);
this.parser._insertFakeElement($.HEAD);
this.parser.openElements.pop();
this.parser._insertFakeElement($.BODY);
this.parser._insertFakeElement($.PRE);
this.parser.treeAdapter.insertText(this.parser.openElements.current, '\n');
this.parser.switchToPlaintextParsing();
};
inherits(PlainTextConversionStream, ParserStream);

View File

@@ -1,14 +0,0 @@
'use strict';
var WritableStream = require('stream').Writable,
util = require('util');
var DevNullStream = module.exports = function () {
WritableStream.call(this);
};
util.inherits(DevNullStream, WritableStream);
DevNullStream.prototype._write = function (chunk, encoding, cb) {
cb();
};

118
node_modules/parse5/lib/sax/index.js generated vendored
View File

@@ -1,118 +0,0 @@
'use strict';
var TransformStream = require('stream').Transform,
DevNullStream = require('./dev_null_stream'),
inherits = require('util').inherits,
Tokenizer = require('../tokenizer'),
LocationInfoTokenizerMixin = require('../extensions/location_info/tokenizer_mixin'),
ParserFeedbackSimulator = require('./parser_feedback_simulator'),
mergeOptions = require('../utils/merge_options');
var DEFAULT_OPTIONS = {
locationInfo: false
};
var SAXParser = module.exports = function (options) {
TransformStream.call(this);
this.options = mergeOptions(DEFAULT_OPTIONS, options);
this.tokenizer = new Tokenizer(options);
if (this.options.locationInfo)
new LocationInfoTokenizerMixin(this.tokenizer);
this.parserFeedbackSimulator = new ParserFeedbackSimulator(this.tokenizer);
this.pendingText = null;
this.currentTokenLocation = void 0;
this.lastChunkWritten = false;
this.stopped = false;
// NOTE: always pipe stream to the /dev/null stream to avoid
// `highWaterMark` hit even if we don't have consumers.
// (see: https://github.com/inikulin/parse5/issues/97#issuecomment-171940774)
this.pipe(new DevNullStream());
};
inherits(SAXParser, TransformStream);
//TransformStream implementation
SAXParser.prototype._transform = function (chunk, encoding, callback) {
if (!this.stopped) {
this.tokenizer.write(chunk.toString('utf8'), this.lastChunkWritten);
this._runParsingLoop();
}
this.push(chunk);
callback();
};
SAXParser.prototype._flush = function (callback) {
callback();
};
SAXParser.prototype.end = function (chunk, encoding, callback) {
this.lastChunkWritten = true;
TransformStream.prototype.end.call(this, chunk, encoding, callback);
};
SAXParser.prototype.stop = function () {
this.stopped = true;
};
//Internals
SAXParser.prototype._runParsingLoop = function () {
do {
var token = this.parserFeedbackSimulator.getNextToken();
if (token.type === Tokenizer.HIBERNATION_TOKEN)
break;
if (token.type === Tokenizer.CHARACTER_TOKEN ||
token.type === Tokenizer.WHITESPACE_CHARACTER_TOKEN ||
token.type === Tokenizer.NULL_CHARACTER_TOKEN) {
if (this.options.locationInfo) {
if (this.pendingText === null)
this.currentTokenLocation = token.location;
else
this.currentTokenLocation.endOffset = token.location.endOffset;
}
this.pendingText = (this.pendingText || '') + token.chars;
}
else {
this._emitPendingText();
this._handleToken(token);
}
} while (!this.stopped && token.type !== Tokenizer.EOF_TOKEN);
};
SAXParser.prototype._handleToken = function (token) {
if (this.options.locationInfo)
this.currentTokenLocation = token.location;
if (token.type === Tokenizer.START_TAG_TOKEN)
this.emit('startTag', token.tagName, token.attrs, token.selfClosing, this.currentTokenLocation);
else if (token.type === Tokenizer.END_TAG_TOKEN)
this.emit('endTag', token.tagName, this.currentTokenLocation);
else if (token.type === Tokenizer.COMMENT_TOKEN)
this.emit('comment', token.data, this.currentTokenLocation);
else if (token.type === Tokenizer.DOCTYPE_TOKEN)
this.emit('doctype', token.name, token.publicId, token.systemId, this.currentTokenLocation);
};
SAXParser.prototype._emitPendingText = function () {
if (this.pendingText !== null) {
this.emit('text', this.pendingText, this.currentTokenLocation);
this.pendingText = null;
}
};

View File

@@ -1,153 +0,0 @@
'use strict';
var Tokenizer = require('../tokenizer'),
foreignContent = require('../common/foreign_content'),
UNICODE = require('../common/unicode'),
HTML = require('../common/html');
//Aliases
var $ = HTML.TAG_NAMES,
NS = HTML.NAMESPACES;
//ParserFeedbackSimulator
//Simulates adjustment of the Tokenizer which performed by standard parser during tree construction.
var ParserFeedbackSimulator = module.exports = function (tokenizer) {
this.tokenizer = tokenizer;
this.namespaceStack = [];
this.namespaceStackTop = -1;
this._enterNamespace(NS.HTML);
};
ParserFeedbackSimulator.prototype.getNextToken = function () {
var token = this.tokenizer.getNextToken();
if (token.type === Tokenizer.START_TAG_TOKEN)
this._handleStartTagToken(token);
else if (token.type === Tokenizer.END_TAG_TOKEN)
this._handleEndTagToken(token);
else if (token.type === Tokenizer.NULL_CHARACTER_TOKEN && this.inForeignContent) {
token.type = Tokenizer.CHARACTER_TOKEN;
token.chars = UNICODE.REPLACEMENT_CHARACTER;
}
else if (this.skipNextNewLine) {
if (token.type !== Tokenizer.HIBERNATION_TOKEN)
this.skipNextNewLine = false;
if (token.type === Tokenizer.WHITESPACE_CHARACTER_TOKEN && token.chars[0] === '\n') {
if (token.chars.length === 1)
return this.getNextToken();
token.chars = token.chars.substr(1);
}
}
return token;
};
//Namespace stack mutations
ParserFeedbackSimulator.prototype._enterNamespace = function (namespace) {
this.namespaceStackTop++;
this.namespaceStack.push(namespace);
this.inForeignContent = namespace !== NS.HTML;
this.currentNamespace = namespace;
this.tokenizer.allowCDATA = this.inForeignContent;
};
ParserFeedbackSimulator.prototype._leaveCurrentNamespace = function () {
this.namespaceStackTop--;
this.namespaceStack.pop();
this.currentNamespace = this.namespaceStack[this.namespaceStackTop];
this.inForeignContent = this.currentNamespace !== NS.HTML;
this.tokenizer.allowCDATA = this.inForeignContent;
};
//Token handlers
ParserFeedbackSimulator.prototype._ensureTokenizerMode = function (tn) {
if (tn === $.TEXTAREA || tn === $.TITLE)
this.tokenizer.state = Tokenizer.MODE.RCDATA;
else if (tn === $.PLAINTEXT)
this.tokenizer.state = Tokenizer.MODE.PLAINTEXT;
else if (tn === $.SCRIPT)
this.tokenizer.state = Tokenizer.MODE.SCRIPT_DATA;
else if (tn === $.STYLE || tn === $.IFRAME || tn === $.XMP ||
tn === $.NOEMBED || tn === $.NOFRAMES || tn === $.NOSCRIPT)
this.tokenizer.state = Tokenizer.MODE.RAWTEXT;
};
ParserFeedbackSimulator.prototype._handleStartTagToken = function (token) {
var tn = token.tagName;
if (tn === $.SVG)
this._enterNamespace(NS.SVG);
else if (tn === $.MATH)
this._enterNamespace(NS.MATHML);
if (this.inForeignContent) {
if (foreignContent.causesExit(token)) {
this._leaveCurrentNamespace();
return;
}
var currentNs = this.currentNamespace;
if (currentNs === NS.MATHML)
foreignContent.adjustTokenMathMLAttrs(token);
else if (currentNs === NS.SVG) {
foreignContent.adjustTokenSVGTagName(token);
foreignContent.adjustTokenSVGAttrs(token);
}
foreignContent.adjustTokenXMLAttrs(token);
tn = token.tagName;
if (!token.selfClosing && foreignContent.isIntegrationPoint(tn, currentNs, token.attrs))
this._enterNamespace(NS.HTML);
}
else {
if (tn === $.PRE || tn === $.TEXTAREA || tn === $.LISTING)
this.skipNextNewLine = true;
else if (tn === $.IMAGE)
token.tagName = $.IMG;
this._ensureTokenizerMode(tn);
}
};
ParserFeedbackSimulator.prototype._handleEndTagToken = function (token) {
var tn = token.tagName;
if (!this.inForeignContent) {
var previousNs = this.namespaceStack[this.namespaceStackTop - 1];
if (previousNs === NS.SVG && foreignContent.SVG_TAG_NAMES_ADJUSTMENT_MAP[tn])
tn = foreignContent.SVG_TAG_NAMES_ADJUSTMENT_MAP[tn];
//NOTE: check for exit from integration point
if (foreignContent.isIntegrationPoint(tn, previousNs, token.attrs))
this._leaveCurrentNamespace();
}
else if (tn === $.SVG && this.currentNamespace === NS.SVG ||
tn === $.MATH && this.currentNamespace === NS.MATHML)
this._leaveCurrentNamespace();
// NOTE: adjust end tag name as well for consistency
if (this.currentNamespace === NS.SVG)
foreignContent.adjustTokenSVGTagName(token);
};

View File

@@ -1,162 +1,176 @@
'use strict';
var defaultTreeAdapter = require('../tree_adapters/default'),
mergeOptions = require('../utils/merge_options'),
doctype = require('../common/doctype'),
HTML = require('../common/html');
const defaultTreeAdapter = require('../tree-adapters/default');
const mergeOptions = require('../utils/merge-options');
const doctype = require('../common/doctype');
const HTML = require('../common/html');
//Aliases
var $ = HTML.TAG_NAMES,
NS = HTML.NAMESPACES;
const $ = HTML.TAG_NAMES;
const NS = HTML.NAMESPACES;
//Default serializer options
var DEFAULT_OPTIONS = {
const DEFAULT_OPTIONS = {
treeAdapter: defaultTreeAdapter
};
//Escaping regexes
var AMP_REGEX = /&/g,
NBSP_REGEX = /\u00a0/g,
DOUBLE_QUOTE_REGEX = /"/g,
LT_REGEX = /</g,
GT_REGEX = />/g;
const AMP_REGEX = /&/g;
const NBSP_REGEX = /\u00a0/g;
const DOUBLE_QUOTE_REGEX = /"/g;
const LT_REGEX = /</g;
const GT_REGEX = />/g;
//Serializer
var Serializer = module.exports = function (node, options) {
this.options = mergeOptions(DEFAULT_OPTIONS, options);
this.treeAdapter = this.options.treeAdapter;
class Serializer {
constructor(node, options) {
this.options = mergeOptions(DEFAULT_OPTIONS, options);
this.treeAdapter = this.options.treeAdapter;
this.html = '';
this.startNode = node;
};
this.html = '';
this.startNode = node;
}
// NOTE: exported as static method for the testing purposes
Serializer.escapeString = function (str, attrMode) {
str = str
.replace(AMP_REGEX, '&amp;')
.replace(NBSP_REGEX, '&nbsp;');
//API
serialize() {
this._serializeChildNodes(this.startNode);
if (attrMode)
return this.html;
}
//Internals
_serializeChildNodes(parentNode) {
const childNodes = this.treeAdapter.getChildNodes(parentNode);
if (childNodes) {
for (let i = 0, cnLength = childNodes.length; i < cnLength; i++) {
const currentNode = childNodes[i];
if (this.treeAdapter.isElementNode(currentNode)) {
this._serializeElement(currentNode);
} else if (this.treeAdapter.isTextNode(currentNode)) {
this._serializeTextNode(currentNode);
} else if (this.treeAdapter.isCommentNode(currentNode)) {
this._serializeCommentNode(currentNode);
} else if (this.treeAdapter.isDocumentTypeNode(currentNode)) {
this._serializeDocumentTypeNode(currentNode);
}
}
}
}
_serializeElement(node) {
const tn = this.treeAdapter.getTagName(node);
const ns = this.treeAdapter.getNamespaceURI(node);
this.html += '<' + tn;
this._serializeAttributes(node);
this.html += '>';
if (
tn !== $.AREA &&
tn !== $.BASE &&
tn !== $.BASEFONT &&
tn !== $.BGSOUND &&
tn !== $.BR &&
tn !== $.COL &&
tn !== $.EMBED &&
tn !== $.FRAME &&
tn !== $.HR &&
tn !== $.IMG &&
tn !== $.INPUT &&
tn !== $.KEYGEN &&
tn !== $.LINK &&
tn !== $.META &&
tn !== $.PARAM &&
tn !== $.SOURCE &&
tn !== $.TRACK &&
tn !== $.WBR
) {
const childNodesHolder =
tn === $.TEMPLATE && ns === NS.HTML ? this.treeAdapter.getTemplateContent(node) : node;
this._serializeChildNodes(childNodesHolder);
this.html += '</' + tn + '>';
}
}
_serializeAttributes(node) {
const attrs = this.treeAdapter.getAttrList(node);
for (let i = 0, attrsLength = attrs.length; i < attrsLength; i++) {
const attr = attrs[i];
const value = Serializer.escapeString(attr.value, true);
this.html += ' ';
if (!attr.namespace) {
this.html += attr.name;
} else if (attr.namespace === NS.XML) {
this.html += 'xml:' + attr.name;
} else if (attr.namespace === NS.XMLNS) {
if (attr.name !== 'xmlns') {
this.html += 'xmlns:';
}
this.html += attr.name;
} else if (attr.namespace === NS.XLINK) {
this.html += 'xlink:' + attr.name;
} else {
this.html += attr.namespace + ':' + attr.name;
}
this.html += '="' + value + '"';
}
}
_serializeTextNode(node) {
const content = this.treeAdapter.getTextNodeContent(node);
const parent = this.treeAdapter.getParentNode(node);
let parentTn = void 0;
if (parent && this.treeAdapter.isElementNode(parent)) {
parentTn = this.treeAdapter.getTagName(parent);
}
if (
parentTn === $.STYLE ||
parentTn === $.SCRIPT ||
parentTn === $.XMP ||
parentTn === $.IFRAME ||
parentTn === $.NOEMBED ||
parentTn === $.NOFRAMES ||
parentTn === $.PLAINTEXT ||
parentTn === $.NOSCRIPT
) {
this.html += content;
} else {
this.html += Serializer.escapeString(content, false);
}
}
_serializeCommentNode(node) {
this.html += '<!--' + this.treeAdapter.getCommentNodeContent(node) + '-->';
}
_serializeDocumentTypeNode(node) {
const name = this.treeAdapter.getDocumentTypeNodeName(node);
this.html += '<' + doctype.serializeContent(name, null, null) + '>';
}
}
// NOTE: used in tests and by rewriting stream
Serializer.escapeString = function(str, attrMode) {
str = str.replace(AMP_REGEX, '&amp;').replace(NBSP_REGEX, '&nbsp;');
if (attrMode) {
str = str.replace(DOUBLE_QUOTE_REGEX, '&quot;');
else {
str = str
.replace(LT_REGEX, '&lt;')
.replace(GT_REGEX, '&gt;');
} else {
str = str.replace(LT_REGEX, '&lt;').replace(GT_REGEX, '&gt;');
}
return str;
};
//API
Serializer.prototype.serialize = function () {
this._serializeChildNodes(this.startNode);
return this.html;
};
//Internals
Serializer.prototype._serializeChildNodes = function (parentNode) {
var childNodes = this.treeAdapter.getChildNodes(parentNode);
if (childNodes) {
for (var i = 0, cnLength = childNodes.length; i < cnLength; i++) {
var currentNode = childNodes[i];
if (this.treeAdapter.isElementNode(currentNode))
this._serializeElement(currentNode);
else if (this.treeAdapter.isTextNode(currentNode))
this._serializeTextNode(currentNode);
else if (this.treeAdapter.isCommentNode(currentNode))
this._serializeCommentNode(currentNode);
else if (this.treeAdapter.isDocumentTypeNode(currentNode))
this._serializeDocumentTypeNode(currentNode);
}
}
};
Serializer.prototype._serializeElement = function (node) {
var tn = this.treeAdapter.getTagName(node),
ns = this.treeAdapter.getNamespaceURI(node);
this.html += '<' + tn;
this._serializeAttributes(node);
this.html += '>';
if (tn !== $.AREA && tn !== $.BASE && tn !== $.BASEFONT && tn !== $.BGSOUND && tn !== $.BR && tn !== $.BR &&
tn !== $.COL && tn !== $.EMBED && tn !== $.FRAME && tn !== $.HR && tn !== $.IMG && tn !== $.INPUT &&
tn !== $.KEYGEN && tn !== $.LINK && tn !== $.MENUITEM && tn !== $.META && tn !== $.PARAM && tn !== $.SOURCE &&
tn !== $.TRACK && tn !== $.WBR) {
var childNodesHolder = tn === $.TEMPLATE && ns === NS.HTML ?
this.treeAdapter.getTemplateContent(node) :
node;
this._serializeChildNodes(childNodesHolder);
this.html += '</' + tn + '>';
}
};
Serializer.prototype._serializeAttributes = function (node) {
var attrs = this.treeAdapter.getAttrList(node);
for (var i = 0, attrsLength = attrs.length; i < attrsLength; i++) {
var attr = attrs[i],
value = Serializer.escapeString(attr.value, true);
this.html += ' ';
if (!attr.namespace)
this.html += attr.name;
else if (attr.namespace === NS.XML)
this.html += 'xml:' + attr.name;
else if (attr.namespace === NS.XMLNS) {
if (attr.name !== 'xmlns')
this.html += 'xmlns:';
this.html += attr.name;
}
else if (attr.namespace === NS.XLINK)
this.html += 'xlink:' + attr.name;
else
this.html += attr.namespace + ':' + attr.name;
this.html += '="' + value + '"';
}
};
Serializer.prototype._serializeTextNode = function (node) {
var content = this.treeAdapter.getTextNodeContent(node),
parent = this.treeAdapter.getParentNode(node),
parentTn = void 0;
if (parent && this.treeAdapter.isElementNode(parent))
parentTn = this.treeAdapter.getTagName(parent);
if (parentTn === $.STYLE || parentTn === $.SCRIPT || parentTn === $.XMP || parentTn === $.IFRAME ||
parentTn === $.NOEMBED || parentTn === $.NOFRAMES || parentTn === $.PLAINTEXT || parentTn === $.NOSCRIPT)
this.html += content;
else
this.html += Serializer.escapeString(content, false);
};
Serializer.prototype._serializeCommentNode = function (node) {
this.html += '<!--' + this.treeAdapter.getCommentNodeContent(node) + '-->';
};
Serializer.prototype._serializeDocumentTypeNode = function (node) {
var name = this.treeAdapter.getDocumentTypeNodeName(node);
this.html += '<' + doctype.serializeContent(name, null, null) + '>';
};
module.exports = Serializer;

View File

@@ -1,28 +0,0 @@
'use strict';
var ReadableStream = require('stream').Readable,
inherits = require('util').inherits,
Serializer = require('./index');
var SerializerStream = module.exports = function (node, options) {
ReadableStream.call(this);
this.serializer = new Serializer(node, options);
Object.defineProperty(this.serializer, 'html', {
//NOTE: To make `+=` concat operator work properly we define
//getter which always returns empty string
get: function () {
return '';
},
set: this.push.bind(this)
});
};
inherits(SerializerStream, ReadableStream);
//Readable stream implementation
SerializerStream.prototype._read = function () {
this.serializer.serialize();
this.push(null);
};

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,147 +1,159 @@
'use strict';
var UNICODE = require('../common/unicode');
const unicode = require('../common/unicode');
const ERR = require('../common/error-codes');
//Aliases
var $ = UNICODE.CODE_POINTS;
//Utils
//OPTIMIZATION: these utility functions should not be moved out of this module. V8 Crankshaft will not inline
//this functions if they will be situated in another module due to context switch.
//Always perform inlining check before modifying this functions ('node --trace-inlining').
function isSurrogatePair(cp1, cp2) {
return cp1 >= 0xD800 && cp1 <= 0xDBFF && cp2 >= 0xDC00 && cp2 <= 0xDFFF;
}
function getSurrogatePairCodePoint(cp1, cp2) {
return (cp1 - 0xD800) * 0x400 + 0x2400 + cp2;
}
const $ = unicode.CODE_POINTS;
//Const
var DEFAULT_BUFFER_WATERLINE = 1 << 16;
const DEFAULT_BUFFER_WATERLINE = 1 << 16;
//Preprocessor
//NOTE: HTML input preprocessing
//(see: http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#preprocessing-the-input-stream)
var Preprocessor = module.exports = function () {
this.html = null;
class Preprocessor {
constructor() {
this.html = null;
this.pos = -1;
this.lastGapPos = -1;
this.lastCharPos = -1;
this.gapStack = [];
this.skipNextNewLine = false;
this.lastChunkWritten = false;
this.endOfChunkHit = false;
this.bufferWaterline = DEFAULT_BUFFER_WATERLINE;
};
Preprocessor.prototype.dropParsedChunk = function () {
if (this.pos > this.bufferWaterline) {
this.lastCharPos -= this.pos;
this.html = this.html.substring(this.pos);
this.pos = 0;
this.pos = -1;
this.lastGapPos = -1;
this.lastCharPos = -1;
this.gapStack = [];
this.skipNextNewLine = false;
this.lastChunkWritten = false;
this.endOfChunkHit = false;
this.bufferWaterline = DEFAULT_BUFFER_WATERLINE;
}
};
Preprocessor.prototype._addGap = function () {
this.gapStack.push(this.lastGapPos);
this.lastGapPos = this.pos;
};
_err() {
// NOTE: err reporting is noop by default. Enabled by mixin.
}
Preprocessor.prototype._processHighRangeCodePoint = function (cp) {
//NOTE: try to peek a surrogate pair
if (this.pos !== this.lastCharPos) {
var nextCp = this.html.charCodeAt(this.pos + 1);
_addGap() {
this.gapStack.push(this.lastGapPos);
this.lastGapPos = this.pos;
}
if (isSurrogatePair(cp, nextCp)) {
//NOTE: we have a surrogate pair. Peek pair character and recalculate code point.
this.pos++;
cp = getSurrogatePairCodePoint(cp, nextCp);
_processSurrogate(cp) {
//NOTE: try to peek a surrogate pair
if (this.pos !== this.lastCharPos) {
const nextCp = this.html.charCodeAt(this.pos + 1);
//NOTE: add gap that should be avoided during retreat
this._addGap();
if (unicode.isSurrogatePair(nextCp)) {
//NOTE: we have a surrogate pair. Peek pair character and recalculate code point.
this.pos++;
//NOTE: add gap that should be avoided during retreat
this._addGap();
return unicode.getSurrogatePairCodePoint(cp, nextCp);
}
}
//NOTE: we are at the end of a chunk, therefore we can't infer surrogate pair yet.
else if (!this.lastChunkWritten) {
this.endOfChunkHit = true;
return $.EOF;
}
//NOTE: isolated surrogate
this._err(ERR.surrogateInInputStream);
return cp;
}
dropParsedChunk() {
if (this.pos > this.bufferWaterline) {
this.lastCharPos -= this.pos;
this.html = this.html.substring(this.pos);
this.pos = 0;
this.lastGapPos = -1;
this.gapStack = [];
}
}
// NOTE: we've hit the end of chunk, stop processing at this point
else if (!this.lastChunkWritten) {
this.endOfChunkHit = true;
return $.EOF;
write(chunk, isLastChunk) {
if (this.html) {
this.html += chunk;
} else {
this.html = chunk;
}
this.lastCharPos = this.html.length - 1;
this.endOfChunkHit = false;
this.lastChunkWritten = isLastChunk;
}
return cp;
};
insertHtmlAtCurrentPos(chunk) {
this.html = this.html.substring(0, this.pos + 1) + chunk + this.html.substring(this.pos + 1, this.html.length);
Preprocessor.prototype.write = function (chunk, isLastChunk) {
if (this.html)
this.html += chunk;
else
this.html = chunk;
this.lastCharPos = this.html.length - 1;
this.endOfChunkHit = false;
this.lastChunkWritten = isLastChunk;
};
Preprocessor.prototype.insertHtmlAtCurrentPos = function (chunk) {
this.html = this.html.substring(0, this.pos + 1) +
chunk +
this.html.substring(this.pos + 1, this.html.length);
this.lastCharPos = this.html.length - 1;
this.endOfChunkHit = false;
};
Preprocessor.prototype.advance = function () {
this.pos++;
if (this.pos > this.lastCharPos) {
if (!this.lastChunkWritten)
this.endOfChunkHit = true;
return $.EOF;
this.lastCharPos = this.html.length - 1;
this.endOfChunkHit = false;
}
var cp = this.html.charCodeAt(this.pos);
advance() {
this.pos++;
if (this.pos > this.lastCharPos) {
this.endOfChunkHit = !this.lastChunkWritten;
return $.EOF;
}
let cp = this.html.charCodeAt(this.pos);
//NOTE: any U+000A LINE FEED (LF) characters that immediately follow a U+000D CARRIAGE RETURN (CR) character
//must be ignored.
if (this.skipNextNewLine && cp === $.LINE_FEED) {
this.skipNextNewLine = false;
this._addGap();
return this.advance();
}
//NOTE: all U+000D CARRIAGE RETURN (CR) characters must be converted to U+000A LINE FEED (LF) characters
if (cp === $.CARRIAGE_RETURN) {
this.skipNextNewLine = true;
return $.LINE_FEED;
}
//NOTE: any U+000A LINE FEED (LF) characters that immediately follow a U+000D CARRIAGE RETURN (CR) character
//must be ignored.
if (this.skipNextNewLine && cp === $.LINE_FEED) {
this.skipNextNewLine = false;
this._addGap();
return this.advance();
if (unicode.isSurrogate(cp)) {
cp = this._processSurrogate(cp);
}
//OPTIMIZATION: first check if code point is in the common allowed
//range (ASCII alphanumeric, whitespaces, big chunk of BMP)
//before going into detailed performance cost validation.
const isCommonValidRange =
(cp > 0x1f && cp < 0x7f) || cp === $.LINE_FEED || cp === $.CARRIAGE_RETURN || (cp > 0x9f && cp < 0xfdd0);
if (!isCommonValidRange) {
this._checkForProblematicCharacters(cp);
}
return cp;
}
//NOTE: all U+000D CARRIAGE RETURN (CR) characters must be converted to U+000A LINE FEED (LF) characters
if (cp === $.CARRIAGE_RETURN) {
this.skipNextNewLine = true;
return $.LINE_FEED;
_checkForProblematicCharacters(cp) {
if (unicode.isControlCodePoint(cp)) {
this._err(ERR.controlCharacterInInputStream);
} else if (unicode.isUndefinedCodePoint(cp)) {
this._err(ERR.noncharacterInInputStream);
}
}
this.skipNextNewLine = false;
retreat() {
if (this.pos === this.lastGapPos) {
this.lastGapPos = this.gapStack.pop();
this.pos--;
}
//OPTIMIZATION: first perform check if the code point in the allowed range that covers most common
//HTML input (e.g. ASCII codes) to avoid performance-cost operations for high-range code points.
return cp >= 0xD800 ? this._processHighRangeCodePoint(cp) : cp;
};
Preprocessor.prototype.retreat = function () {
if (this.pos === this.lastGapPos) {
this.lastGapPos = this.gapStack.pop();
this.pos--;
}
}
this.pos--;
};
module.exports = Preprocessor;

217
node_modules/parse5/lib/tree-adapters/default.js generated vendored Normal file
View File

@@ -0,0 +1,217 @@
'use strict';
const { DOCUMENT_MODE } = require('../common/html');
//Node construction
exports.createDocument = function() {
return {
nodeName: '#document',
mode: DOCUMENT_MODE.NO_QUIRKS,
childNodes: []
};
};
exports.createDocumentFragment = function() {
return {
nodeName: '#document-fragment',
childNodes: []
};
};
exports.createElement = function(tagName, namespaceURI, attrs) {
return {
nodeName: tagName,
tagName: tagName,
attrs: attrs,
namespaceURI: namespaceURI,
childNodes: [],
parentNode: null
};
};
exports.createCommentNode = function(data) {
return {
nodeName: '#comment',
data: data,
parentNode: null
};
};
const createTextNode = function(value) {
return {
nodeName: '#text',
value: value,
parentNode: null
};
};
//Tree mutation
const appendChild = (exports.appendChild = function(parentNode, newNode) {
parentNode.childNodes.push(newNode);
newNode.parentNode = parentNode;
});
const insertBefore = (exports.insertBefore = function(parentNode, newNode, referenceNode) {
const insertionIdx = parentNode.childNodes.indexOf(referenceNode);
parentNode.childNodes.splice(insertionIdx, 0, newNode);
newNode.parentNode = parentNode;
});
exports.setTemplateContent = function(templateElement, contentElement) {
templateElement.content = contentElement;
};
exports.getTemplateContent = function(templateElement) {
return templateElement.content;
};
exports.setDocumentType = function(document, name, publicId, systemId) {
let doctypeNode = null;
for (let i = 0; i < document.childNodes.length; i++) {
if (document.childNodes[i].nodeName === '#documentType') {
doctypeNode = document.childNodes[i];
break;
}
}
if (doctypeNode) {
doctypeNode.name = name;
doctypeNode.publicId = publicId;
doctypeNode.systemId = systemId;
} else {
appendChild(document, {
nodeName: '#documentType',
name: name,
publicId: publicId,
systemId: systemId
});
}
};
exports.setDocumentMode = function(document, mode) {
document.mode = mode;
};
exports.getDocumentMode = function(document) {
return document.mode;
};
exports.detachNode = function(node) {
if (node.parentNode) {
const idx = node.parentNode.childNodes.indexOf(node);
node.parentNode.childNodes.splice(idx, 1);
node.parentNode = null;
}
};
exports.insertText = function(parentNode, text) {
if (parentNode.childNodes.length) {
const prevNode = parentNode.childNodes[parentNode.childNodes.length - 1];
if (prevNode.nodeName === '#text') {
prevNode.value += text;
return;
}
}
appendChild(parentNode, createTextNode(text));
};
exports.insertTextBefore = function(parentNode, text, referenceNode) {
const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
if (prevNode && prevNode.nodeName === '#text') {
prevNode.value += text;
} else {
insertBefore(parentNode, createTextNode(text), referenceNode);
}
};
exports.adoptAttributes = function(recipient, attrs) {
const recipientAttrsMap = [];
for (let i = 0; i < recipient.attrs.length; i++) {
recipientAttrsMap.push(recipient.attrs[i].name);
}
for (let j = 0; j < attrs.length; j++) {
if (recipientAttrsMap.indexOf(attrs[j].name) === -1) {
recipient.attrs.push(attrs[j]);
}
}
};
//Tree traversing
exports.getFirstChild = function(node) {
return node.childNodes[0];
};
exports.getChildNodes = function(node) {
return node.childNodes;
};
exports.getParentNode = function(node) {
return node.parentNode;
};
exports.getAttrList = function(element) {
return element.attrs;
};
//Node data
exports.getTagName = function(element) {
return element.tagName;
};
exports.getNamespaceURI = function(element) {
return element.namespaceURI;
};
exports.getTextNodeContent = function(textNode) {
return textNode.value;
};
exports.getCommentNodeContent = function(commentNode) {
return commentNode.data;
};
exports.getDocumentTypeNodeName = function(doctypeNode) {
return doctypeNode.name;
};
exports.getDocumentTypeNodePublicId = function(doctypeNode) {
return doctypeNode.publicId;
};
exports.getDocumentTypeNodeSystemId = function(doctypeNode) {
return doctypeNode.systemId;
};
//Node types
exports.isTextNode = function(node) {
return node.nodeName === '#text';
};
exports.isCommentNode = function(node) {
return node.nodeName === '#comment';
};
exports.isDocumentTypeNode = function(node) {
return node.nodeName === '#documentType';
};
exports.isElementNode = function(node) {
return !!node.tagName;
};
// Source code location
exports.setNodeSourceCodeLocation = function(node, location) {
node.sourceCodeLocation = location;
};
exports.getNodeSourceCodeLocation = function(node) {
return node.sourceCodeLocation;
};

View File

@@ -1,209 +0,0 @@
'use strict';
var DOCUMENT_MODE = require('../common/html').DOCUMENT_MODE;
//Node construction
exports.createDocument = function () {
return {
nodeName: '#document',
mode: DOCUMENT_MODE.NO_QUIRKS,
childNodes: []
};
};
exports.createDocumentFragment = function () {
return {
nodeName: '#document-fragment',
childNodes: []
};
};
exports.createElement = function (tagName, namespaceURI, attrs) {
return {
nodeName: tagName,
tagName: tagName,
attrs: attrs,
namespaceURI: namespaceURI,
childNodes: [],
parentNode: null
};
};
exports.createCommentNode = function (data) {
return {
nodeName: '#comment',
data: data,
parentNode: null
};
};
var createTextNode = function (value) {
return {
nodeName: '#text',
value: value,
parentNode: null
};
};
//Tree mutation
var appendChild = exports.appendChild = function (parentNode, newNode) {
parentNode.childNodes.push(newNode);
newNode.parentNode = parentNode;
};
var insertBefore = exports.insertBefore = function (parentNode, newNode, referenceNode) {
var insertionIdx = parentNode.childNodes.indexOf(referenceNode);
parentNode.childNodes.splice(insertionIdx, 0, newNode);
newNode.parentNode = parentNode;
};
exports.setTemplateContent = function (templateElement, contentElement) {
templateElement.content = contentElement;
};
exports.getTemplateContent = function (templateElement) {
return templateElement.content;
};
exports.setDocumentType = function (document, name, publicId, systemId) {
var doctypeNode = null;
for (var i = 0; i < document.childNodes.length; i++) {
if (document.childNodes[i].nodeName === '#documentType') {
doctypeNode = document.childNodes[i];
break;
}
}
if (doctypeNode) {
doctypeNode.name = name;
doctypeNode.publicId = publicId;
doctypeNode.systemId = systemId;
}
else {
appendChild(document, {
nodeName: '#documentType',
name: name,
publicId: publicId,
systemId: systemId
});
}
};
exports.setDocumentMode = function (document, mode) {
document.mode = mode;
};
exports.getDocumentMode = function (document) {
return document.mode;
};
exports.detachNode = function (node) {
if (node.parentNode) {
var idx = node.parentNode.childNodes.indexOf(node);
node.parentNode.childNodes.splice(idx, 1);
node.parentNode = null;
}
};
exports.insertText = function (parentNode, text) {
if (parentNode.childNodes.length) {
var prevNode = parentNode.childNodes[parentNode.childNodes.length - 1];
if (prevNode.nodeName === '#text') {
prevNode.value += text;
return;
}
}
appendChild(parentNode, createTextNode(text));
};
exports.insertTextBefore = function (parentNode, text, referenceNode) {
var prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
if (prevNode && prevNode.nodeName === '#text')
prevNode.value += text;
else
insertBefore(parentNode, createTextNode(text), referenceNode);
};
exports.adoptAttributes = function (recipient, attrs) {
var recipientAttrsMap = [];
for (var i = 0; i < recipient.attrs.length; i++)
recipientAttrsMap.push(recipient.attrs[i].name);
for (var j = 0; j < attrs.length; j++) {
if (recipientAttrsMap.indexOf(attrs[j].name) === -1)
recipient.attrs.push(attrs[j]);
}
};
//Tree traversing
exports.getFirstChild = function (node) {
return node.childNodes[0];
};
exports.getChildNodes = function (node) {
return node.childNodes;
};
exports.getParentNode = function (node) {
return node.parentNode;
};
exports.getAttrList = function (element) {
return element.attrs;
};
//Node data
exports.getTagName = function (element) {
return element.tagName;
};
exports.getNamespaceURI = function (element) {
return element.namespaceURI;
};
exports.getTextNodeContent = function (textNode) {
return textNode.value;
};
exports.getCommentNodeContent = function (commentNode) {
return commentNode.data;
};
exports.getDocumentTypeNodeName = function (doctypeNode) {
return doctypeNode.name;
};
exports.getDocumentTypeNodePublicId = function (doctypeNode) {
return doctypeNode.publicId;
};
exports.getDocumentTypeNodeSystemId = function (doctypeNode) {
return doctypeNode.systemId;
};
//Node types
exports.isTextNode = function (node) {
return node.nodeName === '#text';
};
exports.isCommentNode = function (node) {
return node.nodeName === '#comment';
};
exports.isDocumentTypeNode = function (node) {
return node.nodeName === '#documentType';
};
exports.isElementNode = function (node) {
return !!node.tagName;
};

View File

@@ -1,338 +0,0 @@
'use strict';
var doctype = require('../common/doctype'),
DOCUMENT_MODE = require('../common/html').DOCUMENT_MODE;
//Conversion tables for DOM Level1 structure emulation
var nodeTypes = {
element: 1,
text: 3,
cdata: 4,
comment: 8
};
var nodePropertyShorthands = {
tagName: 'name',
childNodes: 'children',
parentNode: 'parent',
previousSibling: 'prev',
nextSibling: 'next',
nodeValue: 'data'
};
//Node
var Node = function (props) {
for (var key in props) {
if (props.hasOwnProperty(key))
this[key] = props[key];
}
};
Node.prototype = {
get firstChild() {
var children = this.children;
return children && children[0] || null;
},
get lastChild() {
var children = this.children;
return children && children[children.length - 1] || null;
},
get nodeType() {
return nodeTypes[this.type] || nodeTypes.element;
}
};
Object.keys(nodePropertyShorthands).forEach(function (key) {
var shorthand = nodePropertyShorthands[key];
Object.defineProperty(Node.prototype, key, {
get: function () {
return this[shorthand] || null;
},
set: function (val) {
this[shorthand] = val;
return val;
}
});
});
//Node construction
exports.createDocument = function () {
return new Node({
type: 'root',
name: 'root',
parent: null,
prev: null,
next: null,
children: [],
'x-mode': DOCUMENT_MODE.NO_QUIRKS
});
};
exports.createDocumentFragment = function () {
return new Node({
type: 'root',
name: 'root',
parent: null,
prev: null,
next: null,
children: []
});
};
exports.createElement = function (tagName, namespaceURI, attrs) {
var attribs = Object.create(null),
attribsNamespace = Object.create(null),
attribsPrefix = Object.create(null);
for (var i = 0; i < attrs.length; i++) {
var attrName = attrs[i].name;
attribs[attrName] = attrs[i].value;
attribsNamespace[attrName] = attrs[i].namespace;
attribsPrefix[attrName] = attrs[i].prefix;
}
return new Node({
type: tagName === 'script' || tagName === 'style' ? tagName : 'tag',
name: tagName,
namespace: namespaceURI,
attribs: attribs,
'x-attribsNamespace': attribsNamespace,
'x-attribsPrefix': attribsPrefix,
children: [],
parent: null,
prev: null,
next: null
});
};
exports.createCommentNode = function (data) {
return new Node({
type: 'comment',
data: data,
parent: null,
prev: null,
next: null
});
};
var createTextNode = function (value) {
return new Node({
type: 'text',
data: value,
parent: null,
prev: null,
next: null
});
};
//Tree mutation
var appendChild = exports.appendChild = function (parentNode, newNode) {
var prev = parentNode.children[parentNode.children.length - 1];
if (prev) {
prev.next = newNode;
newNode.prev = prev;
}
parentNode.children.push(newNode);
newNode.parent = parentNode;
};
var insertBefore = exports.insertBefore = function (parentNode, newNode, referenceNode) {
var insertionIdx = parentNode.children.indexOf(referenceNode),
prev = referenceNode.prev;
if (prev) {
prev.next = newNode;
newNode.prev = prev;
}
referenceNode.prev = newNode;
newNode.next = referenceNode;
parentNode.children.splice(insertionIdx, 0, newNode);
newNode.parent = parentNode;
};
exports.setTemplateContent = function (templateElement, contentElement) {
appendChild(templateElement, contentElement);
};
exports.getTemplateContent = function (templateElement) {
return templateElement.children[0];
};
exports.setDocumentType = function (document, name, publicId, systemId) {
var data = doctype.serializeContent(name, publicId, systemId),
doctypeNode = null;
for (var i = 0; i < document.children.length; i++) {
if (document.children[i].type === 'directive' && document.children[i].name === '!doctype') {
doctypeNode = document.children[i];
break;
}
}
if (doctypeNode) {
doctypeNode.data = data;
doctypeNode['x-name'] = name;
doctypeNode['x-publicId'] = publicId;
doctypeNode['x-systemId'] = systemId;
}
else {
appendChild(document, new Node({
type: 'directive',
name: '!doctype',
data: data,
'x-name': name,
'x-publicId': publicId,
'x-systemId': systemId
}));
}
};
exports.setDocumentMode = function (document, mode) {
document['x-mode'] = mode;
};
exports.getDocumentMode = function (document) {
return document['x-mode'];
};
exports.detachNode = function (node) {
if (node.parent) {
var idx = node.parent.children.indexOf(node),
prev = node.prev,
next = node.next;
node.prev = null;
node.next = null;
if (prev)
prev.next = next;
if (next)
next.prev = prev;
node.parent.children.splice(idx, 1);
node.parent = null;
}
};
exports.insertText = function (parentNode, text) {
var lastChild = parentNode.children[parentNode.children.length - 1];
if (lastChild && lastChild.type === 'text')
lastChild.data += text;
else
appendChild(parentNode, createTextNode(text));
};
exports.insertTextBefore = function (parentNode, text, referenceNode) {
var prevNode = parentNode.children[parentNode.children.indexOf(referenceNode) - 1];
if (prevNode && prevNode.type === 'text')
prevNode.data += text;
else
insertBefore(parentNode, createTextNode(text), referenceNode);
};
exports.adoptAttributes = function (recipient, attrs) {
for (var i = 0; i < attrs.length; i++) {
var attrName = attrs[i].name;
if (typeof recipient.attribs[attrName] === 'undefined') {
recipient.attribs[attrName] = attrs[i].value;
recipient['x-attribsNamespace'][attrName] = attrs[i].namespace;
recipient['x-attribsPrefix'][attrName] = attrs[i].prefix;
}
}
};
//Tree traversing
exports.getFirstChild = function (node) {
return node.children[0];
};
exports.getChildNodes = function (node) {
return node.children;
};
exports.getParentNode = function (node) {
return node.parent;
};
exports.getAttrList = function (element) {
var attrList = [];
for (var name in element.attribs) {
attrList.push({
name: name,
value: element.attribs[name],
namespace: element['x-attribsNamespace'][name],
prefix: element['x-attribsPrefix'][name]
});
}
return attrList;
};
//Node data
exports.getTagName = function (element) {
return element.name;
};
exports.getNamespaceURI = function (element) {
return element.namespace;
};
exports.getTextNodeContent = function (textNode) {
return textNode.data;
};
exports.getCommentNodeContent = function (commentNode) {
return commentNode.data;
};
exports.getDocumentTypeNodeName = function (doctypeNode) {
return doctypeNode['x-name'];
};
exports.getDocumentTypeNodePublicId = function (doctypeNode) {
return doctypeNode['x-publicId'];
};
exports.getDocumentTypeNodeSystemId = function (doctypeNode) {
return doctypeNode['x-systemId'];
};
//Node types
exports.isTextNode = function (node) {
return node.type === 'text';
};
exports.isCommentNode = function (node) {
return node.type === 'comment';
};
exports.isDocumentTypeNode = function (node) {
return node.type === 'directive' && node.name === '!doctype';
};
exports.isElementNode = function (node) {
return !!node.attribs;
};

View File

@@ -3,8 +3,8 @@
module.exports = function mergeOptions(defaults, options) {
options = options || Object.create(null);
return [defaults, options].reduce(function (merged, optObj) {
Object.keys(optObj).forEach(function (key) {
return [defaults, options].reduce((merged, optObj) => {
Object.keys(optObj).forEach(key => {
merged[key] = optObj[key];
});

View File

@@ -1,18 +1,39 @@
'use strict';
var Mixin = module.exports = function (host) {
var originalMethods = {},
overriddenMethods = this._getOverriddenMethods(this, originalMethods);
class Mixin {
constructor(host) {
const originalMethods = {};
const overriddenMethods = this._getOverriddenMethods(this, originalMethods);
Object.keys(overriddenMethods).forEach(function (key) {
if (typeof overriddenMethods[key] === 'function') {
originalMethods[key] = host[key];
host[key] = overriddenMethods[key];
for (const key of Object.keys(overriddenMethods)) {
if (typeof overriddenMethods[key] === 'function') {
originalMethods[key] = host[key];
host[key] = overriddenMethods[key];
}
}
});
};
Mixin.prototype._getOverriddenMethods = function () {
throw new Error('Not implemented');
}
_getOverriddenMethods() {
throw new Error('Not implemented');
}
}
Mixin.install = function(host, Ctor, opts) {
if (!host.__mixins) {
host.__mixins = [];
}
for (let i = 0; i < host.__mixins.length; i++) {
if (host.__mixins[i].constructor === Ctor) {
return host.__mixins[i];
}
}
const mixin = new Ctor(host, opts);
host.__mixins.push(mixin);
return mixin;
};
module.exports = Mixin;

52
node_modules/parse5/package.json generated vendored
View File

@@ -1,27 +1,27 @@
{
"_from": "parse5@4.0.0",
"_id": "parse5@4.0.0",
"_from": "parse5@5.1.0",
"_id": "parse5@5.1.0",
"_inBundle": false,
"_integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==",
"_integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==",
"_location": "/parse5",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "parse5@4.0.0",
"raw": "parse5@5.1.0",
"name": "parse5",
"escapedName": "parse5",
"rawSpec": "4.0.0",
"rawSpec": "5.1.0",
"saveSpec": null,
"fetchSpec": "4.0.0"
"fetchSpec": "5.1.0"
},
"_requiredBy": [
"/jsdom"
],
"_resolved": "https://registry.npmjs.org/parse5/-/parse5-4.0.0.tgz",
"_shasum": "6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608",
"_spec": "parse5@4.0.0",
"_where": "/home/s2/Documents/Code/minifyfromhtml/node_modules/jsdom",
"_resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz",
"_shasum": "c59341c9723f414c452975564c7c00a68d58acd2",
"_spec": "parse5@5.1.0",
"_where": "E:\\projects\\p\\minifyfromhtml\\node_modules\\jsdom",
"author": {
"name": "Ivan Nikulin",
"email": "ifaaan@gmail.com",
@@ -33,24 +33,7 @@
"bundleDependencies": false,
"contributors": "https://github.com/inikulin/parse5/graphs/contributors",
"deprecated": false,
"description": "HTML parsing/serialization toolset for Node.js. WHATWG HTML Living Standard (aka HTML5)-compliant.",
"devDependencies": {
"@types/node": "*",
"del": "^2.0.2",
"gulp": "^3.9.0",
"gulp-benchmark": "^1.1.1",
"gulp-download": "0.0.1",
"gulp-eslint": "^3.0.1",
"gulp-install": "^0.6.0",
"gulp-mocha": "^2.1.3",
"gulp-rename": "^1.2.2",
"gulp-typedoc": "^2.0.0",
"gulp-typescript": "^3.1.2",
"publish-please": "^2.2.0",
"through2": "^2.0.0",
"typedoc": "^0.5.1",
"typescript": "^2.0.6"
},
"description": "HTML parser and serializer.",
"files": [
"lib"
],
@@ -69,12 +52,8 @@
"serializer",
"html serializer",
"htmlserializer",
"sax",
"simple api",
"parse",
"tokenize",
"serialize",
"tokenizer"
"serialize"
],
"license": "MIT",
"main": "./lib/index.js",
@@ -83,10 +62,5 @@
"type": "git",
"url": "git://github.com/inikulin/parse5.git"
},
"scripts": {
"prepublish": "publish-please guard",
"publish-please": "publish-please",
"test": "gulp test"
},
"version": "4.0.0"
"version": "5.1.0"
}