html-vschema
v0.1.1
Published
HTML VSchema creates a simplified and manipulable schema of html.
Downloads
3
Maintainers
Readme
html-vschema
html-vschema
creates a simplified and manipulable schema of html.
Usage
<html>
<body>
<h1 class="text-2xl font-bold">HTML VSchema</h1>
</body>
</html>
const schema = getSchema(document.body);
{
"tagName": "body",
"attributes": {},
"children": [
{
"tagName": "h1",
"attributes": {
"class": "text-2xl font-bold"
},
"children": [
{
"text": "HTML VSchema"
}
]
}
]
}
With Options
ref
const schema = getSchema(document.body, { ref: true });
{
"ref": Element
"tagName": "body",
"attributes": {},
"children": [
{
"ref": Element,
"tagName": "h1",
"attributes": {
"class": "text-2xl font-bold"
},
"children": [
{
"ref": Text,
"text": "HTML VSchema"
}
]
}
]
}
ignoreTags
const schema = getSchema(document.body, { ignoreTags: ["h1"] });
{
"tagName": "body",
"attributes": {},
"children": []
}