Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nerdlabs/fast-html

Blazing fast sax-style HTML parser
https://github.com/nerdlabs/fast-html

Last synced: 27 days ago
JSON representation

Blazing fast sax-style HTML parser

Awesome Lists containing this project

README

        

# fast-html [![Build Status][3]][4] [![Coverage Status][5]][6]
fast-html is a sax-style HTML parser focused on performance. It only copes with sane HTML - see the [Things that break](#things-that-break) section.

## Install

```shell
npm install --save fast-html
```

## Docs
[Test-documentation][7] generated with [mocha's][8] "doc" reporter.

## Usage

```js
var fastHtml = require('fast-html')({ parseAttributes: true });

// Receive start tags
fastHtml.on('start', function(tagName, attributes){

});

// Receive text nodes
fastHtml.on('data', function(text){

});

// Receive end tags
fastHtml.on('end', function(tagName)) {

});

// Release the hounds
fastHtml.parse('

  • Hello World
')

```

### Things that break
FastHTML is designed for maximum performance, therefore it will not

* Try to fix broken markup
* Try to fix slightly broken markup
* Try to do automagic closing stuff
* Be graceful about unescaped HTML strings in inline `script`, `style` and HTML attributes

#### Solutions
* `` strings in inline `script` - Use ``.
* HTML strings in attributes - Escape them.

[3]: https://img.shields.io/travis/nerdlabs/fast-html.svg
[4]: https://travis-ci.org/nerdlabs/fast-html
[5]: https://img.shields.io/coveralls/nerdlabs/fast-html.svg
[6]: https://coveralls.io/r/nerdlabs/fast-html
[7]: http://nerdlabs.github.io/fast-html/docs/
[8]: http://mochajs.org/