Skip to content

A streaming HTML parser based on HTML Standard. 基于 HTML 标准的流式 HTML 解析器

License

Notifications You must be signed in to change notification settings

weiwang3056/yzhanHTMLParser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yzhanHTMLParser

npm npm GitHub license coverage
A streaming HTML parser based on HTML Standard
一款基于 HTML 标准的流式 HTML 解析器

Demo

You could change HTML Code and view the result in realtime.
Online Demo
DEMO PNG

Setup

Node.js

npm i yzhanhtmlparser
import yzhanHTMLParser from 'yzhanhtmlparser'

Browser

<script src="https://cdn.jsdelivr.net/npm/yzhanhtmlparser@latest/docs/yzhanhtmlparser.min.js"></script>

Usage

Declaration Code

const code = `<html lang="en">
<head>
<title>Page Name</title>
<meta charset="UTF-8">
</head>
<body>
<h1 class="text" id=a>Hello World</h1>
<input type="button" disabled/>
</body>`

Parser · Prase

const parseResult = yzhanHTMLParser.parse(code)

Streaming Usage

const fs = require('node:fs')
const htmlParser = new yzhanHTMLParser.HtmlParser()
/* data.txt: abcde */
fs.createReadStream('./data.txt').pipe(htmlParser)
htmlParser.on('data', char => {
  console.log(char) // a . b . c . d . e
})

Development

Unit Testing

npm test

Unit Testing Coverage

npm run test:coverage

Build

npm run build

Preview

npm run dev

About

A streaming HTML parser based on HTML Standard. 基于 HTML 标准的流式 HTML 解析器

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 55.2%
  • JavaScript 38.2%
  • CSS 6.6%