Skip to content

Latest commit

 

History

History
63 lines (40 loc) · 1.95 KB

README.md

File metadata and controls

63 lines (40 loc) · 1.95 KB

PEG HTML parser

build status

This is definitely not the fastest HTML/XML parser that runs on JavaScript but is very small and simple, just so it can be easily modified.

The purpose of this project is to be a quick start for playing with PEG.js and especially for those who love LiveScript.

If you want to know more about PEGs syntax and flavors here are the fun staff - Parsing expression grammars.

The whole PEG HTML parser squeezed without comments and empty lines. It is really a collection of grammar rules from which PEG.js can generate JS parser. My inspiration for writing HTML grammar rules was of course W3C HTML5 syntax recommendation.

PEG HTML parser grammar

Installation

Checkout the repo and install node dependencies.

npm i

Optionally, for syntax highlighting in Sublime Text editor, you can install PEGjs LiveScript plugin.

Usage

Watch

On every save of the parser ./src/peg-html-parser.pegls all *.html files from ./test/fixtures will be parsed and the result of parsing and AST will be written in ./.watch folder in YAML format.

npm run watch

Build

Generates the JS parser to ./dist folder (only CommonJS module style).

npm run build

Tests

Executes tests and parses all *.html files from ./test/fixtures.

npm test

License

The MIT License (MIT)