1.1.2 • Published 10 months ago

html2ast v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

html2ast

html2ast is a tool that converts HTML into an abstract syntax tree (AST), suitable for scenarios where HTML structure needs to be parsed and processed.

Demo

You can view the demo at the following link: Demo address

install

npm i html2ast

Usage exampl

Node.js

import {parse} from 'html2ast'

let tree = parse(`<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>hello world</h1>
</body>
</html>`)

console.log(tree)

UMD

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="https://unpkg.com/html2ast@latest/dist/index.iife.js"></script>
    <script>
        const ast = html2ast.parse('<div><p>hello world</p></div>');
        console.log(ast);
    </script>
</body>
</html>
1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago