hast-util-raw
Advanced tools
Comparing version 6.0.1 to 6.0.2
60
index.js
@@ -133,2 +133,3 @@ 'use strict' | ||
resetTokenizer() | ||
parser._processToken(startTag(node), ns.html) | ||
@@ -139,9 +140,4 @@ | ||
if (!empty) { | ||
resetTokenizer() | ||
parser._processToken(endTag(node)) | ||
// Put the parser back in the data state: some elements, like textareas | ||
// and iframes, change the state. | ||
// See <syntax-tree/hast-util-raw#7>. | ||
// See <https://github.com/inikulin/parse5/blob/2528196/packages/parse5/lib/tokenizer/index.js#L222>. | ||
tokenizer.state = dataState | ||
} | ||
@@ -151,2 +147,3 @@ } | ||
function text(node) { | ||
resetTokenizer() | ||
parser._processToken({ | ||
@@ -161,3 +158,3 @@ type: characterToken, | ||
var p5 = toParse5(node) | ||
resetTokenizer() | ||
parser._processToken({ | ||
@@ -174,2 +171,3 @@ type: doctypeToken, | ||
function comment(node) { | ||
resetTokenizer() | ||
parser._processToken({ | ||
@@ -190,20 +188,23 @@ type: commentToken, | ||
// Reset preprocessor: | ||
// See: <https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/tokenizer/preprocessor.js>. | ||
// See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/tokenizer/preprocessor.js>. | ||
preprocessor.html = null | ||
preprocessor.pos = -1 | ||
preprocessor.lastGapPos = -1 | ||
preprocessor.lastCharPos = -1 | ||
preprocessor.gapStack = [] | ||
preprocessor.skipNextNewLine = false | ||
preprocessor.lastChunkWritten = false | ||
preprocessor.endOfChunkHit = false | ||
preprocessor.lastChunkWritten = false | ||
preprocessor.lastCharPos = -1 | ||
preprocessor.pos = -1 | ||
// Reset preprocessor mixin: | ||
// See: <https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/extensions/position-tracking/preprocessor-mixin.js>. | ||
posTracker.droppedBufferSize = 0 | ||
// See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/extensions/position-tracking/preprocessor-mixin.js>. | ||
posTracker.isEol = false | ||
posTracker.lineStartPos = -column + 1 // Looks weird, but ensures we get correct positional info. | ||
posTracker.droppedBufferSize = offset | ||
posTracker.offset = 0 | ||
posTracker.col = 1 | ||
posTracker.line = line | ||
posTracker.col = 1 | ||
posTracker.offset = 0 | ||
posTracker.lineStartPos = -column + 1 | ||
posTracker.droppedBufferSize = offset | ||
// Reset location tracker: | ||
// See: <https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js>. | ||
// See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js>. | ||
locationTracker.currentAttrLocation = null | ||
@@ -213,3 +214,3 @@ locationTracker.ctLoc = createParse5Location(node) | ||
// See the code for `parse` and `parseFragment`: | ||
// See: <https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/parser/index.js#L371>. | ||
// See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/parser/index.js#L371>. | ||
tokenizer.write(node.value) | ||
@@ -220,3 +221,3 @@ parser._runParsingLoop(null) | ||
// Similar to: | ||
// See: <https://github.com/inikulin/parse5/blob/3bfa7d9/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js#L95>. | ||
// See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js#L95>. | ||
token = tokenizer.currentCharacterToken | ||
@@ -230,7 +231,22 @@ | ||
} | ||
} | ||
function resetTokenizer() { | ||
// Reset tokenizer: | ||
// See: <https://github.com/inikulin/parse5/blob/8b0048e/packages/parse5/lib/tokenizer/index.js#L215>. | ||
// See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/tokenizer/index.js#L218-L234>. | ||
// Especially putting it back in the `data` state is useful: some elements, | ||
// like textareas and iframes, change the state. | ||
// See GH-7. | ||
// But also if broken HTML is in `raw`, and then a correct element is given. | ||
// See GH-11. | ||
tokenizer.tokenQueue = [] | ||
tokenizer.state = dataState | ||
tokenizer.returnState = '' | ||
tokenizer.charRefCode = -1 | ||
tokenizer.tempBuff = [] | ||
tokenizer.lastStartTagName = '' | ||
tokenizer.consumedAfterSnapshot = -1 | ||
tokenizer.active = false | ||
tokenizer.currentCharacterToken = null | ||
tokenizer.currentToken = null | ||
tokenizer.currentCharacterToken = null | ||
tokenizer.currentAttr = null | ||
@@ -237,0 +253,0 @@ } |
{ | ||
"name": "hast-util-raw", | ||
"version": "6.0.1", | ||
"version": "6.0.2", | ||
"description": "hast utility to reparse a tree", | ||
@@ -45,4 +45,4 @@ "license": "MIT", | ||
"devDependencies": { | ||
"browserify": "^16.0.0", | ||
"dtslint": "^3.0.0", | ||
"browserify": "^17.0.0", | ||
"dtslint": "^4.0.0", | ||
"hastscript": "^6.0.0", | ||
@@ -52,6 +52,6 @@ "nyc": "^15.0.0", | ||
"rehype-stringify": "^8.0.0", | ||
"remark-cli": "^8.0.0", | ||
"remark-parse": "^8.0.0", | ||
"remark-preset-wooorm": "^7.0.0", | ||
"remark-rehype": "^7.0.0", | ||
"remark-cli": "^9.0.0", | ||
"remark-parse": "^9.0.0", | ||
"remark-preset-wooorm": "^8.0.0", | ||
"remark-rehype": "^8.0.0", | ||
"tape": "^5.0.0", | ||
@@ -61,8 +61,8 @@ "tinyify": "^3.0.0", | ||
"unist-builder": "^2.0.0", | ||
"xo": "^0.33.0" | ||
"xo": "^0.35.0" | ||
}, | ||
"scripts": { | ||
"format": "remark . -qfo && prettier . --write && xo --fix", | ||
"build-bundle": "browserify index.js -s hastUtilRaw > hast-util-raw.js", | ||
"build-mangle": "browserify index.js -s hastUtilRaw -p tinyify > hast-util-raw.min.js", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"build-bundle": "browserify index.js -s hastUtilRaw -o hast-util-raw.js", | ||
"build-mangle": "browserify index.js -s hastUtilRaw -o hast-util-raw.min.js -p tinyify", | ||
"build": "npm run build-bundle && npm run build-mangle", | ||
@@ -69,0 +69,0 @@ "test-api": "node test", |
@@ -113,5 +113,5 @@ # hast-util-raw | ||
[build-badge]: https://img.shields.io/travis/syntax-tree/hast-util-raw.svg | ||
[build-badge]: https://github.com/syntax-tree/hast-util-raw/workflows/main/badge.svg | ||
[build]: https://travis-ci.org/syntax-tree/hast-util-raw | ||
[build]: https://github.com/syntax-tree/hast-util-raw/actions | ||
@@ -118,0 +118,0 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-raw.svg |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16125
261