0.1.1 • Published 1 year ago

html-vschema v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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": []
}
0.1.1

1 year ago

0.1.0

1 year ago