Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4 from irvingc/binifying

Binifying
  • Loading branch information...
commit e4345fc96b67dd52d5b5c45779afad8cb95dc3f4 2 parents d9b8648 + d677cd2
@badlee authored
Showing with 14 additions and 131,228 deletions.
  1. +2 −0  .gitignore
  2. +7 −1 README.md
  3. +5 −4 jscc.js → bin/jscc
  4. +0 −3  gitEtapes
  5. 0  { → lib}/driver_node.js_
  6. BIN  node
  7. BIN  node_modules/htmlparser/.DS_Store
  8. +0 −17 node_modules/htmlparser/.project
  9. +0 −17 node_modules/htmlparser/.project.bak
  10. +0 −6 node_modules/htmlparser/.settings/.jsdtscope
  11. +0 −1  node_modules/htmlparser/.settings/org.eclipse.wst.jsdt.ui.superType.container
  12. +0 −1  node_modules/htmlparser/.settings/org.eclipse.wst.jsdt.ui.superType.name
  13. +0 −108 node_modules/htmlparser/.tmp_runtests.html.51164~
  14. +0 −108 node_modules/htmlparser/.tmp_runtests.min.html.92328~
  15. +0 −33 node_modules/htmlparser/CHANGELOG
  16. +0 −18 node_modules/htmlparser/LICENSE
  17. +0 −186 node_modules/htmlparser/README.md
  18. +0 −35 node_modules/htmlparser/a
  19. +0 −35 node_modules/htmlparser/b
  20. +0 −35 node_modules/htmlparser/c
  21. +0 −482 node_modules/htmlparser/json2.js
  22. +0 −822 node_modules/htmlparser/lib/htmlparser.js
  23. +0 −22 node_modules/htmlparser/lib/htmlparser.min.js
  24. +0 −6 node_modules/htmlparser/lib/node-htmlparser.js
  25. +0 −6 node_modules/htmlparser/lib/node-htmlparser.min.js
  26. BIN  node_modules/htmlparser/libxmljs.node
  27. +0 −54 node_modules/htmlparser/newparser.js
  28. +0 −754 node_modules/htmlparser/node-htmlparser.old.js
  29. +0 −23 node_modules/htmlparser/package.json
  30. +0 −4 node_modules/htmlparser/profile
  31. +0 −53 node_modules/htmlparser/profile.getelement.js
  32. +0 −199 node_modules/htmlparser/profile.getelement.txt
  33. +0 −63 node_modules/htmlparser/profile.js
  34. +0 −301 node_modules/htmlparser/profileresults.txt
  35. +0 −9 node_modules/htmlparser/pulls/node-htmlparser/CHANGELOG
  36. +0 −18 node_modules/htmlparser/pulls/node-htmlparser/LICENSE
  37. +0 −186 node_modules/htmlparser/pulls/node-htmlparser/README.md
  38. +0 −482 node_modules/htmlparser/pulls/node-htmlparser/json2.js
  39. +0 −772 node_modules/htmlparser/pulls/node-htmlparser/lib/node-htmlparser.js
  40. +0 −22 node_modules/htmlparser/pulls/node-htmlparser/lib/node-htmlparser.min.js
  41. +0 −23 node_modules/htmlparser/pulls/node-htmlparser/package.json
  42. +0 −63 node_modules/htmlparser/pulls/node-htmlparser/profile.js
  43. +0 −107 node_modules/htmlparser/pulls/node-htmlparser/runtests.html
  44. +0 −75 node_modules/htmlparser/pulls/node-htmlparser/runtests.js
  45. +0 −107 node_modules/htmlparser/pulls/node-htmlparser/runtests.min.html
  46. +0 −75 node_modules/htmlparser/pulls/node-htmlparser/runtests.min.js
  47. +0 −15 node_modules/htmlparser/pulls/node-htmlparser/snippet.js
  48. +0 −57 node_modules/htmlparser/pulls/node-htmlparser/tests/01-basic.js
  49. +0 −35 node_modules/htmlparser/pulls/node-htmlparser/tests/02-single_tag_1.js
  50. +0 −36 node_modules/htmlparser/pulls/node-htmlparser/tests/03-single_tag_2.js
  51. +0 −52 node_modules/htmlparser/pulls/node-htmlparser/tests/04-unescaped_in_script.js
  52. +0 −44 node_modules/htmlparser/pulls/node-htmlparser/tests/05-tags_in_comment.js
  53. +0 −44 node_modules/htmlparser/pulls/node-htmlparser/tests/06-comment_in_script.js
  54. +0 −45 node_modules/htmlparser/pulls/node-htmlparser/tests/07-unescaped_in_style.js
  55. +0 −45 node_modules/htmlparser/pulls/node-htmlparser/tests/08-extra_spaces_in_tag.js
  56. +0 −45 node_modules/htmlparser/pulls/node-htmlparser/tests/09-unquoted_attrib.js
  57. +0 −39 node_modules/htmlparser/pulls/node-htmlparser/tests/10-singular_attribute.js
  58. +0 −46 node_modules/htmlparser/pulls/node-htmlparser/tests/11-text_outside_tags.js
  59. +0 −37 node_modules/htmlparser/pulls/node-htmlparser/tests/12-text_only.js
  60. +0 −45 node_modules/htmlparser/pulls/node-htmlparser/tests/13-comment_in_text.js
  61. +0 −53 node_modules/htmlparser/pulls/node-htmlparser/tests/14-comment_in_text_in_script.js
  62. +0 −43 node_modules/htmlparser/pulls/node-htmlparser/tests/15-non-verbose.js
  63. +0 −68 node_modules/htmlparser/pulls/node-htmlparser/tests/16-ignore_whitespace.js
  64. +0 −34 node_modules/htmlparser/pulls/node-htmlparser/tests/17-xml_namespace.js
  65. +0 −36 node_modules/htmlparser/pulls/node-htmlparser/tests/18-enforce_empty_tags.js
  66. +0 −38 node_modules/htmlparser/pulls/node-htmlparser/tests/19-ignore_empty_tags.js
  67. +0 −117 node_modules/htmlparser/pulls/node-htmlparser/tests/20-rss.js
  68. +0 −77 node_modules/htmlparser/pulls/node-htmlparser/tests/21-atom.js
  69. +0 −35 node_modules/htmlparser/pulls/node-htmlparser/utils_example.js
  70. +0 −16 node_modules/htmlparser/rssbug.js
  71. +0 −1  node_modules/htmlparser/rssbug.rss
  72. +0 −108 node_modules/htmlparser/runtests.html
  73. +0 −75 node_modules/htmlparser/runtests.js
  74. +0 −108 node_modules/htmlparser/runtests.min.html
  75. +0 −75 node_modules/htmlparser/runtests.min.js
  76. +0 −15 node_modules/htmlparser/snippet.js
  77. +0 −11 node_modules/htmlparser/testdata/.tmp_test.html.2854~
  78. +0 −2,948 node_modules/htmlparser/testdata/.tmp_trackerchecker.html.65425~
  79. +0 −10 node_modules/htmlparser/testdata/.tmp_trackerchecker.html.76922~
  80. +0 −2,948 node_modules/htmlparser/testdata/.tmp_trackerchecker.html.80022~
  81. +0 −2,948 node_modules/htmlparser/testdata/.tmp_trackerchecker2.html.51378~
  82. +0 −2,947 node_modules/htmlparser/testdata/.tmp_trackerchecker2.html.75287~
  83. +0 −3,311 node_modules/htmlparser/testdata/api.html
  84. +0 −3,460 node_modules/htmlparser/testdata/getelement.html
  85. +0 −2,733 node_modules/htmlparser/testdata/trackerchecker.html
  86. +0 −61 node_modules/htmlparser/tests/01-basic.js
  87. +0 −39 node_modules/htmlparser/tests/02-single_tag_1.js
  88. +0 −40 node_modules/htmlparser/tests/03-single_tag_2.js
  89. +0 −56 node_modules/htmlparser/tests/04-unescaped_in_script.js
  90. +0 −48 node_modules/htmlparser/tests/05-tags_in_comment.js
  91. +0 −48 node_modules/htmlparser/tests/06-comment_in_script.js
  92. +0 −49 node_modules/htmlparser/tests/07-unescaped_in_style.js
  93. +0 −49 node_modules/htmlparser/tests/08-extra_spaces_in_tag.js
  94. +0 −49 node_modules/htmlparser/tests/09-unquoted_attrib.js
  95. +0 −43 node_modules/htmlparser/tests/10-singular_attribute.js
  96. +0 −50 node_modules/htmlparser/tests/11-text_outside_tags.js
  97. +0 −41 node_modules/htmlparser/tests/12-text_only.js
  98. +0 −49 node_modules/htmlparser/tests/13-comment_in_text.js
  99. +0 −57 node_modules/htmlparser/tests/14-comment_in_text_in_script.js
  100. +0 −46 node_modules/htmlparser/tests/15-non-verbose.js
  101. +0 −71 node_modules/htmlparser/tests/16-ignore_whitespace.js
  102. +0 −38 node_modules/htmlparser/tests/17-xml_namespace.js
  103. +0 −40 node_modules/htmlparser/tests/18-enforce_empty_tags.js
  104. +0 −41 node_modules/htmlparser/tests/19-ignore_empty_tags.js
  105. +0 −120 node_modules/htmlparser/tests/20-rss.js
  106. +0 −80 node_modules/htmlparser/tests/21-atom.js
  107. +0 −100 node_modules/htmlparser/tests/22-position_data.js
  108. +0 −35 node_modules/htmlparser/utils_example.js
  109. +0 −1,956 node_modules/htmlparser/v8.log
  110. BIN  node_modules/jsdom/._README.md
  111. BIN  node_modules/jsdom/._wscript
  112. +0 −5 node_modules/jsdom/.gitignore
  113. +0 −22 node_modules/jsdom/LICENSE.txt
  114. +0 −228 node_modules/jsdom/README.md
  115. +0 −37 node_modules/jsdom/example/browser/browser.js
  116. +0 −167 node_modules/jsdom/example/jquery/jquery.js
  117. +0 −9 node_modules/jsdom/example/jquery/run.js
  118. BIN  node_modules/jsdom/example/node-xml/._example.xml
  119. +0 −243 node_modules/jsdom/example/node-xml/example.xml
  120. +0 −46 node_modules/jsdom/example/node-xml/run.js
  121. BIN  node_modules/jsdom/example/pure/._pure.js
  122. BIN  node_modules/jsdom/example/pure/._sax.js
  123. +0 −743 node_modules/jsdom/example/pure/pure.js
  124. +0 −96 node_modules/jsdom/example/pure/run.js
  125. +0 −10 node_modules/jsdom/example/pure/sax-test.js
  126. +0 −535 node_modules/jsdom/example/pure/sax.js
  127. BIN  node_modules/jsdom/example/sizzle/._sax.js
  128. BIN  node_modules/jsdom/example/sizzle/._sizzle.js
  129. +0 −166 node_modules/jsdom/example/sizzle/run.js
  130. +0 −534 node_modules/jsdom/example/sizzle/sax.js
  131. +0 −1,066 node_modules/jsdom/example/sizzle/sizzle.js
  132. BIN  node_modules/jsdom/lib/._jsdom.js
  133. +0 −325 node_modules/jsdom/lib/jsdom.js
  134. BIN  node_modules/jsdom/lib/jsdom/browser/._index.js
  135. +0 −235 node_modules/jsdom/lib/jsdom/browser/domtohtml.js
  136. +0 −144 node_modules/jsdom/lib/jsdom/browser/htmlencoding.js
  137. +0 −159 node_modules/jsdom/lib/jsdom/browser/htmltodom.js
  138. +0 −485 node_modules/jsdom/lib/jsdom/browser/index.js
  139. +0 −1,814 node_modules/jsdom/lib/jsdom/level1/core.js
  140. BIN  node_modules/jsdom/lib/jsdom/level2/._core.js
  141. BIN  node_modules/jsdom/lib/jsdom/level2/._events.js
  142. +0 −663 node_modules/jsdom/lib/jsdom/level2/core.js
  143. +0 −423 node_modules/jsdom/lib/jsdom/level2/events.js
  144. +0 −1,607 node_modules/jsdom/lib/jsdom/level2/html.js
  145. +0 −7 node_modules/jsdom/lib/jsdom/level2/index.js
  146. +0 −24 node_modules/jsdom/lib/jsdom/level2/languages/javascript.js
  147. BIN  node_modules/jsdom/lib/jsdom/level3/._core.js
  148. BIN  node_modules/jsdom/lib/jsdom/level3/._events.js
  149. BIN  node_modules/jsdom/lib/jsdom/level3/._html.js
  150. BIN  node_modules/jsdom/lib/jsdom/level3/._index.js
  151. +0 −573 node_modules/jsdom/lib/jsdom/level3/core.js
  152. +0 −296 node_modules/jsdom/lib/jsdom/level3/events.js
  153. +0 −9 node_modules/jsdom/lib/jsdom/level3/html.js
  154. +0 −7 node_modules/jsdom/lib/jsdom/level3/index.js
  155. +0 −28 node_modules/jsdom/lib/jsdom/selectors/index.js
  156. +0 −1,016 node_modules/jsdom/lib/jsdom/selectors/sizzle.js
  157. +0 −94 node_modules/jsdom/package.json
  158. +0 −22 node_modules/jsdom/status.json
  159. BIN  node_modules/jsdom/test/._DOMTestCase.js
  160. BIN  node_modules/jsdom/test/._mjsunit.js
  161. +0 −282 node_modules/jsdom/test/DOMTestCase.js
  162. +0 −4 node_modules/jsdom/test/LICENSE.txt
  163. BIN  node_modules/jsdom/test/browser/._index.js
  164. +0 −6,883 node_modules/jsdom/test/browser/files/js/jquery.js
  165. +0 −252 node_modules/jsdom/test/browser/files/site.html
  166. +0 −216 node_modules/jsdom/test/browser/index.js
  167. +0 −36 node_modules/jsdom/test/collector.php
  168. +0 −8 node_modules/jsdom/test/env.html
  169. BIN  node_modules/jsdom/test/jsdom/._index.js
  170. BIN  node_modules/jsdom/test/jsdom/files/._env.html
  171. +0 −8 node_modules/jsdom/test/jsdom/files/env.html
  172. +0 −1  node_modules/jsdom/test/jsdom/files/hello.js
  173. +0 −497 node_modules/jsdom/test/jsdom/index.js
  174. +0 −24,402 node_modules/jsdom/test/level1/core.js
  175. BIN  node_modules/jsdom/test/level1/core/files/._hc_staff.xml.js
  176. +0 −13 node_modules/jsdom/test/level1/core/files/extra.xml.js
  177. +0 −27 node_modules/jsdom/test/level1/core/files/hc_nodtdstaff.xml.js
  178. +0 −236 node_modules/jsdom/test/level1/core/files/hc_staff.xml.js
  179. +0 −153 node_modules/jsdom/test/level1/core/files/staff.xml.js
  180. +0 −11,082 node_modules/jsdom/test/level1/html.js
  181. +0 −27 node_modules/jsdom/test/level1/html/files/hc_nodtdstaff.html.js
  182. +0 −235 node_modules/jsdom/test/level1/html/files/hc_staff.html.js
  183. +0 −24,321 node_modules/jsdom/test/level1/svg.js
  184. +0 −27 node_modules/jsdom/test/level1/svg/files/hc_nodtdstaff.svg.js
  185. +0 −259 node_modules/jsdom/test/level1/svg/files/hc_staff.svg.js
  186. +0 −275 node_modules/jsdom/test/level1/svg/files/staff.svg.js
  187. BIN  node_modules/jsdom/test/level2/._events.js
  188. +0 −12,955 node_modules/jsdom/test/level2/core.js
  189. BIN  node_modules/jsdom/test/level2/core/files/._hc_staff.xml.js
  190. +0 −159 node_modules/jsdom/test/level2/core/files/hc_staff.xml.js
  191. BIN  node_modules/jsdom/test/level2/core/files/orig/._hc_staff.xhtml
  192. BIN  node_modules/jsdom/test/level2/core/files/orig/._hc_staff.xml
  193. BIN  node_modules/jsdom/test/level2/core/files/orig/._staff.xml
  194. BIN  node_modules/jsdom/test/level2/core/files/orig/._staffNS.dtd
  195. BIN  node_modules/jsdom/test/level2/core/files/orig/._staffNS.xml
  196. BIN  node_modules/jsdom/test/level2/core/files/orig/._svgtest.js
  197. +0 −48 node_modules/jsdom/test/level2/core/files/orig/hc_staff.html
  198. +0 −72 node_modules/jsdom/test/level2/core/files/orig/hc_staff.svg
  199. +0 −60 node_modules/jsdom/test/level2/core/files/orig/hc_staff.xhtml
  200. +0 −60 node_modules/jsdom/test/level2/core/files/orig/hc_staff.xml
  201. +0 −37 node_modules/jsdom/test/level2/core/files/orig/index.html
  202. 0  node_modules/jsdom/test/level2/core/files/orig/internalSubset01.js
  203. +0 −11 node_modules/jsdom/test/level2/core/files/orig/nodtdstaff.svg
  204. +0 −11 node_modules/jsdom/test/level2/core/files/orig/nodtdstaff.xml
  205. +0 −67 node_modules/jsdom/test/level2/core/files/orig/robots.txt
  206. +0 −17 node_modules/jsdom/test/level2/core/files/orig/staff.dtd
  207. +0 −72 node_modules/jsdom/test/level2/core/files/orig/staff.svg
  208. +0 −57 node_modules/jsdom/test/level2/core/files/orig/staff.xml
  209. +0 −24 node_modules/jsdom/test/level2/core/files/orig/staff2.dtd
  210. +0 −13 node_modules/jsdom/test/level2/core/files/orig/staff2.svg
  211. +0 −13 node_modules/jsdom/test/level2/core/files/orig/staff2.xml
  212. +0 −45 node_modules/jsdom/test/level2/core/files/orig/staffNS.dtd
  213. +0 −73 node_modules/jsdom/test/level2/core/files/orig/staffNS.svg
  214. +0 −68 node_modules/jsdom/test/level2/core/files/orig/staffNS.xml
  215. 0  node_modules/jsdom/test/level2/core/files/orig/svgtest.js
  216. 0  node_modules/jsdom/test/level2/core/files/orig/svgunit.js
  217. +0 −196 node_modules/jsdom/test/level2/core/files/orig/xhtml-lat1.ent
  218. +0 −80 node_modules/jsdom/test/level2/core/files/orig/xhtml-special.ent
  219. +0 −237 node_modules/jsdom/test/level2/core/files/orig/xhtml-symbol.ent
  220. +0 −1,235 node_modules/jsdom/test/level2/core/files/orig/xhtml1-frameset.dtd
  221. +0 −65 node_modules/jsdom/test/level2/core/files/orig/xhtml1-strict.dtd
  222. +0 −1,201 node_modules/jsdom/test/level2/core/files/orig/xhtml1-transitional.dtd
  223. +0 −153 node_modules/jsdom/test/level2/core/files/staff.xml.js
  224. +0 −159 node_modules/jsdom/test/level2/core/files/staff2.xml.js
  225. +0 −250 node_modules/jsdom/test/level2/core/files/staffNS.xml.js
  226. +0 −1,366 node_modules/jsdom/test/level2/events.js
Sorry, we could not display the entire diff because too many files (473) changed.
View
2  .gitignore
@@ -0,0 +1,2 @@
+node_modules/
+npm-debug.log
View
8 README.md
@@ -16,9 +16,15 @@ To use JS/CC and for understanding its internals and behaviors, some knowledge o
For all documentation read the `jscc_manual.pdf` in doc/ folder.
+## Installation
+
+ npm install jscc-node
+
+This install a jscc binary inside your node path, that you can run from the shell
+
## HOW TO USE
- node jscc.js [options] filename
+ jscc [options] filename
## OPTIONS
View
9 jscc.js → bin/jscc
@@ -1,5 +1,6 @@
+#!/usr/bin/env node
print = require("util").puts;
-_print = function(str){console.log("__PRINT__\n"+str);};
+_print = function(str){console.log(str);};
_error = function(str){console.log("___ ERROR ___\n"+str);};
_warning = function(str){console.log("--- WARN ---\n"+str);};
alert = function(str){console.log("=== ALERT ===\n"+str);};
@@ -4541,7 +4542,7 @@ function help()
//Initialize the globals
reset_all( EXEC_CONSOLE );
-DEFAULT_DRIVER = "driver_node.js_";
+DEFAULT_DRIVER = __dirname + "/../lib/driver_node.js_";
//Processing the command line arguments
@@ -4634,8 +4635,8 @@ if( src_file != "" )
//LALR(1) parse table generation
first();
- print_symbols( MODE_GEN_TEXT );
- print_grammar( MODE_GEN_TEXT );
+ //print_symbols( MODE_GEN_TEXT );
+ //print_grammar( MODE_GEN_TEXT );
lalr1_parse_table( false );
check_empty_states();
View
3  gitEtapes
@@ -1,3 +0,0 @@
-cd existing_git_repo
-git commit -a -m 'port JS/CC to nodejs'
-git push -u origin master
View
0  driver_node.js_ → lib/driver_node.js_
File renamed without changes
View
BIN  node
Binary file not shown
View
BIN  node_modules/htmlparser/.DS_Store
Binary file not shown
View
17 node_modules/htmlparser/.project
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>NodeHtmlParser</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
- </natures>
-</projectDescription>
View
17 node_modules/htmlparser/.project.bak
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>NodeHtmlParser</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
- </natures>
-</projectDescription>
View
6 node_modules/htmlparser/.settings/.jsdtscope
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path=""/>
- <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
-</classpath>
View
1  node_modules/htmlparser/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -1 +0,0 @@
-org.eclipse.wst.jsdt.launching.baseBrowserLibrary
View
1  node_modules/htmlparser/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -1 +0,0 @@
-Window
View
108 node_modules/htmlparser/.tmp_runtests.html.51164~
@@ -1,108 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Node.js HTML Parser</title>
- <style type="text/css">
- .good {
- color: #363;
- }
- .bad {
- color: #633;
- font-style: italic;
- }
- </style>
- <script language="JavaScript">
- if ((typeof JSON) != "object") {
- var head = document.getElementsByTagName("head")[0];
- var script = document.createElement('script');
- script.type = "text/javascript";
- script.src = "json2.js";
- head.insertBefore(script, head.firstChild)
- }
- </script>
- <script language="JavaScript" src="lib/node-htmlparser.js"></script>
- <script language="JavaScript" src="tests/01-basic.js"></script>
- <script language="JavaScript" src="tests/02-single_tag_1.js"></script>
- <script language="JavaScript" src="tests/03-single_tag_2.js"></script>
- <script language="JavaScript" src="tests/04-unescaped_in_script.js"></script>
- <script language="JavaScript" src="tests/05-tags_in_comment.js"></script>
- <script language="JavaScript" src="tests/06-comment_in_script.js"></script>
- <script language="JavaScript" src="tests/07-unescaped_in_style.js"></script>
- <script language="JavaScript" src="tests/08-extra_spaces_in_tag.js"></script>
- <script language="JavaScript" src="tests/09-unquoted_attrib.js"></script>
- <script language="JavaScript" src="tests/10-singular_attribute.js"></script>
- <script language="JavaScript" src="tests/11-text_outside_tags.js"></script>
- <script language="JavaScript" src="tests/12-text_only.js"></script>
- <script language="JavaScript" src="tests/13-comment_in_text.js"></script>
- <script language="JavaScript" src="tests/14-comment_in_text_in_script.js"></script>
- <script language="JavaScript" src="tests/15-non-verbose.js"></script>
- <script language="JavaScript" src="tests/16-ignore_whitespace.js"></script>
- <script language="JavaScript" src="tests/17-xml_namespace.js"></script>
- <script language="JavaScript" src="tests/18-enforce_empty_tags.js"></script>
- <script language="JavaScript" src="tests/19-ignore_empty_tags.js"></script>
- <script language="JavaScript" src="tests/20-rss.js"></script>
- <script language="JavaScript" src="tests/21-atom.js"></script>
- <script language="JavaScript" src="tests/22-position_data.js"></script>
- <!-- //TODO: dynamic loading of test files -->
- </head>
- <body style="font-size: small; font-family:Arial, Helvetica, sans-serif;">
-
- <script language="JavaScript">
- var chunkSize = 5;
- var testCount = 0;
- var failedCount = 0;
- while (Tautologistics.NodeHtmlParser.Tests.length) {
- testCount++;
- var test = Tautologistics.NodeHtmlParser.Tests.shift();
- try {
- var handlerCallback = function handlerCallback (error) {
- if (error)
- document.write("<hr>Handler error: " + error + "<hr>");
- }
- var handler = (test.type == "rss") ?
- new Tautologistics.NodeHtmlParser.RssHandler(handlerCallback, test.options.handler)
- :
- new Tautologistics.NodeHtmlParser.DefaultHandler(handlerCallback, test.options.handler)
- ;
- var parser = new Tautologistics.NodeHtmlParser.Parser(handler, test.options.parser);
- document.write("<b>" + test.name + "</b>: ");
- parser.parseComplete(test.html);
- var resultComplete = handler.dom;
- var chunkPos = 0;
- parser.reset();
- while (chunkPos < test.html.length) {
- parser.parseChunk(test.html.substring(chunkPos, chunkPos + chunkSize));
- chunkPos += chunkSize;
- }
- parser.done();
- var resultChunk = handler.dom;
- var testResult =
- JSON.stringify(resultComplete).toString() === JSON.stringify(test.expected).toString()
- &&
- JSON.stringify(resultChunk).toString() === JSON.stringify(test.expected).toString()
- ;
- document.write(testResult ? "<font class='good'>passed</font>" : "<font class='bad'>FAILED</font>");
- if (!testResult) {
- failedCount++;
- document.write("<pre>");
- document.write("<b>Complete</b>\n");
- document.write(JSON.stringify(resultComplete, null, 2));
- document.write("<b>Chunked</b>\n");
- document.write(JSON.stringify(resultChunk, null, 2));
- document.write("<h2>Expected</h2>\n");
- document.write(JSON.stringify(test.expected, null, 2));
- document.write("</pre>");
- }
- } catch (ex) {
- document.write("<h1>Exception occured during test: " + ex + "</h1>")
- }
- document.write("<br>");
- }
- document.write("<hr>");
- document.write("Total tests: " + testCount + "<br>");
- document.write("Failed tests: " + failedCount + "<br>");
- </script>
-
- </body>
-</html>
View
108 node_modules/htmlparser/.tmp_runtests.min.html.92328~
@@ -1,108 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Node.js HTML Parser</title>
- <style type="text/css">
- .good {
- color: #363;
- }
- .bad {
- color: #633;
- font-style: italic;
- }
- </style>
- <script language="JavaScript">
- if ((typeof JSON) != "object") {
- var head = document.getElementsByTagName("head")[0];
- var script = document.createElement('script');
- script.type = "text/javascript";
- script.src = "json2.js";
- head.insertBefore(script, head.firstChild)
- }
- </script>
- <script language="JavaScript" src="lib/node-htmlparser.min.js"></script>
- <script language="JavaScript" src="tests/01-basic.js"></script>
- <script language="JavaScript" src="tests/02-single_tag_1.js"></script>
- <script language="JavaScript" src="tests/03-single_tag_2.js"></script>
- <script language="JavaScript" src="tests/04-unescaped_in_script.js"></script>
- <script language="JavaScript" src="tests/05-tags_in_comment.js"></script>
- <script language="JavaScript" src="tests/06-comment_in_script.js"></script>
- <script language="JavaScript" src="tests/07-unescaped_in_style.js"></script>
- <script language="JavaScript" src="tests/08-extra_spaces_in_tag.js"></script>
- <script language="JavaScript" src="tests/09-unquoted_attrib.js"></script>
- <script language="JavaScript" src="tests/10-singular_attribute.js"></script>
- <script language="JavaScript" src="tests/11-text_outside_tags.js"></script>
- <script language="JavaScript" src="tests/12-text_only.js"></script>
- <script language="JavaScript" src="tests/13-comment_in_text.js"></script>
- <script language="JavaScript" src="tests/14-comment_in_text_in_script.js"></script>
- <script language="JavaScript" src="tests/15-non-verbose.js"></script>
- <script language="JavaScript" src="tests/16-ignore_whitespace.js"></script>
- <script language="JavaScript" src="tests/17-xml_namespace.js"></script>
- <script language="JavaScript" src="tests/18-enforce_empty_tags.js"></script>
- <script language="JavaScript" src="tests/19-ignore_empty_tags.js"></script>
- <script language="JavaScript" src="tests/20-rss.js"></script>
- <script language="JavaScript" src="tests/21-atom.js"></script>
- <script language="JavaScript" src="tests/22-position_data.js"></script>
- <!-- //TODO: dynamic loading of test files -->
- </head>
- <body style="font-size: small; font-family:Arial, Helvetica, sans-serif;">
-
- <script language="JavaScript">
- var chunkSize = 5;
- var testCount = 0;
- var failedCount = 0;
- while (Tautologistics.NodeHtmlParser.Tests.length) {
- testCount++;
- var test = Tautologistics.NodeHtmlParser.Tests.shift();
- try {
- var handlerCallback = function handlerCallback (error) {
- if (error)
- document.write("<hr>Handler error: " + error + "<hr>");
- }
- var handler = (test.type == "rss") ?
- new Tautologistics.NodeHtmlParser.RssHandler(handlerCallback, test.options.handler)
- :
- new Tautologistics.NodeHtmlParser.DefaultHandler(handlerCallback, test.options.handler)
- ;
- var parser = new Tautologistics.NodeHtmlParser.Parser(handler, test.options.parser);
- document.write("<b>" + test.name + "</b>: ");
- parser.parseComplete(test.html);
- var resultComplete = handler.dom;
- var chunkPos = 0;
- parser.reset();
- while (chunkPos < test.html.length) {
- parser.parseChunk(test.html.substring(chunkPos, chunkPos + chunkSize));
- chunkPos += chunkSize;
- }
- parser.done();
- var resultChunk = handler.dom;
- var testResult =
- JSON.stringify(resultComplete).toString() === JSON.stringify(test.expected).toString()
- &&
- JSON.stringify(resultChunk).toString() === JSON.stringify(test.expected).toString()
- ;
- document.write(testResult ? "<font class='good'>passed</font>" : "<font class='bad'>FAILED</font>");
- if (!testResult) {
- failedCount++;
- document.write("<pre>");
- document.write("<b>Complete</b>\n");
- document.write(JSON.stringify(resultComplete, null, 2));
- document.write("<b>Chunked</b>\n");
- document.write(JSON.stringify(resultChunk, null, 2));
- document.write("<h2>Expected</h2>\n");
- document.write(JSON.stringify(test.expected, null, 2));
- document.write("</pre>");
- }
- } catch (ex) {
- document.write("<h1>Exception occured during test: " + ex + "</h1>")
- }
- document.write("<br>");
- }
- document.write("<hr>");
- document.write("Total tests: " + testCount + "<br>");
- document.write("Failed tests: " + failedCount + "<br>");
- </script>
-
- </body>
-</html>
View
33 node_modules/htmlparser/CHANGELOG
@@ -1,33 +0,0 @@
-
-v1.7.2
- * Document position feature fixed to work correctly with chunked parsing
-
-v1.7.1
- * Document position feature disabled until it works correctly with chunked parsing
-
-v1.7.0
- * Empty tag checking switch to being case insensitive [fgnass]
- * Added feature to include document position (row, col) in element data [fgnass]
- * Added parser option "includeLocation" to enable document position data
-
-v1.6.4
- * Fixed 'prevElement' error [Swizec]
-
-v1.6.3
- * Updated to support being an npm package
- * Fixed DomUtils.testElement()
-
-v1.6.1
- * Optimized DomUtils by up to 2-3x
-
-v1.6.0
- * Added support for RSS/Atom feeds
-
-v1.5.0
- * Added DefaultHandler option "enforceEmptyTags" so that XML can be parsed correctly
-
-v1.4.2
- * Added tests for parsing XML with namespaces
-
-v1.4.1
- * Added minified version
View
18 node_modules/htmlparser/LICENSE
@@ -1,18 +0,0 @@
-Copyright 2010, Chris Winberry <chris@winberry.net>. All rights reserved.
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-IN THE SOFTWARE.
View
186 node_modules/htmlparser/README.md
@@ -1,186 +0,0 @@
-#NodeHtmlParser
-A forgiving HTML/XML/RSS parser written in JS for both the browser and NodeJS (yes, despite the name it works just fine in any modern browser). The parser can handle streams (chunked data) and supports custom handlers for writing custom DOMs/output.
-
-##Installing
-
- npm install htmlparser
-
-##Running Tests
-
-###Run tests under node:
- node runtests.js
-
-###Run tests in browser:
-View runtests.html in any browser
-
-##Usage In Node
- var htmlparser = require("node-htmlparser");
- var rawHtml = "Xyz <script language= javascript>var foo = '<<bar>>';< / script><!--<!-- Waah! -- -->";
- var handler = new htmlparser.DefaultHandler(function (error, dom) {
- if (error)
- [...do something for errors...]
- else
- [...parsing done, do something...]
- });
- var parser = new htmlparser.Parser(handler);
- parser.parseComplete(rawHtml);
- sys.puts(sys.inspect(handler.dom, false, null));
-
-##Usage In Browser
- var handler = new Tautologistics.NodeHtmlParser.DefaultHandler(function (error, dom) {
- if (error)
- [...do something for errors...]
- else
- [...parsing done, do something...]
- });
- var parser = new Tautologistics.NodeHtmlParser.Parser(handler);
- parser.parseComplete(document.body.innerHTML);
- alert(JSON.stringify(handler.dom, null, 2));
-
-##Example output
- [ { raw: 'Xyz ', data: 'Xyz ', type: 'text' }
- , { raw: 'script language= javascript'
- , data: 'script language= javascript'
- , type: 'script'
- , name: 'script'
- , attribs: { language: 'javascript' }
- , children:
- [ { raw: 'var foo = \'<bar>\';<'
- , data: 'var foo = \'<bar>\';<'
- , type: 'text'
- }
- ]
- }
- , { raw: '<!-- Waah! -- '
- , data: '<!-- Waah! -- '
- , type: 'comment'
- }
- ]
-
-##Streaming To Parser
- while (...) {
- ...
- parser.parseChunk(chunk);
- }
- parser.done();
-
-##Parsing RSS/Atom Feeds
-
- new htmlparser.RssHandler(function (error, dom) {
- ...
- });
-
-##DefaultHandler Options
-
-###Usage
- var handler = new htmlparser.DefaultHandler(
- function (error) { ... }
- , { verbose: false, ignoreWhitespace: true }
- );
-
-###Option: ignoreWhitespace
-Indicates whether the DOM should exclude text nodes that consists solely of whitespace. The default value is "false".
-
-####Example: true
-The following HTML:
- <font>
- <br>this is the text
- <font>
-becomes:
- [ { raw: 'font'
- , data: 'font'
- , type: 'tag'
- , name: 'font'
- , children:
- [ { raw: 'br', data: 'br', type: 'tag', name: 'br' }
- , { raw: 'this is the text\n'
- , data: 'this is the text\n'
- , type: 'text'
- }
- , { raw: 'font', data: 'font', type: 'tag', name: 'font' }
- ]
- }
- ]
-
-####Example: false
-The following HTML:
- <font>
- <br>this is the text
- <font>
-becomes:
- [ { raw: 'font'
- , data: 'font'
- , type: 'tag'
- , name: 'font'
- , children:
- [ { raw: '\n\t', data: '\n\t', type: 'text' }
- , { raw: 'br', data: 'br', type: 'tag', name: 'br' }
- , { raw: 'this is the text\n'
- , data: 'this is the text\n'
- , type: 'text'
- }
- , { raw: 'font', data: 'font', type: 'tag', name: 'font' }
- ]
- }
- ]
-
-###Option: verbose
-Indicates whether to include extra information on each node in the DOM. This information consists of the "raw" attribute (original, unparsed text found between "<" and ">") and the "data" attribute on "tag", "script", and "comment" nodes. The default value is "true".
-
-####Example: true
-The following HTML:
- <a href="test.html">xxx</a>
-becomes:
- [ { raw: 'a href="test.html"'
- , data: 'a href="test.html"'
- , type: 'tag'
- , name: 'a'
- , attribs: { href: 'test.html' }
- , children: [ { raw: 'xxx', data: 'xxx', type: 'text' } ]
- }
- ]
-
-####Example: false
-The following HTML:
- <a href="test.html">xxx</a>
-becomes:
- [ { type: 'tag'
- , name: 'a'
- , attribs: { href: 'test.html' }
- , children: [ { data: 'xxx', type: 'text' } ]
- }
- ]
-
-###Option: enforceEmptyTags
-Indicates whether the DOM should prevent children on tags marked as empty in the HTML spec. Typically this should be set to "true" HTML parsing and "false" for XML parsing. The default value is "true".
-
-####Example: true
-The following HTML:
- <link>text</link>
-becomes:
- [ { raw: 'link', data: 'link', type: 'tag', name: 'link' }
- , { raw: 'text', data: 'text', type: 'text' }
- ]
-
-####Example: false
-The following HTML:
- <link>text</link>
-becomes:
- [ { raw: 'link'
- , data: 'link'
- , type: 'tag'
- , name: 'link'
- , children: [ { raw: 'text', data: 'text', type: 'text' } ]
- }
- ]
-
-##DomUtils
-
-###TBD (see utils_example.js for now)
-
-##Related Projects
-
-Looking for CSS selectors to search the DOM? Try Node-SoupSelect, a port of SoupSelect to NodeJS: http://github.com/harryf/node-soupselect
-
-There's also a port of hpricot to NodeJS that uses node-HtmlParser for HTML parsing: http://github.com/silentrob/Apricot
-
View
35 node_modules/htmlparser/a
@@ -1,35 +0,0 @@
-[ { raw: 'html',
- data: 'html',
- type: 'tag',
- location: { line: 1, col: 1 },
- name: 'html',
- children:
- [ { raw: '\n\n',
- data: '\n\n',
- type: 'text',
- location: { line: 1, col: 5 } },
- { raw: 'title',
- data: 'title',
- type: 'tag',
- location: { line: 3, col: 1 },
- name: 'title',
- children:
- [ { raw: 'The Title',
- data: 'The Title',
- type: 'text',
- location: { line: 3, col: 6 } } ] },
- { raw: 'body',
- data: 'body',
- type: 'tag',
- location: { line: 3, col: 1 },
- name: 'body',
- children:
- [ { raw: '\nHello world\n\n',
- data: '\nHello world\n\n',
- type: 'text',
- location: { line: 3, col: 5 } } ] },
- { raw: '\n\n',
- data: '\n\n',
- type: 'text',
- location: { line: 6, col: 6 } } ] } ]
-
View
35 node_modules/htmlparser/b
@@ -1,35 +0,0 @@
-[ { raw: 'html',
- data: 'html',
- type: 'tag',
- location: { line: 1, col: 0 },
- name: 'html',
- children:
- [ { raw: '\n\n',
- data: '\n\n',
- type: 'text',
- location: { line: 1, col: 5 } },
- { raw: 'title',
- data: 'title',
- type: 'tag',
- location: { line: 1, col: 0 },
- name: 'title',
- children:
- [ { raw: 'The Title',
- data: 'The Title',
- type: 'text',
- location: { line: 1, col: 0 } } ] },
- { raw: 'body',
- data: 'body',
- type: 'tag',
- location: { line: 1, col: 0 },
- name: 'body',
- children:
- [ { raw: '\nHello world\n\n',
- data: '\nHello world\n\n',
- type: 'text',
- location: { line: 1, col: 0 } } ] },
- { raw: '\n\n',
- data: '\n\n',
- type: 'text',
- location: { line: 1, col: 0 } } ] } ]
-
View
35 node_modules/htmlparser/c
@@ -1,35 +0,0 @@
-[ { raw: 'html',
- data: 'html',
- type: 'tag',
- location: { line: 1, col: 0 },
- name: 'html',
- children:
- [ { raw: '\n\n',
- data: '\n\n',
- type: 'text',
- location: { line: 1, col: 5 } },
- { raw: 'title',
- data: 'title',
- type: 'tag',
- location: { line: 1, col: 0 },
- name: 'title',
- children:
- [ { raw: 'The Title',
- data: 'The Title',
- type: 'text',
- location: { line: 1, col: 0 } } ] },
- { raw: 'body',
- data: 'body',
- type: 'tag',
- location: { line: 1, col: 0 },
- name: 'body',
- children:
- [ { raw: '\nHello world\n\n',
- data: '\nHello world\n\n',
- type: 'text',
- location: { line: 1, col: 0 } } ] },
- { raw: '\n\n',
- data: '\n\n',
- type: 'text',
- location: { line: 1, col: 0 } } ] } ]
-
View
482 node_modules/htmlparser/json2.js
@@ -1,482 +0,0 @@
-/*
- http://www.JSON.org/json2.js
- 2010-03-20
-
- Public Domain.
-
- NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
-
- See http://www.JSON.org/js.html
-
-
- This code should be minified before deployment.
- See http://javascript.crockford.com/jsmin.html
-
- USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
- NOT CONTROL.
-
-
- This file creates a global JSON object containing two methods: stringify
- and parse.
-
- JSON.stringify(value, replacer, space)
- value any JavaScript value, usually an object or array.
-
- replacer an optional parameter that determines how object
- values are stringified for objects. It can be a
- function or an array of strings.
-
- space an optional parameter that specifies the indentation
- of nested structures. If it is omitted, the text will
- be packed without extra whitespace. If it is a number,
- it will specify the number of spaces to indent at each
- level. If it is a string (such as '\t' or '&nbsp;'),
- it contains the characters used to indent at each level.
-
- This method produces a JSON text from a JavaScript value.
-
- When an object value is found, if the object contains a toJSON
- method, its toJSON method will be called and the result will be
- stringified. A toJSON method does not serialize: it returns the
- value represented by the name/value pair that should be serialized,
- or undefined if nothing should be serialized. The toJSON method
- will be passed the key associated with the value, and this will be
- bound to the value
-
- For example, this would serialize Dates as ISO strings.
-
- Date.prototype.toJSON = function (key) {
- function f(n) {
- // Format integers to have at least two digits.
- return n < 10 ? '0' + n : n;
- }
-
- return this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z';
- };
-
- You can provide an optional replacer method. It will be passed the
- key and value of each member, with this bound to the containing
- object. The value that is returned from your method will be
- serialized. If your method returns undefined, then the member will
- be excluded from the serialization.
-
- If the replacer parameter is an array of strings, then it will be
- used to select the members to be serialized. It filters the results
- such that only members with keys listed in the replacer array are
- stringified.
-
- Values that do not have JSON representations, such as undefined or
- functions, will not be serialized. Such values in objects will be
- dropped; in arrays they will be replaced with null. You can use
- a replacer function to replace those with JSON values.
- JSON.stringify(undefined) returns undefined.
-
- The optional space parameter produces a stringification of the
- value that is filled with line breaks and indentation to make it
- easier to read.
-
- If the space parameter is a non-empty string, then that string will
- be used for indentation. If the space parameter is a number, then
- the indentation will be that many spaces.
-
- Example:
-
- text = JSON.stringify(['e', {pluribus: 'unum'}]);
- // text is '["e",{"pluribus":"unum"}]'
-
-
- text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
- // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
-
- text = JSON.stringify([new Date()], function (key, value) {
- return this[key] instanceof Date ?
- 'Date(' + this[key] + ')' : value;
- });
- // text is '["Date(---current time---)"]'
-
-
- JSON.parse(text, reviver)
- This method parses a JSON text to produce an object or array.
- It can throw a SyntaxError exception.
-
- The optional reviver parameter is a function that can filter and
- transform the results. It receives each of the keys and values,
- and its return value is used instead of the original value.
- If it returns what it received, then the structure is not modified.
- If it returns undefined then the member is deleted.
-
- Example:
-
- // Parse the text. Values that look like ISO date strings will
- // be converted to Date objects.
-
- myData = JSON.parse(text, function (key, value) {
- var a;
- if (typeof value === 'string') {
- a =
-/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
- if (a) {
- return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
- +a[5], +a[6]));
- }
- }
- return value;
- });
-
- myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
- var d;
- if (typeof value === 'string' &&
- value.slice(0, 5) === 'Date(' &&
- value.slice(-1) === ')') {
- d = new Date(value.slice(5, -1));
- if (d) {
- return d;
- }
- }
- return value;
- });
-
-
- This is a reference implementation. You are free to copy, modify, or
- redistribute.
-*/
-
-/*jslint evil: true, strict: false */
-
-/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
- call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
- getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
- lastIndex, length, parse, prototype, push, replace, slice, stringify,
- test, toJSON, toString, valueOf
-*/
-
-
-// Create a JSON object only if one does not already exist. We create the
-// methods in a closure to avoid creating global variables.
-
-if (!this.JSON) {
- this.JSON = {};
-}
-
-(function () {
-
- function f(n) {
- // Format integers to have at least two digits.
- return n < 10 ? '0' + n : n;
- }
-
- if (typeof Date.prototype.toJSON !== 'function') {
-
- Date.prototype.toJSON = function (key) {
-
- return isFinite(this.valueOf()) ?
- this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z' : null;
- };
-
- String.prototype.toJSON =
- Number.prototype.toJSON =
- Boolean.prototype.toJSON = function (key) {
- return this.valueOf();
- };
- }
-
- var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- gap,
- indent,
- meta = { // table of character substitutions
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '\\': '\\\\'
- },
- rep;
-
-
- function quote(string) {
-
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can safely slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe escape
-// sequences.
-
- escapable.lastIndex = 0;
- return escapable.test(string) ?
- '"' + string.replace(escapable, function (a) {
- var c = meta[a];
- return typeof c === 'string' ? c :
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- }) + '"' :
- '"' + string + '"';
- }
-
-
- function str(key, holder) {
-
-// Produce a string from holder[key].
-
- var i, // The loop counter.
- k, // The member key.
- v, // The member value.
- length,
- mind = gap,
- partial,
- value = holder[key];
-
-// If the value has a toJSON method, call it to obtain a replacement value.
-
- if (value && typeof value === 'object' &&
- typeof value.toJSON === 'function') {
- value = value.toJSON(key);
- }
-
-// If we were called with a replacer function, then call the replacer to
-// obtain a replacement value.
-
- if (typeof rep === 'function') {
- value = rep.call(holder, key, value);
- }
-
-// What happens next depends on the value's type.
-
- switch (typeof value) {
- case 'string':
- return quote(value);
-
- case 'number':
-
-// JSON numbers must be finite. Encode non-finite numbers as null.
-
- return isFinite(value) ? String(value) : 'null';
-
- case 'boolean':
- case 'null':
-
-// If the value is a boolean or null, convert it to a string. Note:
-// typeof null does not produce 'null'. The case is included here in
-// the remote chance that this gets fixed someday.
-
- return String(value);
-
-// If the type is 'object', we might be dealing with an object or an array or
-// null.
-
- case 'object':
-
-// Due to a specification blunder in ECMAScript, typeof null is 'object',
-// so watch out for that case.
-
- if (!value) {
- return 'null';
- }
-
-// Make an array to hold the partial results of stringifying this object value.
-
- gap += indent;
- partial = [];
-
-// Is the value an array?
-
- if (Object.prototype.toString.apply(value) === '[object Array]') {
-
-// The value is an array. Stringify every element. Use null as a placeholder
-// for non-JSON values.
-
- length = value.length;
- for (i = 0; i < length; i += 1) {
- partial[i] = str(i, value) || 'null';
- }
-
-// Join all of the elements together, separated with commas, and wrap them in
-// brackets.
-
- v = partial.length === 0 ? '[]' :
- gap ? '[\n' + gap +
- partial.join(',\n' + gap) + '\n' +
- mind + ']' :
- '[' + partial.join(',') + ']';
- gap = mind;
- return v;
- }
-
-// If the replacer is an array, use it to select the members to be stringified.
-
- if (rep && typeof rep === 'object') {
- length = rep.length;
- for (i = 0; i < length; i += 1) {
- k = rep[i];
- if (typeof k === 'string') {
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
- }
- }
- }
- } else {
-
-// Otherwise, iterate through all of the keys in the object.
-
- for (k in value) {
- if (Object.hasOwnProperty.call(value, k)) {
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
- }
- }
- }
- }
-
-// Join all of the member texts together, separated with commas,
-// and wrap them in braces.
-
- v = partial.length === 0 ? '{}' :
- gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
- mind + '}' : '{' + partial.join(',') + '}';
- gap = mind;
- return v;
- }
- }
-
-// If the JSON object does not yet have a stringify method, give it one.
-
- if (typeof JSON.stringify !== 'function') {
- JSON.stringify = function (value, replacer, space) {
-
-// The stringify method takes a value and an optional replacer, and an optional
-// space parameter, and returns a JSON text. The replacer can be a function
-// that can replace values, or an array of strings that will select the keys.
-// A default replacer method can be provided. Use of the space parameter can
-// produce text that is more easily readable.
-
- var i;
- gap = '';
- indent = '';
-
-// If the space parameter is a number, make an indent string containing that
-// many spaces.
-
- if (typeof space === 'number') {
- for (i = 0; i < space; i += 1) {
- indent += ' ';
- }
-
-// If the space parameter is a string, it will be used as the indent string.
-
- } else if (typeof space === 'string') {
- indent = space;
- }
-
-// If there is a replacer, it must be a function or an array.
-// Otherwise, throw an error.
-
- rep = replacer;
- if (replacer && typeof replacer !== 'function' &&
- (typeof replacer !== 'object' ||
- typeof replacer.length !== 'number')) {
- throw new Error('JSON.stringify');
- }
-
-// Make a fake root object containing our value under the key of ''.
-// Return the result of stringifying the value.
-
- return str('', {'': value});
- };
- }
-
-
-// If the JSON object does not yet have a parse method, give it one.
-
- if (typeof JSON.parse !== 'function') {
- JSON.parse = function (text, reviver) {
-
-// The parse method takes a text and an optional reviver function, and returns
-// a JavaScript value if the text is a valid JSON text.
-
- var j;
-
- function walk(holder, key) {
-
-// The walk method is used to recursively walk the resulting structure so
-// that modifications can be made.
-
- var k, v, value = holder[key];
- if (value && typeof value === 'object') {
- for (k in value) {
- if (Object.hasOwnProperty.call(value, k)) {
- v = walk(value, k);
- if (v !== undefined) {
- value[k] = v;
- } else {
- delete value[k];
- }
- }
- }
- }
- return reviver.call(holder, key, value);
- }
-
-
-// Parsing happens in four stages. In the first stage, we replace certain
-// Unicode characters with escape sequences. JavaScript handles many characters
-// incorrectly, either silently deleting them, or treating them as line endings.
-
- text = String(text);
- cx.lastIndex = 0;
- if (cx.test(text)) {
- text = text.replace(cx, function (a) {
- return '\\u' +
- ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- });
- }
-
-// In the second stage, we run the text against regular expressions that look
-// for non-JSON patterns. We are especially concerned with '()' and 'new'
-// because they can cause invocation, and '=' because it can cause mutation.
-// But just to be safe, we want to reject all unexpected forms.
-
-// We split the second stage into 4 regexp operations in order to work around
-// crippling inefficiencies in IE's and Safari's regexp engines. First we
-// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
-// replace all simple value tokens with ']' characters. Third, we delete all
-// open brackets that follow a colon or comma or that begin the text. Finally,
-// we look to see that the remaining characters are only whitespace or ']' or
-// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
-
- if (/^[\],:{}\s]*$/.
-test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
-replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
-replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
-
-// In the third stage we use the eval function to compile the text into a
-// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
-// in JavaScript: it can begin a block or an object literal. We wrap the text
-// in parens to eliminate the ambiguity.
-
- j = eval('(' + text + ')');
-
-// In the optional fourth stage, we recursively walk the new structure, passing
-// each name/value pair to a reviver function for possible transformation.
-
- return typeof reviver === 'function' ?
- walk({'': j}, '') : j;
- }
-
-// If the text is not JSON parseable, then a SyntaxError is thrown.
-
- throw new SyntaxError('JSON.parse');
- };
- }
-}());
View
822 node_modules/htmlparser/lib/htmlparser.js
@@ -1,822 +0,0 @@
-/***********************************************
-Copyright 2010, Chris Winberry <chris@winberry.net>. All rights reserved.
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-IN THE SOFTWARE.
-***********************************************/
-/* v1.7.2 */
-
-(function () {
-
-function runningInNode () {
- return(
- (typeof require) == "function"
- &&
- (typeof exports) == "object"
- &&
- (typeof module) == "object"
- &&
- (typeof __filename) == "string"
- &&
- (typeof __dirname) == "string"
- );
-}
-
-if (!runningInNode()) {
- if (!this.Tautologistics)
- this.Tautologistics = {};
- else if (this.Tautologistics.NodeHtmlParser)
- return; //NodeHtmlParser already defined!
- this.Tautologistics.NodeHtmlParser = {};
- exports = this.Tautologistics.NodeHtmlParser;
-}
-
-//Types of elements found in the DOM
-var ElementType = {
- Text: "text" //Plain text
- , Directive: "directive" //Special tag <!...>
- , Comment: "comment" //Special tag <!--...-->
- , Script: "script" //Special tag <script>...</script>
- , Style: "style" //Special tag <style>...</style>
- , Tag: "tag" //Any tag that isn't special
-}
-
-function Parser (handler, options) {
- this._options = options ? options : { };
- if (this._options.includeLocation == undefined) {
- this._options.includeLocation = false; //Do not track element position in document by default
- }
-
- this.validateHandler(handler);
- this._handler = handler;
- this.reset();
-}
-
- //**"Static"**//
- //Regular expressions used for cleaning up and parsing (stateless)
- Parser._reTrim = /(^\s+|\s+$)/g; //Trim leading/trailing whitespace
- Parser._reTrimComment = /(^\!--|--$)/g; //Remove comment tag markup from comment contents
- Parser._reWhitespace = /\s/g; //Used to find any whitespace to split on
- Parser._reTagName = /^\s*(\/?)\s*([^\s\/]+)/; //Used to find the tag name for an element
-
- //Regular expressions used for parsing (stateful)
- Parser._reAttrib = //Find attributes in a tag
- /([^=<>\"\'\s]+)\s*=\s*"([^"]*)"|([^=<>\"\'\s]+)\s*=\s*'([^']*)'|([^=<>\"\'\s]+)\s*=\s*([^'"\s]+)|([^=<>\"\'\s\/]+)/g;
- Parser._reTags = /[\<\>]/g; //Find tag markers
-
- //**Public**//
- //Methods//
- //Parses a complete HTML and pushes it to the handler
- Parser.prototype.parseComplete = function Parser$parseComplete (data) {
- this.reset();
- this.parseChunk(data);
- this.done();
- }
-
- //Parses a piece of an HTML document
- Parser.prototype.parseChunk = function Parser$parseChunk (data) {
- if (this._done)
- this.handleError(new Error("Attempted to parse chunk after parsing already done"));
- this._buffer += data; //FIXME: this can be a bottleneck
- this.parseTags();
- }
-
- //Tells the parser that the HTML being parsed is complete
- Parser.prototype.done = function Parser$done () {
- if (this._done)
- return;
- this._done = true;
-
- //Push any unparsed text into a final element in the element list
- if (this._buffer.length) {
- var rawData = this._buffer;
- this._buffer = "";
- var element = {
- raw: rawData
- , data: (this._parseState == ElementType.Text) ? rawData : rawData.replace(Parser._reTrim, "")
- , type: this._parseState
- };
- if (this._parseState == ElementType.Tag || this._parseState == ElementType.Script || this._parseState == ElementType.Style)
- element.name = this.parseTagName(element.data);
- this.parseAttribs(element);
- this._elements.push(element);
- }
-
- this.writeHandler();
- this._handler.done();
- }
-
- //Resets the parser to a blank state, ready to parse a new HTML document
- Parser.prototype.reset = function Parser$reset () {
- this._buffer = "";
- this._done = false;
- this._elements = [];
- this._elementsCurrent = 0;
- this._current = 0;
- this._next = 0;
- this._location = {
- row: 0
- , col: 0
- , charOffset: 0
- , inBuffer: 0
- };
- this._parseState = ElementType.Text;
- this._prevTagSep = '';
- this._tagStack = [];
- this._handler.reset();
- }
-
- //**Private**//
- //Properties//
- Parser.prototype._options = null; //Parser options for how to behave
- Parser.prototype._handler = null; //Handler for parsed elements
- Parser.prototype._buffer = null; //Buffer of unparsed data
- Parser.prototype._done = false; //Flag indicating whether parsing is done
- Parser.prototype._elements = null; //Array of parsed elements
- Parser.prototype._elementsCurrent = 0; //Pointer to last element in _elements that has been processed
- Parser.prototype._current = 0; //Position in data that has already been parsed
- Parser.prototype._next = 0; //Position in data of the next tag marker (<>)
- Parser.prototype._location = null; //Position tracking for elements in a stream
- Parser.prototype._parseState = ElementType.Text; //Current type of element being parsed
- Parser.prototype._prevTagSep = ''; //Previous tag marker found
- //Stack of element types previously encountered; keeps track of when
- //parsing occurs inside a script/comment/style tag
- Parser.prototype._tagStack = null;
-
- //Methods//
- //Takes an array of elements and parses any found attributes
- Parser.prototype.parseTagAttribs = function Parser$parseTagAttribs (elements) {
- var idxEnd = elements.length;
- var idx = 0;
-
- while (idx < idxEnd) {
- var element = elements[idx++];
- if (element.type == ElementType.Tag || element.type == ElementType.Script || element.type == ElementType.style)
- this.parseAttribs(element);
- }
-
- return(elements);
- }
-
- //Takes an element and adds an "attribs" property for any element attributes found
- Parser.prototype.parseAttribs = function Parser$parseAttribs (element) {
- //Only parse attributes for tags
- if (element.type != ElementType.Script && element.type != ElementType.Style && element.type != ElementType.Tag)
- return;
-
- var tagName = element.data.split(Parser._reWhitespace, 1)[0];
- var attribRaw = element.data.substring(tagName.length);
- if (attribRaw.length < 1)
- return;
-
- var match;
- Parser._reAttrib.lastIndex = 0;
- while (match = Parser._reAttrib.exec(attribRaw)) {
- if (element.attribs == undefined)
- element.attribs = {};
-
- if (typeof match[1] == "string" && match[1].length) {
- element.attribs[match[1]] = match[2];
- } else if (typeof match[3] == "string" && match[3].length) {
- element.attribs[match[3].toString()] = match[4].toString();
- } else if (typeof match[5] == "string" && match[5].length) {
- element.attribs[match[5]] = match[6];
- } else if (typeof match[7] == "string" && match[7].length) {
- element.attribs[match[7]] = match[7];
- }
- }
- }
-
- //Extracts the base tag name from the data value of an element
- Parser.prototype.parseTagName = function Parser$parseTagName (data) {
- if (data == null || data == "")
- return("");
- var match = Parser._reTagName.exec(data);
- if (!match)
- return("");
- return((match[1] ? "/" : "") + match[2]);
- }
-
- //Parses through HTML text and returns an array of found elements
- //I admit, this function is rather large but splitting up had an noticeable impact on speed
- Parser.prototype.parseTags = function Parser$parseTags () {
- var bufferEnd = this._buffer.length - 1;
- while (Parser._reTags.test(this._buffer)) {
- this._next = Parser._reTags.lastIndex - 1;
- var tagSep = this._buffer.charAt(this._next); //The currently found tag marker
- var rawData = this._buffer.substring(this._current, this._next); //The next chunk of data to parse
-
- //A new element to eventually be appended to the element list
- var element = {
- raw: rawData
- , data: (this._parseState == ElementType.Text) ? rawData : rawData.replace(Parser._reTrim, "")
- , type: this._parseState
- };
-
- var elementName = this.parseTagName(element.data);
-
- //This section inspects the current tag stack and modifies the current
- //element if we're actually parsing a special area (script/comment/style tag)
- if (this._tagStack.length) { //We're parsing inside a script/comment/style tag
- if (this._tagStack[this._tagStack.length - 1] == ElementType.Script) { //We're currently in a script tag
- if (elementName == "/script") //Actually, we're no longer in a script tag, so pop it off the stack
- this._tagStack.pop();
- else { //Not a closing script tag
- if (element.raw.indexOf("!--") != 0) { //Make sure we're not in a comment
- //All data from here to script close is now a text element
- element.type = ElementType.Text;
- //If the previous element is text, append the current text to it
- if (this._elements.length && this._elements[this._elements.length - 1].type == ElementType.Text) {
- var prevElement = this._elements[this._elements.length - 1];
- prevElement.raw = prevElement.data = prevElement.raw + this._prevTagSep + element.raw;
- element.raw = element.data = ""; //This causes the current element to not be added to the element list
- }
- }
- }
- }
- else if (this._tagStack[this._tagStack.length - 1] == ElementType.Style) { //We're currently in a style tag
- if (elementName == "/style") //Actually, we're no longer in a style tag, so pop it off the stack
- this._tagStack.pop();
- else {
- if (element.raw.indexOf("!--") != 0) { //Make sure we're not in a comment
- //All data from here to style close is now a text element
- element.type = ElementType.Text;
- //If the previous element is text, append the current text to it
- if (this._elements.length && this._elements[this._elements.length - 1].type == ElementType.Text) {
- var prevElement = this._elements[this._elements.length - 1];
- if (element.raw != "") {
- prevElement.raw = prevElement.data = prevElement.raw + this._prevTagSep + element.raw;
- element.raw = element.data = ""; //This causes the current element to not be added to the element list
- } else { //Element is empty, so just append the last tag marker found
- prevElement.raw = prevElement.data = prevElement.raw + this._prevTagSep;
- }
- } else { //The previous element was not text
- if (element.raw != "") {
- element.raw = element.data = element.raw;
- }
- }
- }
- }
- }
- else if (this._tagStack[this._tagStack.length - 1] == ElementType.Comment) { //We're currently in a comment tag
- var rawLen = element.raw.length;
- if (element.raw.charAt(rawLen - 2) == "-" && element.raw.charAt(rawLen - 1) == "-" && tagSep == ">") {
- //Actually, we're no longer in a style tag, so pop it off the stack
- this._tagStack.pop();
- //If the previous element is a comment, append the current text to it
- if (this._elements.length && this._elements[this._elements.length - 1].type == ElementType.Comment) {
- var prevElement = this._elements[this._elements.length - 1];
- prevElement.raw = prevElement.data = (prevElement.raw + element.raw).replace(Parser._reTrimComment, "");
- element.raw = element.data = ""; //This causes the current element to not be added to the element list
- element.type = ElementType.Text;
- }
- else //Previous element not a comment
- element.type = ElementType.Comment; //Change the current element's type to a comment
- }
- else { //Still in a comment tag
- element.type = ElementType.Comment;
- //If the previous element is a comment, append the current text to it
- if (this._elements.length && this._elements[this._elements.length - 1].type == ElementType.Comment) {
- var prevElement = this._elements[this._elements.length - 1];
- prevElement.raw = prevElement.data = prevElement.raw + element.raw + tagSep;
- element.raw = element.data = ""; //This causes the current element to not be added to the element list
- element.type = ElementType.Text;
- }
- else
- element.raw = element.data = element.raw + tagSep;
- }
- }
- }
-
- //Processing of non-special tags
- if (element.type == ElementType.Tag) {
- element.name = elementName;
-
- if (element.raw.indexOf("!--") == 0) { //This tag is really comment
- element.type = ElementType.Comment;
- delete element["name"];
- var rawLen = element.raw.length;
- //Check if the comment is terminated in the current element
- if (element.raw.charAt(rawLen - 1) == "-" && element.raw.charAt(rawLen - 2) == "-" && tagSep == ">")
- element.raw = element.data = element.raw.replace(Parser._reTrimComment, "");
- else { //It's not so push the comment onto the tag stack
- element.raw += tagSep;
- this._tagStack.push(ElementType.Comment);
- }
- }
- else if (element.raw.indexOf("!") == 0 || element.raw.indexOf("?") == 0) {
- element.type = ElementType.Directive;
- //TODO: what about CDATA?
- }
- else if (element.name == "script") {
- element.type = ElementType.Script;
- //Special tag, push onto the tag stack if not terminated
- if (element.data.charAt(element.data.length - 1) != "/")
- this._tagStack.push(ElementType.Script);
- }
- else if (element.name == "/script")
- element.type = ElementType.Script;
- else if (element.name == "style") {
- element.type = ElementType.Style;
- //Special tag, push onto the tag stack if not terminated
- if (element.data.charAt(element.data.length - 1) != "/")
- this._tagStack.push(ElementType.Style);
- }
- else if (element.name == "/style")
- element.type = ElementType.Style;
- if (element.name && element.name.charAt(0) == "/")
- element.data = element.name;
- }
-
- //Add all tags and non-empty text elements to the element list
- if (element.raw != "" || element.type != ElementType.Text) {
- if (this._options.includeLocation && !element.location) {
- element.location = this.getLocation(element.type == ElementType.Tag);
- }
- this.parseAttribs(element);
- this._elements.push(element);
- //If tag self-terminates, add an explicit, separate closing tag
- if (
- element.type != ElementType.Text
- &&
- element.type != ElementType.Comment
- &&
- element.type != ElementType.Directive
- &&
- element.data.charAt(element.data.length - 1) == "/"
- )
- this._elements.push({
- raw: "/" + element.name
- , data: "/" + element.name
- , name: "/" + element.name
- , type: element.type
- });
- }
- this._parseState = (tagSep == "<") ? ElementType.Tag : ElementType.Text;
- this._current = this._next + 1;
- this._prevTagSep = tagSep;
- }
-
- if (this._options.includeLocation) {
- this.getLocation();
- this._location.row += this._location.inBuffer;
- this._location.inBuffer = 0;
- this._location.charOffset = 0;
- }
- this._buffer = (this._current <= bufferEnd) ? this._buffer.substring(this._current) : "";
- this._current = 0;
-
- this.writeHandler();
- }
-
- Parser.prototype.getLocation = function Parser$getLocation (startTag) {
- var c,
- l = this._location,
- end = this._current - (startTag ? 1 : 0),
- chunk = startTag && l.charOffset == 0 && this._current == 0;
-
- for (; l.charOffset < end; l.charOffset++) {
- c = this._buffer.charAt(l.charOffset);
- if (c == '\n') {
- l.inBuffer++;
- l.col = 0;
- } else if (c != '\r') {
- l.col++;
- }
- }
- return {
- line: l.row + l.inBuffer + 1
- , col: l.col + (chunk ? 0: 1)
- };
- }
-
- //Checks the handler to make it is an object with the right "interface"
- Parser.prototype.validateHandler = function Parser$validateHandler (handler) {
- if ((typeof handler) != "object")
- throw new Error("Handler is not an object");
- if ((typeof handler.reset) != "function")
- throw new Error("Handler method 'reset' is invalid");
- if ((typeof handler.done) != "function")
- throw new Error("Handler method 'done' is invalid");
- if ((typeof handler.writeTag) != "function")
- throw new Error("Handler method 'writeTag' is invalid");
- if ((typeof handler.writeText) != "function")
- throw new Error("Handler method 'writeText' is invalid");
- if ((typeof handler.writeComment) != "function")
- throw new Error("Handler method 'writeComment' is invalid");
- if ((typeof handler.writeDirective) != "function")
- throw new Error("Handler method 'writeDirective' is invalid");
- }
-
- //Writes parsed elements out to the handler
- Parser.prototype.writeHandler = function Parser$writeHandler (forceFlush) {
- forceFlush = !!forceFlush;
- if (this._tagStack.length && !forceFlush)
- return;
- while (this._elements.length) {
- var element = this._elements.shift();
- switch (element.type) {
- case ElementType.Comment:
- this._handler.writeComment(element);
- break;
- case ElementType.Directive:
- this._handler.writeDirective(element);
- break;
- case ElementType.Text:
- this._handler.writeText(element);
- break;
- default:
- this._handler.writeTag(element);
- break;
- }
- }
- }
-
- Parser.prototype.handleError = function Parser$handleError (error) {
- if ((typeof this._handler.error) == "function")
- this._handler.error(error);
- else
- throw error;
- }
-
-//TODO: make this a trully streamable handler
-function RssHandler (callback) {
- RssHandler.super_.call(this, callback, { ignoreWhitespace: true, verbose: false, enforceEmptyTags: false });
-}
-inherits(RssHandler, DefaultHandler);
-
- RssHandler.prototype.done = function RssHandler$done () {
- var feed = { };
- var feedRoot;
-
- var found = DomUtils.getElementsByTagName(function (value) { return(value == "rss" || value == "feed"); }, this.dom, false);
- if (found.length) {
- feedRoot = found[0];
- }
- if (feedRoot) {
- if (feedRoot.name == "rss") {
- feed.type = "rss";
- feedRoot = feedRoot.children[0]; //<channel/>
- feed.id = "";
- try {
- feed.title = DomUtils.getElementsByTagName("title", feedRoot.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- feed.link = DomUtils.getElementsByTagName("link", feedRoot.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- feed.description = DomUtils.getElementsByTagName("description", feedRoot.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- feed.updated = new Date(DomUtils.getElementsByTagName("lastBuildDate", feedRoot.children, false)[0].children[0].data);
- } catch (ex) { }
- try {
- feed.author = DomUtils.getElementsByTagName("managingEditor", feedRoot.children, false)[0].children[0].data;
- } catch (ex) { }
- feed.items = [];
- DomUtils.getElementsByTagName("item", feedRoot.children).forEach(function (item, index, list) {
- var entry = {};
- try {
- entry.id = DomUtils.getElementsByTagName("guid", item.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- entry.title = DomUtils.getElementsByTagName("title", item.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- entry.link = DomUtils.getElementsByTagName("link", item.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- entry.description = DomUtils.getElementsByTagName("description", item.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- entry.pubDate = new Date(DomUtils.getElementsByTagName("pubDate", item.children, false)[0].children[0].data);
- } catch (ex) { }
- feed.items.push(entry);
- });
- } else {
- feed.type = "atom";
- try {
- feed.id = DomUtils.getElementsByTagName("id", feedRoot.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- feed.title = DomUtils.getElementsByTagName("title", feedRoot.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- feed.link = DomUtils.getElementsByTagName("link", feedRoot.children, false)[0].attribs.href;
- } catch (ex) { }
- try {
- feed.description = DomUtils.getElementsByTagName("subtitle", feedRoot.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- feed.updated = new Date(DomUtils.getElementsByTagName("updated", feedRoot.children, false)[0].children[0].data);
- } catch (ex) { }
- try {
- feed.author = DomUtils.getElementsByTagName("email", feedRoot.children, true)[0].children[0].data;
- } catch (ex) { }
- feed.items = [];
- DomUtils.getElementsByTagName("entry", feedRoot.children).forEach(function (item, index, list) {
- var entry = {};
- try {
- entry.id = DomUtils.getElementsByTagName("id", item.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- entry.title = DomUtils.getElementsByTagName("title", item.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- entry.link = DomUtils.getElementsByTagName("link", item.children, false)[0].attribs.href;
- } catch (ex) { }
- try {
- entry.description = DomUtils.getElementsByTagName("summary", item.children, false)[0].children[0].data;
- } catch (ex) { }
- try {
- entry.pubDate = new Date(DomUtils.getElementsByTagName("updated", item.children, false)[0].children[0].data);
- } catch (ex) { }
- feed.items.push(entry);
- });
- }
-
- this.dom = feed;
- }
- RssHandler.super_.prototype.done.call(this);
- }
-
-///////////////////////////////////////////////////
-
-function DefaultHandler (callback, options) {
- this.reset();
- this._options = options ? options : { };
- if (this._options.ignoreWhitespace == undefined)
- this._options.ignoreWhitespace = false; //Keep whitespace-only text nodes
- if (this._options.verbose == undefined)
- this._options.verbose = true; //Keep data property for tags and raw property for all
- if (this._options.enforceEmptyTags == undefined)
- this._options.enforceEmptyTags = true; //Don't allow children for HTML tags defined as empty in spec
- if ((typeof callback) == "function")
- this._callback = callback;
-}
-
- //**"Static"**//
- //HTML Tags that shouldn't contain child nodes
- DefaultHandler._emptyTags = {
- area: 1
- , base: 1
- , basefont: 1
- , br: 1
- , col: 1
- , frame: 1
- , hr: 1
- , img: 1
- , input: 1
- , isindex: 1
- , link: 1
- , meta: 1
- , param: 1
- , embed: 1
- }
- //Regex to detect whitespace only text nodes
- DefaultHandler.reWhitespace = /^\s*$/;
-
- //**Public**//
- //Properties//
- DefaultHandler.prototype.dom = null; //The hierarchical object containing the parsed HTML
- //Methods//
- //Resets the handler back to starting state
- DefaultHandler.prototype.reset = function DefaultHandler$reset() {
- this.dom = [];
- this._done = false;
- this._tagStack = [];
- this._tagStack.last = function DefaultHandler$_tagStack$last () {
- return(this.length ? this[this.length - 1] : null);
- }
- }
- //Signals the handler that parsing is done
- DefaultHandler.prototype.done = function DefaultHandler$done () {
- this._done = true;
- this.handleCallback(null);
- }
- DefaultHandler.prototype.writeTag = function DefaultHandler$writeTag (element) {
- this.handleElement(element);
- }
- DefaultHandler.prototype.writeText = function DefaultHandler$writeText (element) {
- if (this._options.ignoreWhitespace)
- if (DefaultHandler.reWhitespace.test(element.data))
- return;
- this.handleElement(element);
- }
- DefaultHandler.prototype.writeComment = function DefaultHandler$writeComment (element) {
- this.handleElement(element);
- }
- DefaultHandler.prototype.writeDirective = function DefaultHandler$writeDirective (element) {
- this.handleElement(element);
- }
- DefaultHandler.prototype.error = function DefaultHandler$error (error) {
- this.handleCallback(error);
- }
-
- //**Private**//
- //Properties//
- DefaultHandler.prototype._options = null; //Handler options for how to behave
- DefaultHandler.prototype._callback = null; //Callback to respond to when parsing done
- DefaultHandler.prototype._done = false; //Flag indicating whether handler has been notified of parsing completed
- DefaultHandler.prototype._tagStack = null; //List of parents to the currently element being processed
- //Methods//
- DefaultHandler.prototype.handleCallback = function DefaultHandler$handleCallback (error) {
- if ((typeof this._callback) != "function")
- if (error)
- throw error;
- else
- return;
- this._callback(error, this.dom);
- }
-
- DefaultHandler.prototype.isEmptyTag = function(element) {
- var name = element.name.toLowerCase();
- if (name.charAt(0) == '/') {
- name = name.substring(1);
- }
- return this._options.enforceEmptyTags && !!DefaultHandler._emptyTags[name];
- };
-
- DefaultHandler.prototype.handleElement = function DefaultHandler$handleElement (element) {
- if (this._done)
- this.handleCallback(new Error("Writing to the handler after done() called is not allowed without a reset()"));
- if (!this._options.verbose) {
-// element.raw = null; //FIXME: Not clean
- //FIXME: Serious performance problem using delete
- delete element.raw;
- if (element.type == "tag" || element.type == "script" || element.type == "style")
- delete element.data;
- }
- if (!this._tagStack.last()) { //There are no parent elements
- //If the element can be a container, add it to the tag stack and the top level list
- if (element.type != ElementType.Text && element.type != ElementType.Comment && element.type != ElementType.Directive) {
- if (element.name.charAt(0) != "/") { //Ignore closing tags that obviously don't have an opening tag
- this.dom.push(element);
- if (!this.isEmptyTag(element)) { //Don't add tags to the tag stack that can't have children
- this._tagStack.push(element);
- }
- }
- }
- else //Otherwise just add to the top level list
- this.dom.push(element);
- }
- else { //There are parent elements
- //If the element can be a container, add it as a child of the element
- //on top of the tag stack and then add it to the tag stack
- if (element.type != ElementType.Text && element.type != ElementType.Comment && element.type != ElementType.Directive) {
- if (element.name.charAt(0) == "/") {
- //This is a closing tag, scan the tagStack to find the matching opening tag
- //and pop the stack up to the opening tag's parent
- var baseName = element.name.substring(1);
- if (!this.isEmptyTag(element)) {
- var pos = this._tagStack.length - 1;
- while (pos > -1 && this._tagStack[pos--].name != baseName) { }
- if (pos > -1 || this._tagStack[0].name == baseName)
- while (pos < this._tagStack.length - 1)
- this._tagStack.pop();
- }
- }
- else { //This is not a closing tag
- if (!this._tagStack.last().children)
- this._tagStack.last().children = [];
- this._tagStack.last().children.push(element);
- if (!this.isEmptyTag(element)) //Don't add tags to the tag stack that can't have children
- this._tagStack.push(element);
- }
- }
- else { //This is not a container element
- if (!this._tagStack.last().children)
- this._tagStack.last().children = [];
- this._tagStack.last().children.push(element);
- }
- }
- }
-
- var DomUtils = {
- testElement: function DomUtils$testElement (options, element) {
- if (!element) {
- return false;
- }
-
- for (var key in options) {
- if (key == "tag_name") {
- if (element.type != "tag" && element.type != "script" && element.type != "style") {
- return false;
- }
- if (!options["tag_name"](element.name)) {
- return false;
- }
- } else if (key == "tag_type") {
- if (!options["tag_type"](element.type)) {
- return false;
- }
- } else if (key == "tag_contains") {
- if (element.type != "text" && element.type != "comment" && element.type != "directive") {
- return false;
- }
- if (!options["tag_contains"](element.data)) {
- return false;
- }
- } else {
- if (!element.attribs || !options[key](element.attribs[key])) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- , getElements: function DomUtils$getElements (options, currentElement, recurse, limit) {
- recurse = (recurse === undefined || recurse === null) || !!recurse;
- limit = isNaN(parseInt(limit)) ? -1 : parseInt(limit);
-
- if (!currentElement) {
- return([]);
- }
-
- var found = [];
- var elementList;
-
- function getTest (checkVal) {
- return(function (value) { return(value == checkVal); });
- }
- for (var key in options) {
- if ((typeof options[key]) != "function") {
- options[key] = getTest(options[key]);
- }
- }
-
- if (DomUtils.testElement(options, currentElement)) {
- found.push(currentElement);
- }
-
- if (limit >= 0 && found.length >= limit) {
- return(found);
- }
-
- if (recurse && currentElement.children) {
- elementList = currentElement.children;
- } else if (currentElement instanceof Array) {
- elementList = currentElement;
- } else {
- return(found);
- }
-
- for (var i = 0; i < elementList.length; i++) {
- found = found.concat(DomUtils.getElements(options, elementList[i], recurse, limit));
- if (limit >= 0 && found.length >= limit) {
- break;
- }
- }
-
- return(found);
- }
-
- , getElementById: function DomUtils$getElementById (id, currentElement, recurse) {
- var result = DomUtils.getElements({ id: id }, currentElement, recurse, 1);
- return(result.length ? result[0] : null);
- }
-
- , getElementsByTagName: function DomUtils$getElementsByTagName (name, currentElement, recurse, limit) {
- return(DomUtils.getElements({ tag_name: name }, currentElement, recurse, limit));
- }
-
- , getElementsByTagType: function DomUtils$getElementsByTagType (type, currentElement, recurse, limit) {
- return(DomUtils.getElements({ tag_type: type }, currentElement, recurse, limit));
- }
- }
-
- function inherits (ctor, superCtor) {
- var tempCtor = function(){};
- tempCtor.prototype = superCtor.prototype;
- ctor.super_ = superCtor;
- ctor.prototype = new tempCtor();
- ctor.prototype.constructor = ctor;
- }
-
-exports.Parser = Parser;
-
-exports.DefaultHandler = DefaultHandler;
-
-exports.RssHandler = RssHandler;
-
-exports.ElementType = ElementType;
-
-exports.DomUtils = DomUtils;
-
-})();
View
22 node_modules/htmlparser/lib/htmlparser.min.js
@@ -1,22 +0,0 @@
-/***********************************************
-Copyright 2010, Chris Winberry <chris@winberry.net>. All rights reserved.
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-IN THE SOFTWARE.
-***********************************************/
-/* v1.7.2 */
-(function(){function e(a,c){this._options=c?c:{};if(this._options.includeLocation==undefined)this._options.includeLocation=false;this.validateHandler(a);this._handler=a;this.reset()}function n(a){n.super_.call(this,a,{ignoreWhitespace:true,verbose:false,enforceEmptyTags:false})}function i(a,c){this.reset();this._options=c?c:{};if(this._options.ignoreWhitespace==undefined)this._options.ignoreWhitespace=false;if(this._options.verbose==undefined)this._options.verbose=true;if(this._options.enforceEmptyTags== undefined)this._options.enforceEmptyTags=true;if(typeof a=="function")this._callback=a}if(!(typeof require=="function"&&typeof exports=="object"&&typeof module=="object"&&typeof __filename=="string"&&typeof __dirname=="string")){if(this.Tautologistics){if(this.Tautologistics.NodeHtmlParser)return}else this.Tautologistics={};this.Tautologistics.NodeHtmlParser={};exports=this.Tautologistics.NodeHtmlParser}var d={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag"}; e._reTrim=/(^\s+|\s+$)/g;e._reTrimComment=/(^\!--|--$)/g;e._reWhitespace=/\s/g;e._reTagName=/^\s*(\/?)\s*([^\s\/]+)/;e._reAttrib=/([^=<>\"\'\s]+)\s*=\s*"([^"]*)"|([^=<>\"\'\s]+)\s*=\s*'([^']*)'|([^=<>\"\'\s]+)\s*=\s*([^'"\s]+)|([^=<>\"\'\s\/]+)/g;e._reTags=/[\<\>]/g;e.prototype.parseComplete=function(a){this.reset();this.parseChunk(a);this.done()};e.prototype.parseChunk=function(a){this._done&&this.handleError(Error("Attempted to parse chunk after parsing already done"));this._buffer+=a;this.parseTags()}; e.prototype.done=function(){if(!this._done){this._done=true;if(this._buffer.length){var a=this._buffer;this._buffer="";a={raw:a,data:this._parseState==d.Text?a:a.replace(e._reTrim,""),type:this._parseState};if(this._parseState==d.Tag||this._parseState==d.Script||this._parseState==d.Style)a.name=this.parseTagName(a.data);this.parseAttribs(a);this._elements.push(a)}this.writeHandler();this._handler.done()}};e.prototype.reset=function(){this._buffer="";this._done=false;this._elements=[];this._next=this._current= this._elementsCurrent=0;this._location={row:0,col:0,charOffset:0,inBuffer:0};this._parseState=d.Text;this._prevTagSep="";this._tagStack=[];this._handler.reset()};e.prototype._options=null;e.prototype._handler=null;e.prototype._buffer=null;e.prototype._done=false;e.prototype._elements=null;e.prototype._elementsCurrent=0;e.prototype._current=0;e.prototype._next=0;e.prototype._location=null;e.prototype._parseState=d.Text;e.prototype._prevTagSep="";e.prototype._tagStack=null;e.prototype.parseTagAttribs= function(a){for(var c=a.length,b=0;b<c;){var h=a[b++];if(h.type==d.Tag||h.type==d.Script||h.type==d.style)this.parseAttribs(h)}return a};e.prototype.parseAttribs=function(a){if(!(a.type!=d.Script&&a.type!=d.Style&&a.type!=d.Tag)){var c=a.data.split(e._reWhitespace,1)[0];c=a.data.substring(c.length);if(!(c.length<1)){var b;for(e._reAttrib.lastIndex=0;b=e._reAttrib.exec(c);){if(a.attribs==undefined)a.attribs={};if(typeof b[1]=="string"&&b[1].length)a.attribs[b[1]]=b[2];else if(typeof b[3]=="string"&& b[3].length)a.attribs[b[3].toString()]=b[4].toString();else if(typeof b[5]=="string"&&b[5].length)a.attribs[b[5]]=b[6];else if(typeof b[7]=="string"&&b[7].length)a.attribs[b[7]]=b[7]}}}};e.prototype.parseTagName=function(a){if(a==null||a=="")return"";a=e._reTagName.exec(a);if(!a)return"";return(a[1]?"/":"")+a[2]};e.prototype.parseTags=function(){for(var a=this._buffer.length-1;e._reTags.test(this._buffer);){this._next=e._reTags.lastIndex-1;var c=this._buffer.charAt(this._next),b=this._buffer.substring(this._current, this._next);b={raw:b,data:this._parseState==d.Text?b:b.replace(e._reTrim,""),type:this._parseState};var h=this.parseTagName(b.data);if(this._tagStack.length)if(this._tagStack[this._tagStack.length-1]==d.Script)if(h=="/script")this._tagStack.pop();else{if(b.raw.indexOf("!--")!=0){b.type=d.Text;if(this._elements.length&&this._elements[this._elements.length-1].type==d.Text){var g=this._elements[this._elements.length-1];g.raw=g.data=g.raw+this._prevTagSep+b.raw;b.raw=b.data=""}}}else if(this._tagStack[this._tagStack.length- 1]==d.Style)if(h=="/style")this._tagStack.pop();else{if(b.raw.indexOf("!--")!=0){b.type=d.Text;if(this._elements.length&&this._elements[this._elements.length-1].type==d.Text){g=this._elements[this._elements.length-1];if(b.raw!=""){g.raw=g.data=g.raw+this._prevTagSep+b.raw;b.raw=b.data=""}else g.raw=g.data=g.raw+this._prevTagSep}else if(b.raw!="")b.raw=b.data=b.raw}}else if(this._tagStack[this._tagStack.length-1]==d.Comment){g=b.raw.length;if(b.raw.charAt(g-2)=="-"&&b.raw.charAt(g-1)=="-"&&c==">"){this._tagStack.pop(); if(this._elements.length&&this._elements[this._elements.length-1].type==d.Comment){g=this._elements[this._elements.length-1];g.raw=g.data=(g.raw+b.raw).replace(e._reTrimComment,"");b.raw=b.data="";b.type=d.Text}else b.type=d.Comment}else{b.type=d.Comment;if(this._elements.length&&this._elements[this._elements.length-1].type==d.Comment){g=this._elements[this._elements.length-1];g.raw=g.data=g.raw+b.raw+c;b.raw=b.data="";b.type=d.Text}else b.raw=b.data=b.raw+c}}if(b.type==d.Tag){b.name=h;if(b.raw.indexOf("!--")== 0){b.type=d.Comment;delete b.name;g=b.raw.length;if(b.raw.charAt(g-1)=="-"&&b.raw.charAt(g-2)=="-"&&c==">")b.raw=b.data=b.raw.replace(e._reTrimComment,"");else{b.raw+=c;this._tagStack.push(d.Comment)}}else if(b.raw.indexOf("!")==0||b.raw.indexOf("?")==0)b.type=d.Directive;else if(b.name=="script"){b.type=d.Script;b.data.charAt(b.data.length-1)!="/"&&this._tagStack.push(d.Script)}else if(b.name=="/script")b.type=d.Script;else if(b.name=="style"){b.type=d.Style;b.data.charAt(b.data.length-1)!="/"&& this._tagStack.push(d.Style)}else if(b.name=="/style")b.type=d.Style;if(b.name&&b.name.charAt(0)=="/")b.data=b.name}if(b.raw!=""||b.type!=d.Text){if(this._options.includeLocation&&!b.location)b.location=this.getLocation(b.type==d.Tag);this.parseAttribs(b);this._elements.push(b);b.type!=d.Text&&b.type!=d.Comment&&b.type!=d.Directive&&b.data.charAt(b.data.length-1)=="/"&&this._elements.push({raw:"/"+b.name,data:"/"+b.name,name:"/"+b.name,type:b.type})}this._parseState=c=="<"?d.Tag:d.Text;this._current= this._next+1;this._prevTagSep=c}if(this._options.includeLocation){this.getLocation();this._location.row+=this._location.inBuffer;this._location.inBuffer=0;this._location.charOffset=0}this._buffer=this._current<=a?this._buffer.substring(this._current):"";this._current=0;this.writeHandler()};e.prototype.getLocation=function(a){for(var c=this._location,b=this._current-(a?1:0),h=a&&c.charOffset==0&&this._current==0;c.charOffset<b;c.charOffset++){a=this._buffer.charAt(c.charOffset);if(a=="\n"){c.inBuffer++; c.col=0}else a!="\r"&&c.col++}return{line:c.row+c.inBuffer+1,col:c.col+(h?0:1)}};e.prototype.validateHandler=function(a){if(typeof a!="object")throw Error("Handler is not an object");if(typeof a.reset!="function")throw Error("Handler method 'reset' is invalid");if(typeof a.done!="function")throw Error("Handler method 'done' is invalid");if(typeof a.writeTag!="function")throw Error("Handler method 'writeTag' is invalid");if(typeof a.writeText!="function")throw Error("Handler method 'writeText' is invalid"); if(typeof a.writeComment!="function")throw Error("Handler method 'writeComment' is invalid");if(typeof a.writeDirective!="function")throw Error("Handler method 'writeDirective' is invalid");};e.prototype.writeHandler=function(a){a=!!a;if(!(this._tagStack.length&&!a))for(;this._elements.length;){a=this._elements.shift();switch(a.type){case d.Comment:this._handler.writeComment(a);break;case d.Directive:this._handler.writeDirective(a);break;case d.Text:this._handler.writeText(a);break;default:this._handler.writeTag(a)}}}; e.prototype.handleError=function(a){if(typeof this._handler.error=="function")this._handler.error(a);else throw a;};(function(a,c){var b=function(){};b.prototype=c.prototype;a.super_=c;a.prototype=new b;a.prototype.constructor=a})(n,i);n.prototype.done=function(){var a={},c,b=f.getElementsByTagName(function(j){return j=="rss"||j=="feed"},this.dom,false);if(b.length)c=b[0];if(c){if(c.name=="rss"){a.type="rss";c=c.children[0];a.id="";try{a.title=f.getElementsByTagName("title",c.children,false)[0].children[0].data}catch(h){}try{a.link= f.getElementsByTagName("link",c.children,false)[0].children[0].data}catch(g){}try{a.description=f.getElementsByTagName("description",c.children,false)[0].children[0].data}catch(l){}try{a.updated=new Date(f.getElementsByTagName("lastBuildDate",c.children,false)[0].children[0].data)}catch(m){}try{a.author=f.getElementsByTagName("managingEditor",c.children,false)[0].children[0].data}catch(o){}a.items=[];f.getElementsByTagName("item",c.children).forEach(function(j){var k={};try{k.id=f.getElementsByTagName("guid", j.children,false)[0].children[0].data}catch(q){}try{k.title=f.getElementsByTagName("title",j.children,false)[0].children[0].data}catch(r){}try{k.link=f.getElementsByTagName("link",j.children,false)[0].children[0].data}catch(s){}try{k.description=f.getElementsByTagName("description",j.children,false)[0].children[0].data}catch(t){}try{k.pubDate=new Date(f.getElementsByTagName("pubDate",j.children,false)[0].children[0].data)}catch(u){}a.items.push(k)})}else{a.type="atom";try{a.id=f.getElementsByTagName("id", c.children,false)[0].children[0].data}catch(p){}try{a.title=f.getElementsByTagName("title",c.children,false)[0].children[0].data}catch(v){}try{a.link=f.getElementsByTagName("link",c.children,false)[0].attribs.href}catch(w){}try{a.description=f.getElementsByTagName("subtitle",c.children,false)[0].children[0].data}catch(x){}try{a.updated=new Date(f.getElementsByTagName("updated",c.children,false)[0].children[0].data)}catch(y){}try{a.author=f.getElementsByTagName("email",c.children,true)[0].children[0].data}catch(z){}a.items= [];f.getElementsByTagName("entry",c.children).forEach(function(j){var k={};try{k.id=f.getElementsByTagName("id",j.children,false)[0].children[0].data}catch(q){}try{k.title=f.getElementsByTagName("title",j.children,false)[0].children[0].data}catch(r){}try{k.link=f.getElementsByTagName("link",j.children,false)[0].attribs.href}catch(s){}try{k.description=f.getElementsByTagName("summary",j.children,false)[0].children[0].data}catch(t){}try{k.pubDate=new Date(f.getElementsByTagName("updated",j.children, false)[0].children[0].data)}catch(u){}a.items.push(k)})}this.dom=a}n.super_.prototype.done.call(this)};i._emptyTags={area:1,base:1,basefont:1,br:1,col:1,frame:1,hr:1,img:1,input:1,isindex:1,link:1,meta:1,param:1,embed:1};i.reWhitespace=/^\s*$/;i.prototype.dom=null;i.prototype.reset=function(){this.dom=[];this._done=false;this._tagStack=[];this._tagStack.last=function(){return this.length?this[this.length-1]:null}};i.prototype.done=function(){this._done=true;this.handleCallback(null)};i.prototype.writeTag= function(a){this.handleElement(a)};i.prototype.writeText=function(a){if(this._options.ignoreWhitespace)if(i.reWhitespace.test(a.data))return;this.handleElement(a)};i.prototype.writeComment=function(a){this.handleElement(a)};i.prototype.writeDirective=function(a){this.handleElement(a)};i.prototype.error=function(a){this.handleCallback(a)};i.prototype._options=null;i.prototype._callback=null;i.prototype._done=false;i.prototype._tagStack=null;i.prototype.handleCallback=function(a){if(typeof this._callback!= "function")if(a)throw a;else return;this._callback(a,this.dom)};i.prototype.isEmptyTag=function(a){a=a.name.toLowerCase();if(a.charAt(0)=="/")a=a.substring(1);return this._options.enforceEmptyTags&&!!i._emptyTags[a]};i.prototype.handleElement=function(a){this._done&&this.handleCallback(Error("Writing to the handler after done() called is not allowed without a reset()"));if(!this._options.verbose){delete a.raw;if(a.type=="tag"||a.type=="script"||a.type=="style")delete a.data}if(this._tagStack.last())if(a.type!= d.Text&&a.type!=d.Comment&&a.type!=d.Directive)if(a.name.charAt(0)=="/"){var c=a.name.substring(1);if(!this.isEmptyTag(a)){for(a=this._tagStack.length-1;a>-1&&this._tagStack[a--].name!=c;);if(a>-1||this._tagStack[0].name==c)for(;a<this._tagStack.length-1;)this._tagStack.pop()}}else{if(!this._tagStack.last().children)this._tagStack.last().children=[];this._tagStack.last().children.push(a);this.isEmptyTag(a)||this._tagStack.push(a)}else{if(!this._tagStack.last().children)this._tagStack.last().children= [];this._tagStack.last().children.push(a)}else if(a.type!=d.Text&&a.type!=d.Comment&&a.type!=d.Directive){if(a.name.charAt(0)!="/"){this.dom.push(a);this.isEmptyTag(a)||this._tagStack.push(a)}}else this.dom.push(a)};var f={testElement:function(a,c){if(!c)return false;for(var b in a)if(b=="tag_name"){if(c.type!="tag"&&c.type!="script"&&c.type!="style")return false;if(!a.tag_name(c.name))return false}else if(b=="tag_type"){if(!a.tag_type(c.type))return false}else if(b=="tag_contains"){if(c.type!="text"&& c.type!="comment"&&c.type!="directive")return false;if(!a.tag_contains(c.data))return false}else if(!c.attribs||!a[b](c.attribs[b]))return false;return true},getElements:function(a,c,b,h){function g(o){return function(p){return p==o}}b=b===undefined||b===null||!!b;h=isNaN(parseInt(h))?-1:parseInt(h);if(!c)return[];var l=[],m;for(m in a)if(typeof a[m]!="function")a[m]=g(a[m]);f.testElement(a,c)&&l.push(c);if(h>=0&&l.length>=h)return l;if(b&&c.children)c=c.children;else if(c instanceof Array)c=c;else return l; for(m=0;m<c.length;m++){l=l.concat(f.getElements(a,c[m],b,h));if(h>=0&&l.length>=h)break}return l},getElementById:function(a,c,b){a=f.getElements({id:a},c,b,1);return a.length?a[0]:null},getElementsByTagName:function(a,c,b,h){return f.getElements({tag_name:a},c,b,h)},getElementsByTagType:function(a,c,b,h){return f.getElements({tag_type:a},c,b,h)}};exports.Parser=e;exports.DefaultHandler=i;exports.RssHandler=n;exports.ElementType=d;exports.DomUtils=f})();
View
6 node_modules/htmlparser/lib/node-htmlparser.js
@@ -1,6 +0,0 @@
-var htmlparser = require("./htmlparser");
-exports.Parser = htmlparser.Parser;
-exports.DefaultHandler = htmlparser.DefaultHandler;
-exports.RssHandler = htmlparser.RssHandler;
-exports.ElementType = htmlparser.ElementType;
-exports.DomUtils = htmlparser.DomUtils;
View
6 node_modules/htmlparser/lib/node-htmlparser.min.js
@@ -1,6 +0,0 @@
-var htmlparser = require("./htmlparser.min");
-exports.Parser = htmlparser.Parser;
-exports.DefaultHandler = htmlparser.DefaultHandler;
-exports.RssHandler = htmlparser.RssHandler;
-exports.ElementType = htmlparser.ElementType;
-exports.DomUtils = htmlparser.DomUtils;
View
BIN  node_modules/htmlparser/libxmljs.node
Binary file not shown
View
54 node_modules/htmlparser/newparser.js
@@ -1,54 +0,0 @@
-//node --prof --prof_auto profile.js
-//deps/v8/tools/mac-tick-processor v8.log
-var sys = require("sys");
-var fs = require("fs");
-
-var testHtml = "./testdata/api.html"; //Test HTML file to load
-var testIterations = 100; //Number of test loops to run
-
-var html = fs.readFileSync(testHtml).toString();
-
-function getMillisecs () {