added old data

This commit is contained in:
TinyAtoms
2020-08-01 19:26:11 -03:00
commit 276ef453dc
2923 changed files with 307078 additions and 0 deletions

9
project3/node_modules/htmlparser2/test/01-events.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
var helper = require("./test-helper.js");
helper.mochaTest("Events", __dirname, function(test, cb){
helper.writeToParser(
helper.getEventCollector(cb),
test.options.parser,
test.html
);
});

23
project3/node_modules/htmlparser2/test/02-stream.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
var helper = require("./test-helper.js"),
Stream = require("..").WritableStream,
fs = require("fs"),
path = require("path");
helper.mochaTest("Stream", __dirname, function(test, cb){
var filePath = path.join(__dirname, "Documents", test.file);
fs.createReadStream(filePath).pipe(
new Stream(
helper.getEventCollector(function(err, events){
cb(err, events);
var handler = helper.getEventCollector(cb),
stream = new Stream(handler, test.options);
fs.readFile(filePath, function(err, data){
if(err) throw err;
else stream.end(data);
});
}
), test.options)
).on("error", cb);
});

19
project3/node_modules/htmlparser2/test/03-feed.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
//Runs tests for feeds
var helper = require("./test-helper.js"),
FeedHandler = require("..").RssHandler,
fs = require("fs"),
path = require("path");
helper.mochaTest("Feeds", __dirname, function(test, cb){
fs.readFile(
path.join(__dirname, "Documents", test.file),
function(err, file){
helper.writeToParser(
new FeedHandler(cb),
{ xmlMode: true },
file.toString()
);
}
);
});

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- http://en.wikipedia.org/wiki/Atom_%28standard%29 -->
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Feed</title>
<subtitle>A subtitle.</subtitle>
<link href="http://example.org/feed/" rel="self" />
<link href="http://example.org/" />
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
<updated>2003-12-13T18:30:02Z</updated>
<author>
<name>John Doe</name>
<email>johndoe@example.com</email>
</author>
<entry>
<title>Atom-Powered Robots Run Amok</title>
<link href="http://example.org/2003/12/13/atom03" />
<link rel="alternate" type="text/html" href="http://example.org/2003/12/13/atom03.html"/>
<link rel="edit" href="http://example.org/2003/12/13/atom03/edit"/>
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
<updated>2003-12-13T18:30:02Z</updated>
<content type="html"><p>Some content.</p></content>
</entry>
</feed>

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<title>Attributes test</title>
</head>
<body>
<!-- Normal attributes -->
<button id="test0" class="value0" title="value1">class="value0" title="value1"</button>
<!-- Attributes with no quotes or value -->
<button id="test1" class=value2 disabled>class=value2 disabled</button>
<!-- Attributes with no space between them. No valid, but accepted by the browser -->
<button id="test2" class="value4"title="value5">class="value4"title="value5"</button>
</body>
</html>

View File

@@ -0,0 +1 @@
<!DOCTYPE html><html><title>The Title</title><body>Hello world</body></html>

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:ev="http://purl.org/rss/1.0/modules/event/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:admin="http://webns.net/mvcb/">
<channel rdf:about="http://sfbay.craigslist.org/ccc/">
<title>craigslist | all community in SF bay area</title>
<link>http://sfbay.craigslist.org/ccc/</link>
<description/>
<dc:language>en-us</dc:language>
<dc:rights>Copyright 2011 craigslist, inc.</dc:rights>
<dc:publisher>webmaster@craigslist.org</dc:publisher>
<dc:creator>webmaster@craigslist.org</dc:creator>
<dc:source>http://sfbay.craigslist.org/ccc//</dc:source>
<dc:title>craigslist | all community in SF bay area</dc:title>
<dc:type>Collection</dc:type>
<syn:updateBase>2011-11-04T09:39:10-07:00</syn:updateBase>
<syn:updateFrequency>4</syn:updateFrequency>
<syn:updatePeriod>hourly</syn:updatePeriod>
<items>
<rdf:Seq>
<rdf:li rdf:resource="http://sfbay.craigslist.org/sby/muc/2681301534.html"/>
</rdf:Seq>
</items>
</channel>
<item rdf:about="http://sfbay.craigslist.org/sby/muc/2681301534.html">
<title><![CDATA[ Music Equipment Repair and Consignment ]]></title>
<link>
http://sfbay.craigslist.org/sby/muc/2681301534.html
</link>
<description><![CDATA[
San Jose Rock Shop offers musical instrument repair and consignment! (408) 215-2065<br> <br> We are pleased to announce our NEW LOCATION: 1199 N 5th st. San Jose, ca 95112. Please call ahead, by appointment only.<br> <br> Recently featured by Metro Newspaper in their 2011 Best of the Silicon Valley edition see it online here:<br> <a href="http://www.metroactive.com/best-of-silicon-valley/2011/music-nightlife/editor-picks.html" rel="nofollow">http://www.metroactive.com/best-of-silicon-valley/2011/music-nightlife/editor-picks.html</a><br> <br> Guitar Set up (acoustic and electronic) $40!<!-- END CLTAGS -->
]]></description>
<dc:date>2011-11-04T09:35:17-07:00</dc:date>
<dc:language>en-us</dc:language>
<dc:rights>Copyright 2011 craigslist, inc.</dc:rights>
<dc:source>
http://sfbay.craigslist.org/sby/muc/2681301534.html
</dc:source>
<dc:title><![CDATA[ Music Equipment Repair and Consignment ]]></dc:title>
<dc:type>text</dc:type>
<dcterms:issued>2011-11-04T09:35:17-07:00</dcterms:issued>
</item>
<item rdf:about="http://sfbay.craigslist.org/eby/rid/2685010755.html">
<title><![CDATA[
Ride Offered - Oakland/BART to LA/SFV - TODAY 3PM 11/04 (oakland north / temescal)
]]></title>
<link>
http://sfbay.craigslist.org/eby/rid/2685010755.html
</link>
<description><![CDATA[
Im offering a lift for up to two people from Oakland (or near any BART station in the East Bay/580/880 Corridor, or San Jose/Morgan Hill, Gilroy) to the San Fernando Valley / Los Angeles area. Specifically, Im leaving from Oakland between 2:30 and 3:00pm (this is flexible, but if I leave too late my girlfriend will kill me), and heading to Woodland Hills via the 580, I-5, 405, and 101.<!-- END CLTAGS -->
]]></description>
<dc:date>2011-11-04T09:34:54-07:00</dc:date>
<dc:language>en-us</dc:language>
<dc:rights>Copyright 2011 craigslist, inc.</dc:rights>
<dc:source>
http://sfbay.craigslist.org/eby/rid/2685010755.html
</dc:source>
<dc:title><![CDATA[
Ride Offered - Oakland/BART to LA/SFV - TODAY 3PM 11/04 (oakland north / temescal)
]]></dc:title>
<dc:type>text</dc:type>
<dcterms:issued>2011-11-04T09:34:54-07:00</dcterms:issued>
</item>
</rdf:RDF>

View File

@@ -0,0 +1,48 @@
<?xml version="1.0"?>
<!-- http://cyber.law.harvard.edu/rss/examples/rss2sample.xml -->
<rss version="2.0">
<channel>
<title>Liftoff News</title>
<link>http://liftoff.msfc.nasa.gov/</link>
<description>Liftoff to Space Exploration.</description>
<language>en-us</language>
<pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
<lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>Weblog Editor 2.0</generator>
<managingEditor>editor@example.com</managingEditor>
<webMaster>webmaster@example.com</webMaster>
<item>
<title>Star City</title>
<link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
<description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's &lt;a href="http://howe.iki.rssi.ru/GCTC/gctc_e.htm"&gt;Star City&lt;/a&gt;.</description>
<pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid>
</item>
<item>
<description>Sky watchers in Europe, Asia, and parts of Alaska and Canada will experience a &lt;a href="http://science.nasa.gov/headlines/y2003/30may_solareclipse.htm"&gt;partial eclipse of the Sun&lt;/a&gt; on Saturday, May 31st.</description>
<pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/05/30.html#item572</guid>
</item>
<item>
<title>The Engine That Does More</title>
<link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link>
<description>Before man travels to Mars, NASA hopes to design new engines that will let us fly through the Solar System more quickly. The proposed VASIMR engine would do that.</description>
<pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571</guid>
</item>
<item>
<title>Astronauts' Dirty Laundry</title>
<link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link>
<description>Compared to earlier spacecraft, the International Space Station has many luxuries, but laundry facilities are not one of them. Instead, astronauts have other options.</description>
<pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid>
</item>
</channel>
</rss>

View File

@@ -0,0 +1,44 @@
{
"name": "simple",
"options": {
"handler": {},
"parser": {}
},
"html": "<h1 class=test>adsf</h1>",
"expected": [
{
"event": "opentagname",
"data": [
"h1"
]
},
{
"event": "attribute",
"data": [
"class",
"test"
]
},
{
"event": "opentag",
"data": [
"h1",
{
"class": "test"
}
]
},
{
"event": "text",
"data": [
"adsf"
]
},
{
"event": "closetag",
"data": [
"h1"
]
}
]
}

View File

@@ -0,0 +1,63 @@
{
"name": "Template script tags",
"options": {
"handler": {},
"parser": {}
},
"html": "<p><script type=\"text/template\"><h1>Heading1</h1></script></p>",
"expected": [
{
"event": "opentagname",
"data": [
"p"
]
},
{
"event": "opentag",
"data": [
"p",
{}
]
},
{
"event": "opentagname",
"data": [
"script"
]
},
{
"event": "attribute",
"data": [
"type",
"text/template"
]
},
{
"event": "opentag",
"data": [
"script",
{
"type": "text/template"
}
]
},
{
"event": "text",
"data": [
"<h1>Heading1</h1>"
]
},
{
"event": "closetag",
"data": [
"script"
]
},
{
"event": "closetag",
"data": [
"p"
]
}
]
}

View File

@@ -0,0 +1,46 @@
{
"name": "Lowercase tags",
"options": {
"handler": {},
"parser": {
"lowerCaseTags": true
}
},
"html": "<H1 class=test>adsf</H1>",
"expected": [
{
"event": "opentagname",
"data": [
"h1"
]
},
{
"event": "attribute",
"data": [
"class",
"test"
]
},
{
"event": "opentag",
"data": [
"h1",
{
"class": "test"
}
]
},
{
"event": "text",
"data": [
"adsf"
]
},
{
"event": "closetag",
"data": [
"h1"
]
}
]
}

View File

@@ -0,0 +1,50 @@
{
"name": "CDATA",
"options": {
"handler": {},
"parser": {"xmlMode": true}
},
"html": "<tag><![CDATA[ asdf ><asdf></adsf><> fo]]></tag><![CD>",
"expected": [
{
"event": "opentagname",
"data": [
"tag"
]
},
{
"event": "opentag",
"data": [
"tag",
{}
]
},
{
"event": "cdatastart",
"data": []
},
{
"event": "text",
"data": [
" asdf ><asdf></adsf><> fo"
]
},
{
"event": "cdataend",
"data": []
},
{
"event": "closetag",
"data": [
"tag"
]
},
{
"event": "processinginstruction",
"data": [
"![CD",
"![CD"
]
}
]
}

View File

@@ -0,0 +1,35 @@
{
"name": "CDATA (inside special)",
"options": {
"handler": {},
"parser": {}
},
"html": "<script>/*<![CDATA[*/ asdf ><asdf></adsf><> fo/*]]>*/</script>",
"expected": [
{
"event": "opentagname",
"data": [
"script"
]
},
{
"event": "opentag",
"data": [
"script",
{}
]
},
{
"event": "text",
"data": [
"/*<![CDATA[*/ asdf ><asdf></adsf><> fo/*]]>*/"
]
},
{
"event": "closetag",
"data": [
"script"
]
}
]
}

View File

@@ -0,0 +1,16 @@
{
"name": "leading lt",
"options": {
"handler": {},
"parser": {}
},
"html": ">a>",
"expected": [
{
"event": "text",
"data": [
">a>"
]
}
]
}

View File

@@ -0,0 +1,67 @@
{
"name": "Self-closing tags",
"options": {
"handler": {
},
"parser": {
}
},
"html": "<a href=http://test.com/>Foo</a><hr / >",
"expected": [
{
"event": "opentagname",
"data": [
"a"
]
},
{
"event": "attribute",
"data": [
"href",
"http://test.com/"
]
},
{
"event": "opentag",
"data": [
"a",
{
"href": "http://test.com/"
}
]
},
{
"event": "text",
"data": [
"Foo"
]
},
{
"event": "closetag",
"data": [
"a"
]
},
{
"event": "opentagname",
"data": [
"hr"
]
},
{
"event": "opentag",
"data": [
"hr",
{}
]
},
{
"event": "closetag",
"data": [
"hr"
]
}
]
}

View File

@@ -0,0 +1,71 @@
{
"name": "Implicit close tags",
"options": {},
"html": "<ol><li class=test><div><table style=width:100%><tr><th>TH<td colspan=2><h3>Heading</h3><tr><td><div>Div</div><td><div>Div2</div></table></div><li><div><h3>Heading 2</h3></div></li></ol><p>Para<h4>Heading 4</h4>",
"expected": [
{ "event": "opentagname", "data": [ "ol" ] },
{ "event": "opentag", "data": [ "ol", {} ] },
{ "event": "opentagname", "data": [ "li" ] },
{ "event": "attribute", "data": [ "class", "test" ] },
{ "event": "opentag", "data": [ "li", { "class": "test" } ] },
{ "event": "opentagname", "data": [ "div" ] },
{ "event": "opentag", "data": [ "div", {} ] },
{ "event": "opentagname", "data": [ "table" ] },
{ "event": "attribute", "data": [ "style", "width:100%" ] },
{ "event": "opentag", "data": [ "table", { "style": "width:100%" } ] },
{ "event": "opentagname", "data": [ "tr" ] },
{ "event": "opentag", "data": [ "tr", {} ] },
{ "event": "opentagname", "data": [ "th" ] },
{ "event": "opentag", "data": [ "th", {} ] },
{ "event": "text", "data": [ "TH" ] },
{ "event": "closetag", "data": [ "th" ] },
{ "event": "opentagname", "data": [ "td" ] },
{ "event": "attribute", "data": [ "colspan", "2" ] },
{ "event": "opentag", "data": [ "td", { "colspan": "2" } ] },
{ "event": "opentagname", "data": [ "h3" ] },
{ "event": "opentag", "data": [ "h3", {} ] },
{ "event": "text", "data": [ "Heading" ] },
{ "event": "closetag", "data": [ "h3" ] },
{ "event": "closetag", "data": [ "td" ] },
{ "event": "closetag", "data": [ "tr" ] },
{ "event": "opentagname", "data": [ "tr" ] },
{ "event": "opentag", "data": [ "tr", {} ] },
{ "event": "opentagname", "data": [ "td" ] },
{ "event": "opentag", "data": [ "td", {} ] },
{ "event": "opentagname", "data": [ "div" ] },
{ "event": "opentag", "data": [ "div", {} ] },
{ "event": "text", "data": [ "Div" ] },
{ "event": "closetag", "data": [ "div" ] },
{ "event": "closetag", "data": [ "td" ] },
{ "event": "opentagname", "data": [ "td" ] },
{ "event": "opentag", "data": [ "td", {} ] },
{ "event": "opentagname", "data": [ "div" ] },
{ "event": "opentag", "data": [ "div", {} ] },
{ "event": "text", "data": [ "Div2" ] },
{ "event": "closetag", "data": [ "div" ] },
{ "event": "closetag", "data": [ "td" ] },
{ "event": "closetag", "data": [ "tr" ] },
{ "event": "closetag", "data": [ "table" ] },
{ "event": "closetag", "data": [ "div" ] },
{ "event": "closetag", "data": [ "li" ] },
{ "event": "opentagname", "data": [ "li" ] },
{ "event": "opentag", "data": [ "li", {} ] },
{ "event": "opentagname", "data": [ "div" ] },
{ "event": "opentag", "data": [ "div", {} ] },
{ "event": "opentagname", "data": [ "h3" ] },
{ "event": "opentag", "data": [ "h3", {} ] },
{ "event": "text", "data": [ "Heading 2" ] },
{ "event": "closetag", "data": [ "h3" ] },
{ "event": "closetag", "data": [ "div" ] },
{ "event": "closetag", "data": [ "li" ] },
{ "event": "closetag", "data": [ "ol" ] },
{ "event": "opentagname", "data": [ "p" ] },
{ "event": "opentag", "data": [ "p", {} ] },
{ "event": "text", "data": [ "Para" ] },
{ "event": "closetag", "data": [ "p" ] },
{ "event": "opentagname", "data": [ "h4" ] },
{ "event": "opentag", "data": [ "h4", {} ] },
{ "event": "text", "data": [ "Heading 4" ] },
{ "event": "closetag", "data": [ "h4" ] }
]
}

View File

@@ -0,0 +1,68 @@
{
"name": "attributes (no white space, no value, no quotes)",
"options": {
"handler": {},
"parser": {}
},
"html": "<button class=\"test0\"title=\"test1\" disabled value=test2>adsf</button>",
"expected": [
{
"event": "opentagname",
"data": [
"button"
]
},
{
"event": "attribute",
"data": [
"class",
"test0"
]
},
{
"event": "attribute",
"data": [
"title",
"test1"
]
},
{
"event": "attribute",
"data": [
"disabled",
""
]
},
{
"event": "attribute",
"data": [
"value",
"test2"
]
},
{
"event": "opentag",
"data": [
"button",
{
"class": "test0",
"title": "test1",
"disabled": "",
"value": "test2"
}
]
},
{
"event": "text",
"data": [
"adsf"
]
},
{
"event": "closetag",
"data": [
"button"
]
}
]
}

View File

@@ -0,0 +1,52 @@
{
"name": "crazy attribute",
"options": {
"handler": {},
"parser": {}
},
"html": "<p < = '' FAIL>stuff</p><a",
"expected": [
{
"event": "opentagname",
"data": [
"p"
]
},
{
"event": "attribute",
"data": [
"<",
""
]
},
{
"event": "attribute",
"data": [
"fail",
""
]
},
{
"event": "opentag",
"data": [
"p",
{
"<": "",
"fail": ""
}
]
},
{
"event": "text",
"data": [
"stuff"
]
},
{
"event": "closetag",
"data": [
"p"
]
}
]
}

View File

@@ -0,0 +1,54 @@
{
"name": "Scripts creating other scripts",
"options": {
"handler": {},
"parser": {}
},
"html": "<p><script>var str = '<script></'+'script>';</script></p>",
"expected": [
{
"event": "opentagname",
"data": [
"p"
]
},
{
"event": "opentag",
"data": [
"p",
{}
]
},
{
"event": "opentagname",
"data": [
"script"
]
},
{
"event": "opentag",
"data": [
"script",
{}
]
},
{
"event": "text",
"data": [
"var str = '<script></'+'script>';"
]
},
{
"event": "closetag",
"data": [
"script"
]
},
{
"event": "closetag",
"data": [
"p"
]
}
]
}

View File

@@ -0,0 +1,20 @@
{
"name": "Long comment ending",
"options": {
"handler": {},
"parser": {}
},
"html": "<meta id='before'><!-- text ---><meta id='after'>",
"expected": [
{ "event": "opentagname", "data": [ "meta" ] },
{ "event": "attribute", "data": [ "id", "before" ] },
{ "event": "opentag", "data": [ "meta", {"id": "before"} ] },
{ "event": "closetag", "data": [ "meta" ] },
{ "event": "comment", "data": [ " text -" ] },
{ "event": "commentend", "data": [] },
{ "event": "opentagname", "data": [ "meta" ] },
{ "event": "attribute", "data": [ "id", "after" ] },
{ "event": "opentag", "data": [ "meta", {"id": "after"} ] },
{ "event": "closetag", "data": [ "meta" ] }
]
}

View File

@@ -0,0 +1,22 @@
{
"name": "Long CDATA ending",
"options": {
"handler": {},
"parser": {"xmlMode": true}
},
"html": "<before /><tag><![CDATA[ text ]]]></tag><after />",
"expected": [
{ "event": "opentagname", "data": [ "before" ] },
{ "event": "opentag", "data": [ "before", {} ] },
{ "event": "closetag", "data": [ "before" ] },
{ "event": "opentagname", "data": [ "tag" ] },
{ "event": "opentag", "data": [ "tag", {} ] },
{ "event": "cdatastart", "data": [] },
{ "event": "text", "data": [ " text ]" ] },
{ "event": "cdataend", "data": [] },
{ "event": "closetag", "data": [ "tag" ] },
{ "event": "opentagname", "data": [ "after" ] },
{ "event": "opentag", "data": [ "after", {} ] },
{ "event": "closetag", "data": [ "after" ] }
]
}

View File

@@ -0,0 +1,27 @@
{
"name": "Implicit open p and br tags",
"options": {
"handler": {},
"parser": {}
},
"html": "<div>Hallo</p>World</br></ignore></div></p></br>",
"expected": [
{ "event": "opentagname", "data": [ "div" ] },
{ "event": "opentag", "data": [ "div", {} ] },
{ "event": "text", "data": [ "Hallo" ] },
{ "event": "opentagname", "data": [ "p" ] },
{ "event": "opentag", "data": [ "p", {} ] },
{ "event": "closetag", "data": [ "p" ] },
{ "event": "text", "data": [ "World" ] },
{ "event": "opentagname", "data": [ "br" ] },
{ "event": "opentag", "data": [ "br", {} ] },
{ "event": "closetag", "data": [ "br" ] },
{ "event": "closetag", "data": [ "div" ] },
{ "event": "opentagname", "data": [ "p" ] },
{ "event": "opentag", "data": [ "p", {} ] },
{ "event": "closetag", "data": [ "p" ] },
{ "event": "opentagname", "data": [ "br" ] },
{ "event": "opentag", "data": [ "br", {} ] },
{ "event": "closetag", "data": [ "br" ] }
]
}

View File

@@ -0,0 +1,16 @@
{
"name": "lt followed by whitespace",
"options": {
"handler": {},
"parser": {}
},
"html": "a < b",
"expected": [
{
"event": "text",
"data": [
"a < b"
]
}
]
}

View File

@@ -0,0 +1,45 @@
{
"name": "double attribute",
"options": {
"handler": {},
"parser": {}
},
"html": "<h1 class=test class=boo></h1>",
"expected": [
{
"event": "opentagname",
"data": [
"h1"
]
},
{
"event": "attribute",
"data": [
"class",
"test"
]
},
{
"event": "attribute",
"data": [
"class",
"boo"
]
},
{
"event": "opentag",
"data": [
"h1",
{
"class": "test"
}
]
},
{
"event": "closetag",
"data": [
"h1"
]
}
]
}

View File

@@ -0,0 +1,16 @@
{
"name": "numeric entities",
"options": {
"handler": {},
"parser": {"decodeEntities": true}
},
"html": "&#x61;&#x62&#99;&#100&#x66g&#x;&#x68",
"expected": [
{
"event": "text",
"data": [
"abcdfg&#x;h"
]
}
]
}

View File

@@ -0,0 +1,16 @@
{
"name": "legacy entities",
"options": {
"handler": {},
"parser": {"decodeEntities": true}
},
"html": "&AMPel&iacutee&ampeer;s&lter",
"expected": [
{
"event": "text",
"data": [
"&el\u00EDe&eer;s<er"
]
}
]
}

View File

@@ -0,0 +1,16 @@
{
"name": "named entities",
"options": {
"handler": {},
"parser": {"decodeEntities": true}
},
"html": "&amp;el&lt;er&CounterClockwiseContourIntegral;foo&bar",
"expected": [
{
"event": "text",
"data": [
"&el<er\u2233foo&bar"
]
}
]
}

View File

@@ -0,0 +1,16 @@
{
"name": "xml entities",
"options": {
"handler": {},
"parser": {"decodeEntities": true, "xmlMode": true}
},
"html": "&amp;&gt;&amp&lt;&uuml;&#x61;&#x62&#99;&#100&#101",
"expected": [
{
"event": "text",
"data": [
"&>&amp<&uuml;a&#x62c&#100&#101"
]
}
]
}

View File

@@ -0,0 +1,38 @@
{
"name": "entity in attribute",
"options": {
"handler": {},
"parser": {"decodeEntities": true}
},
"html": "<a href='http://example.com/p&#x61;ge?param=value&param2&param3=&lt;val&; & &'>",
"expected": [
{
"event": "opentagname",
"data": [
"a"
]
},
{
"event": "attribute",
"data": [
"href",
"http://example.com/page?param=value&param2&param3=<val&; & &"
]
},
{
"event": "opentag",
"data": [
"a",
{
"href": "http://example.com/page?param=value&param2&param3=<val&; & &"
}
]
},
{
"event": "closetag",
"data": [
"a"
]
}
]
}

View File

@@ -0,0 +1,41 @@
{
"name": "double brackets",
"options": {
"handler": {},
"parser": {}
},
"html": "<<princess-purpose>>testing</princess-purpose>",
"expected": [
{
"event": "text",
"data": [
"<"
]
},
{
"event": "opentagname",
"data": [
"princess-purpose"
]
},
{
"event": "opentag",
"data": [
"princess-purpose",
{}
]
},
{
"event": "text",
"data": [
">testing"
]
},
{
"event": "closetag",
"data": [
"princess-purpose"
]
}
]
}

View File

@@ -0,0 +1,16 @@
{
"name": "legacy entities",
"options": {
"handler": {},
"parser": {"decodeEntities": true}
},
"html": "M&M",
"expected": [
{
"event": "text",
"data": [
"M&M"
]
}
]
}

View File

@@ -0,0 +1,133 @@
{
"name": "Special special tags",
"options": {},
"html": "<sCriPT></scripter</soo</sCript><STyLE></styler</STylE><sCiPt><stylee><scriptee><soo>",
"expected": [
{
"event": "opentagname",
"data": [
"script"
]
},
{
"event": "opentag",
"data": [
"script",
{}
]
},
{
"event": "text",
"data": [
"</scripter</soo"
]
},
{
"event": "closetag",
"data": [
"script"
]
},
{
"event": "opentagname",
"data": [
"style"
]
},
{
"event": "opentag",
"data": [
"style",
{}
]
},
{
"event": "text",
"data": [
"</styler"
]
},
{
"event": "closetag",
"data": [
"style"
]
},
{
"event": "opentagname",
"data": [
"scipt"
]
},
{
"event": "opentag",
"data": [
"scipt",
{}
]
},
{
"event": "opentagname",
"data": [
"stylee"
]
},
{
"event": "opentag",
"data": [
"stylee",
{}
]
},
{
"event": "opentagname",
"data": [
"scriptee"
]
},
{
"event": "opentag",
"data": [
"scriptee",
{}
]
},
{
"event": "opentagname",
"data": [
"soo"
]
},
{
"event": "opentag",
"data": [
"soo",
{}
]
},
{
"event": "closetag",
"data": [
"soo"
]
},
{
"event": "closetag",
"data": [
"scriptee"
]
},
{
"event": "closetag",
"data": [
"stylee"
]
},
{
"event": "closetag",
"data": [
"scipt"
]
}
]
}

View File

@@ -0,0 +1,13 @@
{
"name": "Empty tag name",
"options": {},
"html": "< ></ >",
"expected": [
{
"event": "text",
"data": [
"< ></ >"
]
}
]
}

View File

@@ -0,0 +1,35 @@
{
"name": "Not quite closed",
"options": {},
"html": "<foo /bar></foo bar>",
"expected": [
{
"event": "opentagname",
"data": [
"foo"
]
},
{
"event": "attribute",
"data": [
"bar",
""
]
},
{
"event": "opentag",
"data": [
"foo",
{
"bar": ""
}
]
},
{
"event": "closetag",
"data": [
"foo"
]
}
]
}

View File

@@ -0,0 +1,62 @@
{
"name": "Entities in attributes",
"options": {
"handler": {},
"parser": {"decodeEntities": true}
},
"html": "<foo bar=&amp; baz=\"&amp;\" boo='&amp;' noo=>",
"expected": [
{
"event": "opentagname",
"data": [
"foo"
]
},
{
"event": "attribute",
"data": [
"bar",
"&"
]
},
{
"event": "attribute",
"data": [
"baz",
"&"
]
},
{
"event": "attribute",
"data": [
"boo",
"&"
]
},
{
"event": "attribute",
"data": [
"noo",
""
]
},
{
"event": "opentag",
"data": [
"foo",
{
"bar": "&",
"baz": "&",
"boo": "&",
"noo": ""
}
]
},
{
"event": "closetag",
"data": [
"foo"
]
}
]
}

View File

@@ -0,0 +1,9 @@
{
"name": "CDATA in HTML",
"options": {},
"html": "<![CDATA[ foo ]]>",
"expected": [
{ "event": "comment", "data": [ "[CDATA[ foo ]]" ] },
{ "event": "commentend", "data": [] }
]
}

View File

@@ -0,0 +1,18 @@
{
"name": "Comment edge-cases",
"options": {},
"html": "<!-foo><!-- --- --><!--foo",
"expected": [
{
"event": "processinginstruction",
"data": [
"!-foo",
"!-foo"
]
},
{ "event": "comment", "data": [ " --- " ] },
{ "event": "commentend", "data": [] },
{ "event": "comment", "data": [ "foo" ] },
{ "event": "commentend", "data": [] }
]
}

View File

@@ -0,0 +1,22 @@
{
"name": "CDATA edge-cases",
"options": {
"parser": {"recognizeCDATA": true}
},
"html": "<![CDATA><![CDATA[[]]sdaf]]><![CDATA[foo",
"expected": [
{
"event": "processinginstruction",
"data": [
"![cdata",
"![CDATA"
]
},
{ "event": "cdatastart", "data": [] },
{ "event": "text", "data": [ "[]]sdaf" ] },
{ "event": "cdataend", "data": [] },
{ "event": "cdatastart", "data": [] },
{ "event": "text", "data": [ "foo" ] },
{ "event": "cdataend", "data": [] }
]
}

View File

@@ -0,0 +1,9 @@
{
"name": "Comment false ending",
"options": {},
"html": "<!-- a-b-> -->",
"expected": [
{ "event": "comment", "data": [ " a-b-> " ] },
{ "event": "commentend", "data": [] }
]
}

34
project3/node_modules/htmlparser2/test/Feeds/01-rss.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
exports.name = "RSS (2.0)";
exports.file = "/RSS_Example.xml";
exports.expected = {
type: "rss",
id: "",
title: "Liftoff News",
link: "http://liftoff.msfc.nasa.gov/",
description: "Liftoff to Space Exploration.",
updated: new Date("Tue, 10 Jun 2003 09:41:01 GMT"),
author: "editor@example.com",
items: [{
id: "http://liftoff.msfc.nasa.gov/2003/06/03.html#item573",
title: "Star City",
link: "http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp",
description: "How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's &lt;a href=\"http://howe.iki.rssi.ru/GCTC/gctc_e.htm\"&gt;Star City&lt;/a&gt;.",
pubDate: new Date("Tue, 03 Jun 2003 09:39:21 GMT")
}, {
id: "http://liftoff.msfc.nasa.gov/2003/05/30.html#item572",
description: "Sky watchers in Europe, Asia, and parts of Alaska and Canada will experience a &lt;a href=\"http://science.nasa.gov/headlines/y2003/30may_solareclipse.htm\"&gt;partial eclipse of the Sun&lt;/a&gt; on Saturday, May 31st.",
pubDate: new Date("Fri, 30 May 2003 11:06:42 GMT")
}, {
id: "http://liftoff.msfc.nasa.gov/2003/05/27.html#item571",
title: "The Engine That Does More",
link: "http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp",
description: "Before man travels to Mars, NASA hopes to design new engines that will let us fly through the Solar System more quickly. The proposed VASIMR engine would do that.",
pubDate: new Date("Tue, 27 May 2003 08:37:32 GMT")
}, {
id: "http://liftoff.msfc.nasa.gov/2003/05/20.html#item570",
title: "Astronauts' Dirty Laundry",
link: "http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp",
description: "Compared to earlier spacecraft, the International Space Station has many luxuries, but laundry facilities are not one of them. Instead, astronauts have other options.",
pubDate: new Date("Tue, 20 May 2003 08:56:02 GMT")
}]
};

View File

@@ -0,0 +1,18 @@
exports.name = "Atom (1.0)";
exports.file = "/Atom_Example.xml";
exports.expected = {
type: "atom",
id: "urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6",
title: "Example Feed",
link: "http://example.org/feed/",
description: "A subtitle.",
updated: new Date("2003-12-13T18:30:02Z"),
author: "johndoe@example.com",
items: [{
id: "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a",
title: "Atom-Powered Robots Run Amok",
link: "http://example.org/2003/12/13/atom03",
description: "Some content.",
pubDate: new Date("2003-12-13T18:30:02Z")
}]
};

20
project3/node_modules/htmlparser2/test/Feeds/03-rdf.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
exports.name = "RDF test";
exports.file = "/RDF_Example.xml";
exports.expected = {
"type": "rdf",
"id": "",
"title": "craigslist | all community in SF bay area",
"link": "http://sfbay.craigslist.org/ccc/",
"items": [
{
"title": "Music Equipment Repair and Consignment",
"link": "http://sfbay.craigslist.org/sby/muc/2681301534.html",
"description": "San Jose Rock Shop offers musical instrument repair and consignment! (408) 215-2065<br> <br> We are pleased to announce our NEW LOCATION: 1199 N 5th st. San Jose, ca 95112. Please call ahead, by appointment only.<br> <br> Recently featured by Metro Newspaper in their 2011 Best of the Silicon Valley edition see it online here:<br> <a href=\"http://www.metroactive.com/best-of-silicon-valley/2011/music-nightlife/editor-picks.html\" rel=\"nofollow\">http://www.metroactive.com/best-of-silicon-valley/2011/music-nightlife/editor-picks.html</a><br> <br> Guitar Set up (acoustic and electronic) $40!<!-- END CLTAGS -->"
},
{
"title": "Ride Offered - Oakland/BART to LA/SFV - TODAY 3PM 11/04 (oakland north / temescal)",
"link": "http://sfbay.craigslist.org/eby/rid/2685010755.html",
"description": "Im offering a lift for up to two people from Oakland (or near any BART station in the East Bay/580/880 Corridor, or San Jose/Morgan Hill, Gilroy) to the San Fernando Valley / Los Angeles area. Specifically, Im leaving from Oakland between 2:30 and 3:00pm (this is flexible, but if I leave too late my girlfriend will kill me), and heading to Woodland Hills via the 580, I-5, 405, and 101.<!-- END CLTAGS -->"
}
]
};

View File

@@ -0,0 +1,83 @@
{
"name": "Basic html",
"options": {},
"file": "Basic.html",
"expected": [
{
"event": "processinginstruction",
"data": [
"!doctype",
"!DOCTYPE html"
]
},
{
"event": "opentagname",
"data": [
"html"
]
},
{
"event": "opentag",
"data": [
"html",
{}
]
},
{
"event": "opentagname",
"data": [
"title"
]
},
{
"event": "opentag",
"data": [
"title",
{}
]
},
{
"event": "text",
"data": [
"The Title"
]
},
{
"event": "closetag",
"data": [
"title"
]
},
{
"event": "opentagname",
"data": [
"body"
]
},
{
"event": "opentag",
"data": [
"body",
{}
]
},
{
"event": "text",
"data": [
"Hello world"
]
},
{
"event": "closetag",
"data": [
"body"
]
},
{
"event": "closetag",
"data": [
"html"
]
}
]
}

1093
project3/node_modules/htmlparser2/test/Stream/02-RSS.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,678 @@
{
"name": "Atom feed",
"options": {"xmlMode": true},
"file": "Atom_Example.xml",
"expected": [
{
"event": "processinginstruction",
"data": [
"?xml",
"?xml version=\"1.0\" encoding=\"utf-8\"?"
]
},
{
"event": "text",
"data": [
"\n"
]
},
{
"event": "comment",
"data": [
" http://en.wikipedia.org/wiki/Atom_%28standard%29 "
]
},
{
"event": "commentend",
"data": []
},
{
"event": "text",
"data": [
"\n"
]
},
{
"event": "opentagname",
"data": [
"feed"
]
},
{
"event": "attribute",
"data": [
"xmlns",
"http://www.w3.org/2005/Atom"
]
},
{
"event": "opentag",
"data": [
"feed",
{
"xmlns": "http://www.w3.org/2005/Atom"
}
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"title"
]
},
{
"event": "opentag",
"data": [
"title",
{}
]
},
{
"event": "text",
"data": [
"Example Feed"
]
},
{
"event": "closetag",
"data": [
"title"
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"subtitle"
]
},
{
"event": "opentag",
"data": [
"subtitle",
{}
]
},
{
"event": "text",
"data": [
"A subtitle."
]
},
{
"event": "closetag",
"data": [
"subtitle"
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"link"
]
},
{
"event": "attribute",
"data": [
"href",
"http://example.org/feed/"
]
},
{
"event": "attribute",
"data": [
"rel",
"self"
]
},
{
"event": "opentag",
"data": [
"link",
{
"href": "http://example.org/feed/",
"rel": "self"
}
]
},
{
"event": "closetag",
"data": [
"link"
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"link"
]
},
{
"event": "attribute",
"data": [
"href",
"http://example.org/"
]
},
{
"event": "opentag",
"data": [
"link",
{
"href": "http://example.org/"
}
]
},
{
"event": "closetag",
"data": [
"link"
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"id"
]
},
{
"event": "opentag",
"data": [
"id",
{}
]
},
{
"event": "text",
"data": [
"urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6"
]
},
{
"event": "closetag",
"data": [
"id"
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"updated"
]
},
{
"event": "opentag",
"data": [
"updated",
{}
]
},
{
"event": "text",
"data": [
"2003-12-13T18:30:02Z"
]
},
{
"event": "closetag",
"data": [
"updated"
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"author"
]
},
{
"event": "opentag",
"data": [
"author",
{}
]
},
{
"event": "text",
"data": [
"\n\t\t"
]
},
{
"event": "opentagname",
"data": [
"name"
]
},
{
"event": "opentag",
"data": [
"name",
{}
]
},
{
"event": "text",
"data": [
"John Doe"
]
},
{
"event": "closetag",
"data": [
"name"
]
},
{
"event": "text",
"data": [
"\n\t\t"
]
},
{
"event": "opentagname",
"data": [
"email"
]
},
{
"event": "opentag",
"data": [
"email",
{}
]
},
{
"event": "text",
"data": [
"johndoe@example.com"
]
},
{
"event": "closetag",
"data": [
"email"
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "closetag",
"data": [
"author"
]
},
{
"event": "text",
"data": [
"\n\n\t"
]
},
{
"event": "opentagname",
"data": [
"entry"
]
},
{
"event": "opentag",
"data": [
"entry",
{}
]
},
{
"event": "text",
"data": [
"\n\t\t"
]
},
{
"event": "opentagname",
"data": [
"title"
]
},
{
"event": "opentag",
"data": [
"title",
{}
]
},
{
"event": "text",
"data": [
"Atom-Powered Robots Run Amok"
]
},
{
"event": "closetag",
"data": [
"title"
]
},
{
"event": "text",
"data": [
"\n\t\t"
]
},
{
"event": "opentagname",
"data": [
"link"
]
},
{
"event": "attribute",
"data": [
"href",
"http://example.org/2003/12/13/atom03"
]
},
{
"event": "opentag",
"data": [
"link",
{
"href": "http://example.org/2003/12/13/atom03"
}
]
},
{
"event": "closetag",
"data": [
"link"
]
},
{
"event": "text",
"data": [
"\n\t\t"
]
},
{
"event": "opentagname",
"data": [
"link"
]
},
{
"event": "attribute",
"data": [
"rel",
"alternate"
]
},
{
"event": "attribute",
"data": [
"type",
"text/html"
]
},
{
"event": "attribute",
"data": [
"href",
"http://example.org/2003/12/13/atom03.html"
]
},
{
"event": "opentag",
"data": [
"link",
{
"rel": "alternate",
"type": "text/html",
"href": "http://example.org/2003/12/13/atom03.html"
}
]
},
{
"event": "closetag",
"data": [
"link"
]
},
{
"event": "text",
"data": [
"\n\t\t"
]
},
{
"event": "opentagname",
"data": [
"link"
]
},
{
"event": "attribute",
"data": [
"rel",
"edit"
]
},
{
"event": "attribute",
"data": [
"href",
"http://example.org/2003/12/13/atom03/edit"
]
},
{
"event": "opentag",
"data": [
"link",
{
"rel": "edit",
"href": "http://example.org/2003/12/13/atom03/edit"
}
]
},
{
"event": "closetag",
"data": [
"link"
]
},
{
"event": "text",
"data": [
"\n\t\t"
]
},
{
"event": "opentagname",
"data": [
"id"
]
},
{
"event": "opentag",
"data": [
"id",
{}
]
},
{
"event": "text",
"data": [
"urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a"
]
},
{
"event": "closetag",
"data": [
"id"
]
},
{
"event": "text",
"data": [
"\n\t\t"
]
},
{
"event": "opentagname",
"data": [
"updated"
]
},
{
"event": "opentag",
"data": [
"updated",
{}
]
},
{
"event": "text",
"data": [
"2003-12-13T18:30:02Z"
]
},
{
"event": "closetag",
"data": [
"updated"
]
},
{
"event": "text",
"data": [
"\n\t\t"
]
},
{
"event": "opentagname",
"data": [
"content"
]
},
{
"event": "attribute",
"data": [
"type",
"html"
]
},
{
"event": "opentag",
"data": [
"content",
{
"type": "html"
}
]
},
{
"event": "opentagname",
"data": [
"p"
]
},
{
"event": "opentag",
"data": [
"p",
{}
]
},
{
"event": "text",
"data": [
"Some content."
]
},
{
"event": "closetag",
"data": [
"p"
]
},
{
"event": "closetag",
"data": [
"content"
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "closetag",
"data": [
"entry"
]
},
{
"event": "text",
"data": [
"\n\n"
]
},
{
"event": "closetag",
"data": [
"feed"
]
},
{
"event": "text",
"data": [
"\n"
]
}
]
}

1399
project3/node_modules/htmlparser2/test/Stream/04-RDF.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,354 @@
{
"name": "Attributes",
"options": {},
"file": "Attributes.html",
"expected": [
{
"event": "processinginstruction",
"data": [
"!doctype",
"!doctype html"
]
},
{
"event": "text",
"data": [
"\n"
]
},
{
"event": "opentagname",
"data": [
"html"
]
},
{
"event": "opentag",
"data": [
"html",
{}
]
},
{
"event": "text",
"data": [
"\n"
]
},
{
"event": "opentagname",
"data": [
"head"
]
},
{
"event": "opentag",
"data": [
"head",
{}
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"title"
]
},
{
"event": "opentag",
"data": [
"title",
{}
]
},
{
"event": "text",
"data": [
"Attributes test"
]
},
{
"event": "closetag",
"data": [
"title"
]
},
{
"event": "text",
"data": [
"\n"
]
},
{
"event": "closetag",
"data": [
"head"
]
},
{
"event": "text",
"data": [
"\n"
]
},
{
"event": "opentagname",
"data": [
"body"
]
},
{
"event": "opentag",
"data": [
"body",
{}
]
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "comment",
"data": [
" Normal attributes "
]
},
{
"event": "commentend",
"data": []
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"button"
]
},
{
"event": "attribute",
"data": [
"id",
"test0"
]
},
{
"event": "attribute",
"data": [
"class",
"value0"
]
},
{
"event": "attribute",
"data": [
"title",
"value1"
]
},
{
"event": "opentag",
"data": [
"button",
{
"id": "test0",
"class": "value0",
"title": "value1"
}
]
},
{
"event": "text",
"data": [
"class=\"value0\" title=\"value1\""
]
},
{
"event": "closetag",
"data": [
"button"
]
},
{
"event": "text",
"data": [
"\n\n\t"
]
},
{
"event": "comment",
"data": [
" Attributes with no quotes or value "
]
},
{
"event": "commentend",
"data": []
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"button"
]
},
{
"event": "attribute",
"data": [
"id",
"test1"
]
},
{
"event": "attribute",
"data": [
"class",
"value2"
]
},
{
"event": "attribute",
"data": [
"disabled",
""
]
},
{
"event": "opentag",
"data": [
"button",
{
"id": "test1",
"class": "value2",
"disabled": ""
}
]
},
{
"event": "text",
"data": [
"class=value2 disabled"
]
},
{
"event": "closetag",
"data": [
"button"
]
},
{
"event": "text",
"data": [
"\n\n\t"
]
},
{
"event": "comment",
"data": [
" Attributes with no space between them. No valid, but accepted by the browser "
]
},
{
"event": "commentend",
"data": []
},
{
"event": "text",
"data": [
"\n\t"
]
},
{
"event": "opentagname",
"data": [
"button"
]
},
{
"event": "attribute",
"data": [
"id",
"test2"
]
},
{
"event": "attribute",
"data": [
"class",
"value4"
]
},
{
"event": "attribute",
"data": [
"title",
"value5"
]
},
{
"event": "opentag",
"data": [
"button",
{
"id": "test2",
"class": "value4",
"title": "value5"
}
]
},
{
"event": "text",
"data": [
"class=\"value4\"title=\"value5\""
]
},
{
"event": "closetag",
"data": [
"button"
]
},
{
"event": "text",
"data": [
"\n"
]
},
{
"event": "closetag",
"data": [
"body"
]
},
{
"event": "text",
"data": [
"\n"
]
},
{
"event": "closetag",
"data": [
"html"
]
}
]
}

75
project3/node_modules/htmlparser2/test/api.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
var htmlparser2 = require(".."),
assert = require("assert");
describe("API", function(){
it("should load all modules", function(){
var Stream = require("../lib/Stream.js");
assert.strictEqual(htmlparser2.Stream, Stream, "should load module");
assert.strictEqual(htmlparser2.Stream, Stream, "should load it again (cache)");
var ProxyHandler = require("../lib/ProxyHandler.js");
assert.strictEqual(htmlparser2.ProxyHandler, ProxyHandler, "should load module");
assert.strictEqual(htmlparser2.ProxyHandler, ProxyHandler, "should load it again (cache)");
});
it("should work without callbacks", function(){
var p = new htmlparser2.Parser(null, {xmlMode: true, lowerCaseAttributeNames: true});
p.end("<a foo><bar></a><!-- --><![CDATA[]]]><?foo?><!bar><boo/>boohay");
p.write("foo");
//check for an error
p.end();
var err = false;
p._cbs.onerror = function(){ err = true; };
p.write("foo");
assert(err);
err = false;
p.end();
assert(err);
p.reset();
//remove method
p._cbs.onopentag = function(){};
p.write("<a foo");
p._cbs.onopentag = null;
p.write(">");
//pause/resume
var processed = false;
p._cbs.ontext = function(t){
assert.equal(t, "foo");
processed = true;
};
p.pause();
p.write("foo");
assert(!processed);
p.resume();
assert(processed);
processed = false;
p.pause();
assert(!processed);
p.resume();
assert(!processed);
p.pause();
p.end("foo");
assert(!processed);
p.resume();
assert(processed);
});
it("should update the position", function(){
var p = new htmlparser2.Parser(null);
p.write("foo");
assert.equal(p.startIndex, 0);
p.write("<bar>");
assert.equal(p.startIndex, 3);
});
});

83
project3/node_modules/htmlparser2/test/test-helper.js generated vendored Normal file
View File

@@ -0,0 +1,83 @@
var htmlparser2 = require(".."),
fs = require("fs"),
path = require("path"),
assert = require("assert"),
Parser = htmlparser2.Parser,
CollectingHandler = htmlparser2.CollectingHandler;
exports.writeToParser = function(handler, options, data){
var parser = new Parser(handler, options);
//first, try to run the test via chunks
for(var i = 0; i < data.length; i++){
parser.write(data.charAt(i));
}
parser.end();
//then parse everything
parser.parseComplete(data);
};
//returns a tree structure
exports.getEventCollector = function(cb){
var handler = new CollectingHandler({onerror: cb, onend: onend});
return handler;
function onend(){
cb(null, handler.events.reduce(eventReducer, []));
}
};
function eventReducer(events, arr){
if(arr[0] === "onerror" || arr[0] === "onend");
else if(arr[0] === "ontext" && events.length && events[events.length - 1].event === "text"){
events[events.length - 1].data[0] += arr[1];
} else {
events.push({
event: arr[0].substr(2),
data: arr.slice(1)
});
}
return events;
}
function getCallback(expected, done){
var repeated = false;
return function(err, actual){
assert.ifError(err);
try {
assert.deepEqual(expected, actual, "didn't get expected output");
} catch(e){
e.expected = JSON.stringify(expected, null, 2);
e.actual = JSON.stringify(actual, null, 2);
throw e;
}
if(repeated) done();
else repeated = true;
};
}
exports.mochaTest = function(name, root, test){
describe(name, readDir);
function readDir(){
var dir = path.join(root, name);
fs
.readdirSync(dir)
.filter(RegExp.prototype.test, /^[^\._]/) //ignore all files with a leading dot or underscore
.map(function(name){
return path.join(dir, name);
})
.map(require)
.forEach(runTest);
}
function runTest(file){
it(file.name, function(done){
test(file, getCallback(file.expected, done));
});
}
};