hast-util-from-parse5
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -7,3 +7,2 @@ 'use strict'; | ||
var vfileLocation = require('vfile-location'); | ||
var has = require('has'); | ||
var h = require('hastscript'); | ||
@@ -14,2 +13,4 @@ | ||
var own = {}.hasOwnProperty; | ||
/* Handlers. */ | ||
@@ -46,3 +47,3 @@ var map = { | ||
function transform(ast, config) { | ||
var fn = has(map, ast.nodeName) ? map[ast.nodeName] : element; | ||
var fn = own.call(map, ast.nodeName) ? map[ast.nodeName] : element; | ||
var children; | ||
@@ -49,0 +50,0 @@ var node; |
{ | ||
"name": "hast-util-from-parse5", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Transform Parse5’s AST to HAST", | ||
@@ -15,4 +15,4 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/wooorm/hast-util-from-parse5", | ||
"bugs": "https://github.com/wooorm/hast-util-from-parse5/issues", | ||
"repository": "https://github.com/syntax-tree/hast-util-from-parse5", | ||
"bugs": "https://github.com/syntax-tree/hast-util-from-parse5/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
@@ -24,3 +24,2 @@ "contributors": [ | ||
"camelcase": "^3.0.0", | ||
"has": "^1.0.1", | ||
"hastscript": "^3.0.0", | ||
@@ -31,14 +30,14 @@ "property-information": "^3.1.0", | ||
"devDependencies": { | ||
"browserify": "^13.0.1", | ||
"browserify": "^14.0.0", | ||
"esmangle": "^1.0.1", | ||
"nyc": "^10.0.0", | ||
"nyc": "^11.0.0", | ||
"parse5": "^3.0.0", | ||
"remark-cli": "^2.0.0", | ||
"remark-preset-wooorm": "^1.0.0", | ||
"remark-cli": "^3.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
"tape": "^4.0.0", | ||
"vfile": "^2.0.0", | ||
"xo": "^0.17.0" | ||
"xo": "^0.18.0" | ||
}, | ||
"scripts": { | ||
"build-md": "remark . --quiet --frail", | ||
"build-md": "remark . -qfo", | ||
"build-bundle": "browserify index.js --bare -s hastUtilFromParse5 > hast-util-from-parse5.js", | ||
@@ -54,2 +53,3 @@ "build-mangle": "esmangle hast-util-from-parse5.js > hast-util-from-parse5.min.js", | ||
"space": true, | ||
"esnext": false, | ||
"rules": { | ||
@@ -69,5 +69,6 @@ "guard-for-in": "off" | ||
"remarkConfig": { | ||
"output": true, | ||
"presets": "wooorm" | ||
"plugins": [ | ||
"preset-wooorm" | ||
] | ||
} | ||
} |
@@ -15,33 +15,27 @@ # hast-util-from-parse5 [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
Dependencies: | ||
Say we have the following file, `example.html`: | ||
```html | ||
<!doctype html><title>Hello!</title><h1 id="world">World!<!--after--> | ||
``` | ||
And our script, `example.js`, looks as follows: | ||
```javascript | ||
var vfile = require('to-vfile'); | ||
var parse5 = require('parse5'); | ||
var inspect = require('unist-util-inspect'); | ||
var vfile = require('vfile'); | ||
var fromParse5 = require('hast-util-from-parse5'); | ||
``` | ||
Fixture: | ||
var doc = vfile.readSync('example.html') | ||
var ast = parse5.parse(String(doc), {locationInfo: true}); | ||
var hast = fromParse5(ast, doc); | ||
```javascript | ||
var doc = '<!doctype html><title>Hello!</title><h1 id="world">World!<!--after-->'; | ||
console.log(inspect(hast)); | ||
``` | ||
Parse: | ||
Now, running `node example` yields: | ||
```javascript | ||
var ast = parse5.parse(doc, {locationInfo: true}); | ||
``` | ||
Transform: | ||
```javascript | ||
var hast = fromParse5(ast, vfile(doc)); | ||
``` | ||
Yields: | ||
```txt | ||
root[2] (1:1-1:70, 0-69) [data={"quirksMode":false}] | ||
```text | ||
root[2] (1:1-2:1, 0-70) [data={"quirksMode":false}] | ||
├─ doctype (1:1-1:16, 0-15) [name="html"] | ||
@@ -53,5 +47,6 @@ └─ element[2] [tagName="html"] | ||
└─ element[1] [tagName="body"] | ||
└─ element[2] (1:37-1:70, 36-69) [tagName="h1"][properties={"id":"world"}] | ||
└─ element[3] (1:37-2:1, 36-70) [tagName="h1"][properties={"id":"world"}] | ||
├─ text: "World!" (1:52-1:58, 51-57) | ||
└─ comment: "after" (1:58-1:70, 57-69) | ||
├─ comment: "after" (1:58-1:70, 57-69) | ||
└─ text: "\n" (1:70-2:1, 69-70) | ||
``` | ||
@@ -134,9 +129,9 @@ | ||
[travis-badge]: https://img.shields.io/travis/wooorm/hast-util-from-parse5.svg | ||
[travis-badge]: https://img.shields.io/travis/syntax-tree/hast-util-from-parse5.svg | ||
[travis]: https://travis-ci.org/wooorm/hast-util-from-parse5 | ||
[travis]: https://travis-ci.org/syntax-tree/hast-util-from-parse5 | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/hast-util-from-parse5.svg | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-from-parse5.svg | ||
[codecov]: https://codecov.io/github/wooorm/hast-util-from-parse5 | ||
[codecov]: https://codecov.io/github/syntax-tree/hast-util-from-parse5 | ||
@@ -149,8 +144,8 @@ [npm-install]: https://docs.npmjs.com/cli/install | ||
[hast]: https://github.com/wooorm/hast | ||
[hast]: https://github.com/syntax-tree/hast | ||
[ast]: https://github.com/inikulin/parse5/wiki/Documentation | ||
[node]: https://github.com/wooorm/hast#ast | ||
[node]: https://github.com/syntax-tree/hast#ast | ||
[vfile]: https://github.com/wooorm/vfile | ||
[vfile]: https://github.com/vfile/vfile |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
10793
4
148
- Removedhas@^1.0.1
- Removedhas@1.0.4(transitive)