syntax-tree / hast-util-from-parse5 Goto Github PK
View Code? Open in Web Editor NEWutility to transform Parse5’s AST to hast
Home Page: https://unifiedjs.com
License: MIT License
utility to transform Parse5’s AST to hast
Home Page: https://unifiedjs.com
License: MIT License
First of all, thank you for creating and open sourcing HAST and Unist. They are very well structured and easy to use.
I noticed a disagreement between the spec and the parser, though. I have the following HTML:
<div block="b1 b2"></div>
The parser returns the following HAST:
{
"type": "element",
"tagName": "div",
"properties": {
"block": "b1 b2"
},
"children": []
}
I expected it to be:
{
"type": "element",
"tagName": "div",
"properties": {
"block": ["b1", "b2"]
},
"children": []
}
Does it work as expected and I should just split the value myself or is it an issue of the parser which should be corrected?
xtend can easily be replaced with Object.assign
// immutable
Object.assign({}, a, b)
// mutable
Object.assign(a, b)
Hi, I tried to parse this file (~887KB) but it will end up in a Maximum call stack size exceeded
error.
1:1 error RangeError: Maximum call stack size exceeded
at String.replace (<anonymous>)
at normalize (E:\Repositorys\prettyhtml\packages\prettyhtml-hastscript\node_modules\property-information\normalize.js:6:30)
at find (E:\Repositorys\prettyhtml\packages\prettyhtml-hastscript\node_modules\property-information\find.js:16:16)
at addProperty (E:\Repositorys\prettyhtml\packages\prettyhtml-hastscript\factory.js:50:12)
at h (E:\Repositorys\prettyhtml\packages\prettyhtml-hastscript\factory.js:25:9)
at element (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\index.js:167:10)
at transform (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\index.js:70:10)
at nodes (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\index.js:99:21)
at transform (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\index.js:67:16)
at nodes (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\index.js:99:21)
the reasons are obvious because there are too many "attributes" which results in too many "normalization" calls. Is there any chance to fix that?
hast-util-from-parse5/index.js
Line 158 in c9b1e27
position(pos.startTag)
could return null
, but that branch isn't expected by the code that fails.
Hi, I forked this repository and need to update some tests but the error message is very cryptic because we have to compare deep objects. How do you deal with that? It's very hard to debug. Do you know a better tape-reporter? (I tried several without success)
not ok 47 p5 w/o position, hast w/o intent of position
---
operator: deepEqual
expected: |-
{ type: 'root', children: [ { type: 'doctype', name: 'html', public: null, system: null }, { type: 'element', tagName: 'html', properties: {}, children: [ { type: 'element', tagName: 'head', properties: [Object], children: [Object] }, { type: 'element', tagName: 'body', properties: [Object], children: [Object] } ] } ], data: { quirksMode: false } }
actual: |-
{ type: 'root', children: [ { type: 'doctype', name: 'html', public: null, system: null }, { type: 'element', tagName: 'html', properties: {}, children: [ { type: 'element', tagName: 'head', properties: [Object], children: [Object] }, { type: 'element', tagName: 'body', properties: [Object], children: [Object] } ] } ], data: { quirksMode: false } }
at: checkNoNo (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\test\index.js:425:7)
stack: |-
Error: p5 w/o position, hast w/o intent of position
at Test.assert [as _assert] (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\node_modules\tape\lib\test.js:224:54)
at Test.bound [as _assert] (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\node_modules\tape\lib\test.js:76:32)
at Test.tapeDeepEqual (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\node_modules\tape\lib\test.js:421:10)
at Test.bound [as deepEqual] (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\node_modules\tape\lib\test.js:76:32)
at checkNoNo (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\test\index.js:425:7)
at Test.<anonymous> (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\test\index.js:370:7)
at Test.bound [as _cb] (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\node_modules\tape\lib\test.js:76:32)
at Test.run (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\node_modules\tape\lib\test.js:95:10)
at Test.bound [as run] (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\node_modules\tape\lib\test.js:76:32)
at Test._end (E:\Repositorys\prettyhtml\packages\prettyhtml-hast-util-from-parse\node_modules\tape\lib\test.js:164:11)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.