hast-util-from-parse5
Advanced tools
Comparing version 1.0.0 to 1.1.0
32
index.js
@@ -51,3 +51,4 @@ /** | ||
toPosition: file ? vfileLocation(file).toPosition : null, | ||
verbose: settings.verbose | ||
verbose: settings.verbose, | ||
location: false | ||
}); | ||
@@ -67,2 +68,3 @@ } | ||
var node; | ||
var position; | ||
@@ -76,3 +78,8 @@ if (ast.childNodes) { | ||
if (ast.__location && config.toPosition) { | ||
node.position = location(ast.__location, ast, node, config); | ||
config.location = true; | ||
position = location(ast.__location, ast, node, config); | ||
if (position) { | ||
node.position = position; | ||
} | ||
} | ||
@@ -121,3 +128,3 @@ | ||
if (config.file) { | ||
if (config.file && config.location) { | ||
node.position = location({ | ||
@@ -213,2 +220,3 @@ startOffset: 0, | ||
function location(info, ast, node, config) { | ||
var start = info.startOffset; | ||
var end = info.endOffset; | ||
@@ -232,3 +240,7 @@ var values = info.attrs || {}; | ||
if (reference && reference.position) { | ||
end = reference.position.end.offset; | ||
if (reference.position.end) { | ||
end = reference.position.end.offset; | ||
} else { | ||
end = null; | ||
} | ||
/* Unclosed without children: */ | ||
@@ -250,6 +262,10 @@ } else if (info.startTag) { | ||
return { | ||
start: config.toPosition(info.startOffset), | ||
end: config.toPosition(end) | ||
}; | ||
start = typeof start === 'number' ? config.toPosition(start) : null; | ||
end = typeof end === 'number' ? config.toPosition(end) : null; | ||
if (!start && !end) { | ||
return undefined; | ||
} | ||
return {start: start, end: end}; | ||
} |
{ | ||
"name": "hast-util-from-parse5", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Transform Parse5’s AST to HAST", | ||
@@ -31,14 +31,9 @@ "license": "MIT", | ||
"esmangle": "^1.0.1", | ||
"nyc": "^7.0.0", | ||
"nyc": "^8.3.0", | ||
"parse5": "^2.1.5", | ||
"remark-cli": "^1.0.0", | ||
"remark-comment-config": "^4.0.0", | ||
"remark-github": "^5.0.0", | ||
"remark-lint": "^4.0.0", | ||
"remark-usage": "^4.0.0", | ||
"remark-validate-links": "^4.0.0", | ||
"remark-cli": "^2.0.0", | ||
"remark-preset-wooorm": "^1.0.0", | ||
"tape": "^4.0.0", | ||
"unist-util-inspect": "^4.0.0", | ||
"vfile": "^1.4.0", | ||
"xo": "^0.16.0" | ||
"vfile": "^2.0.0", | ||
"xo": "^0.17.0" | ||
}, | ||
@@ -61,4 +56,3 @@ "scripts": { | ||
"ignores": [ | ||
"hast-util-from-parse5.js", | ||
"hast-util-from-parse5.min.js" | ||
"hast-util-from-parse5.js" | ||
] | ||
@@ -74,18 +68,4 @@ }, | ||
"output": true, | ||
"plugins": { | ||
"comment-config": null, | ||
"github": null, | ||
"usage": null, | ||
"lint": { | ||
"heading-increment": false, | ||
"list-item-spacing": false, | ||
"no-duplicate-headings": false, | ||
"no-missing-blank-lines": false | ||
}, | ||
"validate-links": null | ||
}, | ||
"settings": { | ||
"bullet": "*" | ||
} | ||
"presets": "wooorm" | ||
} | ||
} |
@@ -75,3 +75,3 @@ # hast-util-from-parse5 [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
Whether to add positional information about starting tags, closing tags, | ||
and attributes to elements (`boolean`, default: `false`). Note: not used | ||
and attributes to elements (`boolean`, default: `false`). Note: not used | ||
without `file`. | ||
@@ -78,0 +78,0 @@ |
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
9
230
12196
4