reshape-parser
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -37,4 +37,6 @@ const {SAXParser} = require('parse5') | ||
parser.on('endTag', (name) => { | ||
parser.on('endTag', (name, loc) => { | ||
const node = stack.pop() | ||
addEndLocation(node, loc, input) | ||
if (!stack.length) { result.push(node); return } | ||
@@ -80,4 +82,18 @@ pushResult(stack, result, node) | ||
function addLocation (node, loc, options) { | ||
node.location = { line: loc.line, col: loc.col } | ||
const locType = node.type === 'text' ? 'endOffset' : 'startInnerOffset' | ||
node.location = { line: loc.line, col: loc.col, startOffset: loc.startOffset, [locType]: loc.endOffset } | ||
if (options.filename) { node.location.filename = options.filename } | ||
} | ||
function addEndLocation (node, loc, input) { | ||
if (node) { | ||
node.location.endInnerOffset = loc.startOffset; | ||
node.location.endOffset = loc.endOffset; | ||
node.location.innerHTML = input.slice(node.location.startInnerOffset, node.location.endInnerOffset); | ||
node.location.outerHTML = input.slice(node.location.startOffset, node.location.endOffset); | ||
} | ||
} |
{ | ||
"name": "reshape-parser", | ||
"description": "html parser for reshape", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"author": "Jeff Escalante", | ||
@@ -11,9 +11,9 @@ "ava": { | ||
"dependencies": { | ||
"parse5": "^2.1.5" | ||
"parse5": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.16.0", | ||
"ava": "^0.19.0", | ||
"coveralls": "^2.11.12", | ||
"nyc": "^7.1.0", | ||
"standard": "7.x" | ||
"nyc": "^10.0.0", | ||
"standard": "10.0.0" | ||
}, | ||
@@ -24,2 +24,6 @@ "engines": { | ||
"homepage": "https://github.com/reshape/parser", | ||
"keywords": [ | ||
"html", | ||
"parser" | ||
], | ||
"license": "MIT", | ||
@@ -26,0 +30,0 @@ "main": "lib", |
@@ -8,3 +8,3 @@ # Reshape Parser | ||
An html parser for reshape based on [parse5](https://github.com/inikulin/parse5), featuring source location info and more robust node types. | ||
An HTML parser for [reshape](https://github.com/reshape/reshape) based on [parse5](https://github.com/inikulin/parse5), featuring source location info and more robust node types. | ||
@@ -34,3 +34,3 @@ > **Note:** This project is in early development, and versioning is a little different. [Read this](http://markup.im/#q4_cRZ1Q) for more details. | ||
| ---- | ----------- | ------- | | ||
| **filename** | Attach a filename to the `location` info in each node | | | ||
| **filename** | Attach a filename to the `location` info in each node. | | | ||
@@ -37,0 +37,0 @@ ### The Reshape AST |
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
6358
76
4
+ Addedparse5@4.0.0(transitive)
- Removedparse5@2.2.3(transitive)
Updatedparse5@^4.0.0