Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reshape-parser

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reshape-parser - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

20

lib/index.js

@@ -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);
}
}

14

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc