Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/schizobulia/antlrv4-js-html
Parsing html by antlr
https://github.com/schizobulia/antlrv4-js-html
Last synced: about 1 month ago
JSON representation
Parsing html by antlr
- Host: GitHub
- URL: https://github.com/schizobulia/antlrv4-js-html
- Owner: schizobulia
- Created: 2022-07-10T07:21:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-10T07:21:39.000Z (over 2 years ago)
- Last Synced: 2024-11-20T00:12:05.105Z (about 1 month ago)
- Language: JavaScript
- Size: 142 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# antlrv4-js-html
## 使用antlrv4的js api 解析html
### 快速开始
```bash
$ npm i antlrv4-js-html
```### 示例
```javascript
const antlrv4_js_html = require('antlrv4-js-html')class Visitor extends antlrv4_js_html.Visitor {
constructor() {
super()
}visitTerminal(ctx) {
let text = ctx.getText()
console.log(text)
return this.visitChildren(ctx);
}
}antlrv4_js_html.transform(`
`, new Visitor())
21
```### 浏览器中使用
```html
console.log(antlrv4_js_html)
```
### 其他模块的支持
- [v] es
- [v] esm
- [v] umd### API
```javascript
// Visit a parse tree produced by HTMLParser#htmlDocument.
visitHtmlDocument(ctx) {
return this.visitChildren(ctx);
}// Visit a parse tree produced by HTMLParser#scriptletOrSeaWs.
visitScriptletOrSeaWs(ctx) {
return this.visitChildren(ctx);
}// Visit a parse tree produced by HTMLParser#htmlElements.
visitHtmlElements(ctx) {
return this.visitChildren(ctx);
}// Visit a parse tree produced by HTMLParser#htmlElement.
visitHtmlElement(ctx) {
return this.visitChildren(ctx);
}// Visit a parse tree produced by HTMLParser#htmlContent.
visitHtmlContent(ctx) {
return this.visitChildren(ctx);
}// Visit a parse tree produced by HTMLParser#htmlAttribute.
visitHtmlAttribute(ctx) {
return this.visitChildren(ctx);
}// Visit a parse tree produced by HTMLParser#htmlChardata.
visitHtmlChardata(ctx) {
return this.visitChildren(ctx);
}// Visit a parse tree produced by HTMLParser#htmlMisc.
visitHtmlMisc(ctx) {
return this.visitChildren(ctx);
}// Visit a parse tree produced by HTMLParser#htmlComment.
visitHtmlComment(ctx) {
return this.visitChildren(ctx);
}// Visit a parse tree produced by HTMLParser#script.
visitScript(ctx) {
return this.visitChildren(ctx);
}// Visit a parse tree produced by HTMLParser#style.
visitStyle(ctx) {
return this.visitChildren(ctx);
}
```### 其他库
- [css3](https://github.com/schizobulia/antlrv4-js-css)
- [xml](https://github.com/schizobulia/antlrv4-js-xml)