├── .gitignore
├── .gitattributes
├── test
├── Documents
│ ├── Basic.html
│ ├── Attributes.html
│ ├── Atom_Example.xml
│ ├── RSS_Example.xml
│ └── RDF_Example.xml
├── 01-events.js
├── Events
│ ├── 25-empty_tag_name.json
│ ├── 28-cdata_in_html.json
│ ├── 31-comment_false-ending.json
│ ├── 06-leading-lt.json
│ ├── 15-lt-whitespace.json
│ ├── 23-legacy_entity_fail.json
│ ├── 18-legacy_entities.json
│ ├── 17-numeric_entities.json
│ ├── 19-named_entities.json
│ ├── 20-xml_entities.json
│ ├── 29-comment_edge-cases.json
│ ├── 26-not-quite-closed.json
│ ├── 30-cdata_edge-cases.json
│ ├── 32-script-ending-with-lessthan.json
│ ├── 05-cdata-special.json
│ ├── 01-simple.json
│ ├── 22-double_brackets.json
│ ├── 12-long-comment-end.json
│ ├── 16-double_attribs.json
│ ├── 03-lowercase_tags.json
│ ├── 13-long-cdata-end.json
│ ├── 21-entity_in_attribute.json
│ ├── 10-crazy-attrib.json
│ ├── 04-cdata.json
│ ├── 11-script_in_script.json
│ ├── 07-self-closing.json
│ ├── 14-implicit-open-tags.json
│ ├── 27-entities_in_attributes.json
│ ├── 02-template.json
│ ├── 09-attributes.json
│ ├── 24-special_special.json
│ └── 08-implicit-close-tags.json
├── 03-feed.js
├── unicode.js
├── Feeds
│ ├── 02-atom.js
│ ├── 03-rdf.js
│ └── 01-rss.js
├── 02-stream.js
├── Stream
│ ├── 01-basic.json
│ ├── 05-Attributes.json
│ ├── 03-Atom.json
│ ├── 02-RSS.json
│ └── 04-RDF.json
├── test-helper.js
└── api.js
├── .travis.yml
├── README.md
├── lib
├── ProxyHandler.js
├── WritableStream.js
├── Stream.js
├── CollectingHandler.js
├── index.js
├── FeedHandler.js
├── Parser.js
└── Tokenizer.js
├── LICENSE
├── package.json
└── .eslintrc
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/**
2 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text eol=lf
--------------------------------------------------------------------------------
/test/Documents/Basic.html:
--------------------------------------------------------------------------------
1 |
The TitleHello world
--------------------------------------------------------------------------------
/test/01-events.js:
--------------------------------------------------------------------------------
1 | var helper = require("./test-helper.js");
2 |
3 | helper.mochaTest("Events", __dirname, function(test, cb){
4 | helper.writeToParser(
5 | helper.getEventCollector(cb),
6 | test.options.parser,
7 | test.html
8 | );
9 | });
--------------------------------------------------------------------------------
/test/Events/25-empty_tag_name.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Empty tag name",
3 | "options": {},
4 | "html": "< > >",
5 | "expected": [
6 | {
7 | "event": "text",
8 | "data": [
9 | "< > >"
10 | ]
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/test/Events/28-cdata_in_html.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "CDATA in HTML",
3 | "options": {},
4 | "html": "",
5 | "expected": [
6 | { "event": "comment", "data": [ "[CDATA[ foo ]]" ] },
7 | { "event": "commentend", "data": [] }
8 | ]
9 | }
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - stable
4 | - unstable
5 | - 6
6 | - 4
7 | - 0.12
8 |
9 | sudo: false
10 |
11 | matrix:
12 | fast_finish: true
13 | allow_failures:
14 | - node_js: unstable
15 |
16 | script: npm run coveralls
17 |
--------------------------------------------------------------------------------
/test/Events/31-comment_false-ending.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Comment false ending",
3 | "options": {},
4 | "html": "",
5 | "expected": [
6 | { "event": "comment", "data": [ " a-b-> " ] },
7 | { "event": "commentend", "data": [] }
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/test/Events/06-leading-lt.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "leading lt",
3 | "options": {
4 | "handler": {},
5 | "parser": {}
6 | },
7 | "html": ">a>",
8 | "expected": [
9 | {
10 | "event": "text",
11 | "data": [
12 | ">a>"
13 | ]
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/test/Events/15-lt-whitespace.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "lt followed by whitespace",
3 | "options": {
4 | "handler": {},
5 | "parser": {}
6 | },
7 | "html": "a < b",
8 | "expected": [
9 | {
10 | "event": "text",
11 | "data": [
12 | "a < b"
13 | ]
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/test/Events/23-legacy_entity_fail.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "legacy entities",
3 | "options": {
4 | "handler": {},
5 | "parser": {"decodeEntities": true}
6 | },
7 | "html": "M&M",
8 | "expected": [
9 | {
10 | "event": "text",
11 | "data": [
12 | "M&M"
13 | ]
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # htmlparser2-without-node-native
2 |
3 | [htmlparser2](https://github.com/fb55/htmlparser2) build that excludes node native modules so that you can use it in platforms like React Native.
4 |
5 | * Remove `Stream` and `WritableStream`.
6 | * Use [eventemitter2](https://github.com/asyncly/EventEmitter2) instead of native `events`.
7 |
--------------------------------------------------------------------------------
/test/Events/18-legacy_entities.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "legacy entities",
3 | "options": {
4 | "handler": {},
5 | "parser": {"decodeEntities": true}
6 | },
7 | "html": "&elíe&eer;s<er",
8 | "expected": [
9 | {
10 | "event": "text",
11 | "data": [
12 | "&el\u00EDe&eer;s&<üaجde"
13 | ]
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/test/03-feed.js:
--------------------------------------------------------------------------------
1 | //Runs tests for feeds
2 |
3 | var helper = require("./test-helper.js"),
4 | FeedHandler = require("..").RssHandler,
5 | fs = require("fs"),
6 | path = require("path");
7 |
8 | helper.mochaTest("Feeds", __dirname, function(test, cb){
9 | fs.readFile(
10 | path.join(__dirname, "Documents", test.file),
11 | function(err, file){
12 | helper.writeToParser(
13 | new FeedHandler(cb),
14 | { xmlMode: true },
15 | file.toString()
16 | );
17 | }
18 | );
19 | });
--------------------------------------------------------------------------------
/test/Events/29-comment_edge-cases.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Comment edge-cases",
3 | "options": {},
4 | "html": "
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |