The hast specification and implementation (hastscript) of Doctype (and Root) are different #58
-
Hi, If we run a script like the following: import {h} from 'hastscript'
console.log(h('doctype')) The result in console is as follows: { type: 'element', tagName: 'doctype', properties: {}, children: [] } However, in the hast specification, Doctype is a Doctype object that inherits from Node, not an Element or an object that inherits from Element. Therefore, the specification seem to expect the following: { type: 'doctype' } Also the same thing seems to be happening for Root. IMO there is a problem with either the hast spec or the hastscript. Which is correct? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Both are correct. If you want to add non-element hast type, like doctype, use https://github.com/syntax-tree/unist-builder import { u } from 'unist-builder';
console.log(u('doctype')); |
Beta Was this translation helpful? Give feedback.
Both are correct.
The definition of doctype in hast is correct.
And hastscript generates elements exclusively.
If you want to add non-element hast type, like doctype, use https://github.com/syntax-tree/unist-builder