html-vschema
creates a simplified and manipulable schema of html.
<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"
}
]
}
]
}
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"
}
]
}
]
}
const schema = getSchema(document.body, { ignoreTags: ["h1"] });
{
"tagName": "body",
"attributes": {},
"children": []
}