<commit_before>node-sahtml
===========

Fast and low memory API for HTML (node.js).

Returns HTML tokens one-by-one. Does not build DOM (Document Object Model).

Installation
------------

```
npm install sahtml
```

Usage
-----

```javascript
var SAHtml = require('sahtml').SAHtml;

var parser = new SAHtml('<!DOCTYPE html><html><head><title>Example</title></head><body><img src="/logo.png"/><a href="/">Hello World</a></body></html>');
    token;

while ((token = parser.next()).type != 'eof') {
    console.log(token);
}
```

Produces:

```
{ type: 'doctype', value: 'html', pos: 0 }
{ type: 'tagDef', name: 'html', pos: 15 }
{ type: 'tagDefEnd', pos: 20 }
{ type: 'tagDef', name: 'head', pos: 21 }
{ type: 'tagDefEnd', pos: 26 }
{ type: 'tagDef', name: 'title', pos: 27 }
{ type: 'tagDefEnd', pos: 33 }
{ type: 'string', value: 'Example', pos: 34 }
{ type: 'tagClose', name: 'title', pos: 41 }
{ type: 'tagClose', name: 'head', pos: 49 }
{ type: 'tagDef', name: 'body', pos: 56 }<commit_msg>Syntax error in example.<commit_after>node-sahtml
===========

Fast and low memory API for HTML (node.js).

Returns HTML tokens one-by-one. Does not build DOM (Document Object Model).

Installation
------------

```
npm install sahtml
```

Usage
-----

```javascript
var SAHtml = require('sahtml').SAHtml;

var parser = new SAHtml('<!DOCTYPE html><html><head><title>Example</title></head><body><img src="/logo.png"/><a href="/">Hello World</a></body></html>'),
    token;

while ((token = parser.next()).type != 'eof') {
    console.log(token);
}
```

Produces:

```
{ type: 'doctype', value: 'html', pos: 0 }
{ type: 'tagDef', name: 'html', pos: 15 }
{ type: 'tagDefEnd', pos: 20 }
{ type: 'tagDef', name: 'head', pos: 21 }
{ type: 'tagDefEnd', pos: 26 }
{ type: 'tagDef', name: 'title', pos: 27 }
{ type: 'tagDefEnd', pos: 33 }
{ type: 'string', value: 'Example', pos: 34 }
{ type: 'tagClose', name: 'title', pos: 41 }
{ type: 'tagClose', name: 'head', pos: 49 }
{ type: 'tagDef', name: 'body', pos: 56 }
{'fraction_non_alphanumeric': 0.24037981009495252, 'fraction_numerical': 0.020989505247376312, 'mean_word_length': 4.120204603580563, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3031560', 'n_tokens_mistral': 766, 'n_tokens_neox': 705, 'n_words': 211}