htmljs-parser 2.11.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1031) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +103 -106
  3. package/dist/core/Parser.d.ts +67 -0
  4. package/dist/index.d.ts +23 -0
  5. package/dist/index.js +2034 -0
  6. package/dist/index.mjs +2013 -0
  7. package/dist/internal.d.ts +4 -0
  8. package/dist/states/ATTRIBUTE.d.ts +18 -0
  9. package/dist/states/BEGIN_DELIMITED_HTML_BLOCK.d.ts +7 -0
  10. package/dist/states/CDATA.d.ts +3 -0
  11. package/dist/states/CLOSE_TAG.d.ts +3 -0
  12. package/dist/states/CONCISE_HTML_CONTENT.d.ts +2 -0
  13. package/dist/states/DECLARATION.d.ts +2 -0
  14. package/dist/states/DTD.d.ts +2 -0
  15. package/dist/states/EXPRESSION.d.ts +9 -0
  16. package/dist/states/HTML_COMMENT.d.ts +2 -0
  17. package/dist/states/HTML_CONTENT.d.ts +7 -0
  18. package/dist/states/INLINE_SCRIPT.d.ts +7 -0
  19. package/dist/states/JS_COMMENT_BLOCK.d.ts +2 -0
  20. package/dist/states/JS_COMMENT_LINE.d.ts +2 -0
  21. package/dist/states/OPEN_TAG.d.ts +25 -0
  22. package/dist/states/PARSED_TEXT_CONTENT.d.ts +7 -0
  23. package/dist/states/PLACEHOLDER.d.ts +7 -0
  24. package/dist/states/REGULAR_EXPRESSION.d.ts +6 -0
  25. package/dist/states/STRING.d.ts +6 -0
  26. package/dist/states/TAG_NAME.d.ts +5 -0
  27. package/dist/states/TEMPLATE_STRING.d.ts +2 -0
  28. package/dist/states/index.d.ts +20 -0
  29. package/dist/util/constants.d.ts +131 -0
  30. package/dist/util/util.d.ts +7 -0
  31. package/package.json +67 -30
  32. package/.jshintrc +0 -29
  33. package/.travis.yml +0 -8
  34. package/BaseParser.js +0 -188
  35. package/Parser.js +0 -3324
  36. package/html-tags.js +0 -126
  37. package/index.js +0 -6
  38. package/notify-util.js +0 -319
  39. package/operators.js +0 -65
  40. package/test/.jshintrc +0 -43
  41. package/test/1.x-test.js +0 -6
  42. package/test/autotest/argument-and-params/expected.html +0 -17
  43. package/test/autotest/argument-and-params/input.htmljs +0 -6
  44. package/test/autotest/argument-attr/expected.html +0 -2
  45. package/test/autotest/argument-attr/input.htmljs +0 -1
  46. package/test/autotest/argument-attr-extra-whitespace/expected.html +0 -4
  47. package/test/autotest/argument-attr-extra-whitespace/input.htmljs +0 -2
  48. package/test/autotest/argument-attr-multiple/expected.html +0 -1
  49. package/test/autotest/argument-attr-multiple/input.htmljs +0 -1
  50. package/test/autotest/argument-tag/expected.html +0 -9
  51. package/test/autotest/argument-tag/input.htmljs +0 -3
  52. package/test/autotest/argument-tag-attr/expected.html +0 -2
  53. package/test/autotest/argument-tag-attr/input.htmljs +0 -1
  54. package/test/autotest/argument-tag-complex/expected.html +0 -2
  55. package/test/autotest/argument-tag-complex/input.htmljs +0 -1
  56. package/test/autotest/argument-tag-extra-whitespace/expected.html +0 -2
  57. package/test/autotest/argument-tag-extra-whitespace/input.htmljs +0 -1
  58. package/test/autotest/argument-tag-multiple/expected.html +0 -1
  59. package/test/autotest/argument-tag-multiple/input.htmljs +0 -1
  60. package/test/autotest/argument-tag-nested-parens/expected.html +0 -3
  61. package/test/autotest/argument-tag-nested-parens/input.htmljs +0 -4
  62. package/test/autotest/attr-bound/expected.html +0 -23
  63. package/test/autotest/attr-bound/input.htmljs +0 -6
  64. package/test/autotest/attr-comma-multiline/expected.html +0 -3
  65. package/test/autotest/attr-comma-multiline/input.htmljs +0 -6
  66. package/test/autotest/attr-complex/expected.html +0 -3
  67. package/test/autotest/attr-complex/input.htmljs +0 -1
  68. package/test/autotest/attr-complex-instanceof/expected.html +0 -2
  69. package/test/autotest/attr-complex-instanceof/input.htmljs +0 -1
  70. package/test/autotest/attr-escape-characters/expected.html +0 -3
  71. package/test/autotest/attr-escape-characters/input.htmljs +0 -3
  72. package/test/autotest/attr-escaped-dollar/expected.html +0 -1
  73. package/test/autotest/attr-escaped-dollar/input.htmljs +0 -1
  74. package/test/autotest/attr-escaped-dollar/test.js +0 -5
  75. package/test/autotest/attr-grouped/expected.html +0 -3
  76. package/test/autotest/attr-grouped/input.htmljs +0 -5
  77. package/test/autotest/attr-grouped-2/expected.html +0 -3
  78. package/test/autotest/attr-grouped-2/input.htmljs +0 -5
  79. package/test/autotest/attr-grouped-3/expected.html +0 -3
  80. package/test/autotest/attr-grouped-3/input.htmljs +0 -5
  81. package/test/autotest/attr-grouped-4/expected.html +0 -3
  82. package/test/autotest/attr-grouped-4/input.htmljs +0 -5
  83. package/test/autotest/attr-grouped-invalid/expected.html +0 -1
  84. package/test/autotest/attr-grouped-invalid/input.htmljs +0 -5
  85. package/test/autotest/attr-grouped-invalid-eof/expected.html +0 -1
  86. package/test/autotest/attr-grouped-invalid-eof/input.htmljs +0 -4
  87. package/test/autotest/attr-grouped-multiple/expected.html +0 -3
  88. package/test/autotest/attr-grouped-multiple/input.htmljs +0 -4
  89. package/test/autotest/attr-inc-and-dec/expected.html +0 -4
  90. package/test/autotest/attr-inc-and-dec/input.htmljs +0 -2
  91. package/test/autotest/attr-inconsistent-commas/expected.html +0 -1
  92. package/test/autotest/attr-inconsistent-commas/input.htmljs +0 -1
  93. package/test/autotest/attr-int-and-id/expected.html +0 -2
  94. package/test/autotest/attr-int-and-id/input.htmljs +0 -1
  95. package/test/autotest/attr-literal-false/expected.html +0 -2
  96. package/test/autotest/attr-literal-false/input.htmljs +0 -1
  97. package/test/autotest/attr-literal-false/test.js +0 -1
  98. package/test/autotest/attr-literal-null/expected.html +0 -2
  99. package/test/autotest/attr-literal-null/input.htmljs +0 -1
  100. package/test/autotest/attr-literal-null/test.js +0 -1
  101. package/test/autotest/attr-literal-numbers/expected.html +0 -2
  102. package/test/autotest/attr-literal-numbers/input.htmljs +0 -1
  103. package/test/autotest/attr-literal-numbers/test.js +0 -1
  104. package/test/autotest/attr-literal-regex/expected.html +0 -11
  105. package/test/autotest/attr-literal-regex/input.htmljs +0 -4
  106. package/test/autotest/attr-literal-string-double-quotes/expected.html +0 -2
  107. package/test/autotest/attr-literal-string-double-quotes/input.htmljs +0 -1
  108. package/test/autotest/attr-literal-string-double-quotes/test.js +0 -1
  109. package/test/autotest/attr-literal-string-single-quotes/expected.html +0 -2
  110. package/test/autotest/attr-literal-string-single-quotes/input.htmljs +0 -1
  111. package/test/autotest/attr-literal-string-single-quotes/test.js +0 -1
  112. package/test/autotest/attr-literal-true/expected.html +0 -2
  113. package/test/autotest/attr-literal-true/input.htmljs +0 -1
  114. package/test/autotest/attr-literal-true/test.js +0 -1
  115. package/test/autotest/attr-literal-undefined/expected.html +0 -2
  116. package/test/autotest/attr-literal-undefined/input.htmljs +0 -1
  117. package/test/autotest/attr-literal-undefined/test.js +0 -1
  118. package/test/autotest/attr-method-shorthand/expected.html +0 -14
  119. package/test/autotest/attr-method-shorthand/input.htmljs +0 -39
  120. package/test/autotest/attr-multi-line-comment/expected.html +0 -3
  121. package/test/autotest/attr-multi-line-comment/input.htmljs +0 -1
  122. package/test/autotest/attr-multi-line-string/expected.html +0 -2
  123. package/test/autotest/attr-multi-line-string/input.htmljs +0 -3
  124. package/test/autotest/attr-name-with-html-chars/expected.html +0 -1
  125. package/test/autotest/attr-name-with-html-chars/input.htmljs +0 -1
  126. package/test/autotest/attr-nested-literal-regex/expected.html +0 -2
  127. package/test/autotest/attr-nested-literal-regex/input.htmljs +0 -1
  128. package/test/autotest/attr-no-value/expected.html +0 -3
  129. package/test/autotest/attr-no-value/input.htmljs +0 -1
  130. package/test/autotest/attr-no-value-self-closed/expected.html +0 -2
  131. package/test/autotest/attr-no-value-self-closed/input.htmljs +0 -1
  132. package/test/autotest/attr-non-literal/expected.html +0 -5
  133. package/test/autotest/attr-non-literal/input.htmljs +0 -2
  134. package/test/autotest/attr-non-literal/test.js +0 -1
  135. package/test/autotest/attr-object-expressions/expected.html +0 -4
  136. package/test/autotest/attr-object-expressions/input.htmljs +0 -3
  137. package/test/autotest/attr-simple-expression/expected.html +0 -3
  138. package/test/autotest/attr-simple-expression/input.htmljs +0 -1
  139. package/test/autotest/attr-unenclosed-whitespace/expected.html +0 -2
  140. package/test/autotest/attr-unenclosed-whitespace/input.htmljs +0 -1
  141. package/test/autotest/attr-unenclosed-whitespace-minus/expected.html +0 -2
  142. package/test/autotest/attr-unenclosed-whitespace-minus/input.htmljs +0 -1
  143. package/test/autotest/attr-unenclosed-whitespace-multiple-attrs/expected.html +0 -5
  144. package/test/autotest/attr-unenclosed-whitespace-multiple-attrs/input.htmljs +0 -2
  145. package/test/autotest/attr-unenclosed-whitespace-odd/expected.html +0 -2
  146. package/test/autotest/attr-unenclosed-whitespace-odd/input.htmljs +0 -1
  147. package/test/autotest/attr-value-self-closed/expected.html +0 -2
  148. package/test/autotest/attr-value-self-closed/input.htmljs +0 -1
  149. package/test/autotest/attr-value-single-quote-escaped/expected.html +0 -2
  150. package/test/autotest/attr-value-single-quote-escaped/input.htmljs +0 -1
  151. package/test/autotest/attr-value-string-concat/expected.html +0 -2
  152. package/test/autotest/attr-value-string-concat/input.htmljs +0 -1
  153. package/test/autotest/attr-value-typeof/expected.html +0 -2
  154. package/test/autotest/attr-value-typeof/input.htmljs +0 -1
  155. package/test/autotest/attr-value-typeof-comma/expected.html +0 -2
  156. package/test/autotest/attr-value-typeof-comma/input.htmljs +0 -1
  157. package/test/autotest/attr-value-typeof-no-space-prefix/expected.html +0 -2
  158. package/test/autotest/attr-value-typeof-no-space-prefix/input.htmljs +0 -1
  159. package/test/autotest/attr-value-void/expected.html +0 -2
  160. package/test/autotest/attr-value-void/input.htmljs +0 -1
  161. package/test/autotest/attr-with-parens-and-double-quoted-strings/expected.html +0 -2
  162. package/test/autotest/attr-with-parens-and-double-quoted-strings/input.htmljs +0 -1
  163. package/test/autotest/attr-with-parens-and-single-quoted-strings/expected.html +0 -2
  164. package/test/autotest/attr-with-parens-and-single-quoted-strings/input.htmljs +0 -1
  165. package/test/autotest/attr-with-right-angle-bracket/expected.html +0 -3
  166. package/test/autotest/attr-with-right-angle-bracket/input.htmljs +0 -1
  167. package/test/autotest/attr-with-right-angle-bracket-parens/expected.html +0 -3
  168. package/test/autotest/attr-with-right-angle-bracket-parens/input.htmljs +0 -1
  169. package/test/autotest/attr-without-delimiters/expected.html +0 -2
  170. package/test/autotest/attr-without-delimiters/input.htmljs +0 -1
  171. package/test/autotest/backtick-string/expected.html +0 -3
  172. package/test/autotest/backtick-string/input.htmljs +0 -2
  173. package/test/autotest/backtick-string-eof/expected.html +0 -1
  174. package/test/autotest/backtick-string-eof/input.htmljs +0 -2
  175. package/test/autotest/backtick-string-nested-with-space/expected.html +0 -2
  176. package/test/autotest/backtick-string-nested-with-space/input.htmljs +0 -1
  177. package/test/autotest/backtick-string-placeholder-newline/expected.html +0 -4
  178. package/test/autotest/backtick-string-placeholder-newline/input.htmljs +0 -3
  179. package/test/autotest/bad-tag-indent/expected.html +0 -1
  180. package/test/autotest/bad-tag-indent/input.htmljs +0 -1
  181. package/test/autotest/cdata/expected.html +0 -3
  182. package/test/autotest/cdata/input.htmljs +0 -1
  183. package/test/autotest/cdata-2/expected.html +0 -5
  184. package/test/autotest/cdata-2/input.htmljs +0 -3
  185. package/test/autotest/cdata-pos/expected.html +0 -7
  186. package/test/autotest/cdata-pos/input.htmljs +0 -4
  187. package/test/autotest/cdata-pos/test.js +0 -1
  188. package/test/autotest/comma-ends-attr-operators/expected.html +0 -2
  189. package/test/autotest/comma-ends-attr-operators/input.htmljs +0 -1
  190. package/test/autotest/commas-relax/expected.html +0 -2
  191. package/test/autotest/commas-relax/input.htmljs +0 -1
  192. package/test/autotest/commas-relax/test.js +0 -7
  193. package/test/autotest/commas-require-all-attrs-first/expected.html +0 -1
  194. package/test/autotest/commas-require-all-attrs-first/input.htmljs +0 -1
  195. package/test/autotest/commas-require-all-attrs-last/expected.html +0 -1
  196. package/test/autotest/commas-require-all-attrs-last/input.htmljs +0 -1
  197. package/test/autotest/comment-concise-js-block/expected.html +0 -4
  198. package/test/autotest/comment-concise-js-block/input.htmljs +0 -6
  199. package/test/autotest/comment-concise-js-block-trailing/expected.html +0 -4
  200. package/test/autotest/comment-concise-js-block-trailing/input.htmljs +0 -6
  201. package/test/autotest/comment-concise-js-line/expected.html +0 -4
  202. package/test/autotest/comment-concise-js-line/input.htmljs +0 -3
  203. package/test/autotest/comments-within-open-tag/expected.html +0 -2
  204. package/test/autotest/comments-within-open-tag/input.htmljs +0 -1
  205. package/test/autotest/complex/expected.html +0 -24
  206. package/test/autotest/complex/input.htmljs +0 -22
  207. package/test/autotest/complex-attr-name/expected.html +0 -2
  208. package/test/autotest/complex-attr-name/input.htmljs +0 -1
  209. package/test/autotest/concise-complex-tag-name/expected.html +0 -2
  210. package/test/autotest/concise-complex-tag-name/input.htmljs +0 -1
  211. package/test/autotest/concise-contentplaceholder-html-start/expected.html +0 -5
  212. package/test/autotest/concise-contentplaceholder-html-start/input.htmljs +0 -1
  213. package/test/autotest/concise-contentplaceholder-start/expected.html +0 -1
  214. package/test/autotest/concise-contentplaceholder-start/input.htmljs +0 -1
  215. package/test/autotest/concise-hyphen-after-tag-name/expected.html +0 -1
  216. package/test/autotest/concise-hyphen-after-tag-name/input.htmljs +0 -1
  217. package/test/autotest/css-calc/expected.html +0 -6
  218. package/test/autotest/css-calc/input.htmljs +0 -5
  219. package/test/autotest/declaration/expected.html +0 -1
  220. package/test/autotest/declaration/input.htmljs +0 -1
  221. package/test/autotest/default-attr/expected.html +0 -2
  222. package/test/autotest/default-attr/input.htmljs +0 -1
  223. package/test/autotest/default-attr-comma/expected.html +0 -2
  224. package/test/autotest/default-attr-comma/input.htmljs +0 -1
  225. package/test/autotest/default-attr-no-space/expected.html +0 -6
  226. package/test/autotest/default-attr-no-space/input.htmljs +0 -3
  227. package/test/autotest/double-hyphen-block/expected.html +0 -12
  228. package/test/autotest/double-hyphen-block/input.htmljs +0 -8
  229. package/test/autotest/double-hyphen-line/expected.html +0 -12
  230. package/test/autotest/double-hyphen-line/input.htmljs +0 -5
  231. package/test/autotest/double-hyphen-line-start/expected.html +0 -12
  232. package/test/autotest/double-hyphen-line-start/input.htmljs +0 -6
  233. package/test/autotest/dtd/expected.html +0 -1
  234. package/test/autotest/dtd/input.htmljs +0 -1
  235. package/test/autotest/empty-closing-tag/expected.html +0 -8
  236. package/test/autotest/empty-closing-tag/input.htmljs +0 -6
  237. package/test/autotest/empty-closing-tag2/expected.html +0 -9
  238. package/test/autotest/empty-closing-tag2/input.htmljs +0 -5
  239. package/test/autotest/eof-attr-argument/expected.html +0 -1
  240. package/test/autotest/eof-attr-argument/input.htmljs +0 -1
  241. package/test/autotest/eof-attr-name/expected.html +0 -3
  242. package/test/autotest/eof-attr-name/input.htmljs +0 -1
  243. package/test/autotest/eof-attr-value/expected.html +0 -3
  244. package/test/autotest/eof-attr-value/input.htmljs +0 -1
  245. package/test/autotest/eof-attr-value-js-comment-comment/expected.html +0 -3
  246. package/test/autotest/eof-attr-value-js-comment-comment/input.htmljs +0 -1
  247. package/test/autotest/eof-attr-value-js-comment-comment-concise/expected.html +0 -1
  248. package/test/autotest/eof-attr-value-js-comment-comment-concise/input.htmljs +0 -1
  249. package/test/autotest/eof-attr-value-string/expected.html +0 -1
  250. package/test/autotest/eof-attr-value-string/input.htmljs +0 -1
  251. package/test/autotest/eof-doctype/expected.html +0 -1
  252. package/test/autotest/eof-doctype/input.htmljs +0 -1
  253. package/test/autotest/eof-placeholder-body-escaped/expected.html +0 -4
  254. package/test/autotest/eof-placeholder-body-escaped/input.htmljs +0 -1
  255. package/test/autotest/eof-placeholder-body-non-escaped/expected.html +0 -4
  256. package/test/autotest/eof-placeholder-body-non-escaped/input.htmljs +0 -4
  257. package/test/autotest/eof-placeholder-concise/expected.html +0 -3
  258. package/test/autotest/eof-placeholder-concise/input.htmljs +0 -2
  259. package/test/autotest/eof-placeholder-script-body-escaped/expected.html +0 -4
  260. package/test/autotest/eof-placeholder-script-body-escaped/input.htmljs +0 -1
  261. package/test/autotest/eof-placeholder-script-body-non-escaped/expected.html +0 -4
  262. package/test/autotest/eof-placeholder-script-body-non-escaped/input.htmljs +0 -1
  263. package/test/autotest/eof-placeholder-string/expected.html +0 -4
  264. package/test/autotest/eof-placeholder-string/input.htmljs +0 -1
  265. package/test/autotest/eof-script-body/expected.html +0 -4
  266. package/test/autotest/eof-script-body/input.htmljs +0 -2
  267. package/test/autotest/eof-style/expected.html +0 -4
  268. package/test/autotest/eof-style/input.htmljs +0 -1
  269. package/test/autotest/eof-tag-start/expected.html +0 -3
  270. package/test/autotest/eof-tag-start/input.htmljs +0 -1
  271. package/test/autotest/eof-xml-declaration/expected.html +0 -1
  272. package/test/autotest/eof-xml-declaration/input.htmljs +0 -1
  273. package/test/autotest/html-block-after-tag/expected.html +0 -6
  274. package/test/autotest/html-block-after-tag/input.htmljs +0 -1
  275. package/test/autotest/html-comments/expected.html +0 -3
  276. package/test/autotest/html-comments/input.htmljs +0 -1
  277. package/test/autotest/html-comments-ignore-placeholders/expected.html +0 -1
  278. package/test/autotest/html-comments-ignore-placeholders/input.htmljs +0 -1
  279. package/test/autotest/ignoreAttributes/expected.html +0 -2
  280. package/test/autotest/ignoreAttributes/input.htmljs +0 -1
  281. package/test/autotest/ignoreAttributes/test.js +0 -7
  282. package/test/autotest/ignoreNonstandardStringPlaceholders/expected.html +0 -2
  283. package/test/autotest/ignoreNonstandardStringPlaceholders/input.htmljs +0 -1
  284. package/test/autotest/ignoreNonstandardStringPlaceholders/test.js +0 -1
  285. package/test/autotest/ignorePlaceholders-attr-double-escaped-dollar-placeholder/expected.html +0 -2
  286. package/test/autotest/ignorePlaceholders-attr-double-escaped-dollar-placeholder/input.htmljs +0 -1
  287. package/test/autotest/ignorePlaceholders-attr-double-escaped-dollar-placeholder/test.js +0 -1
  288. package/test/autotest/ignorePlaceholders-attr-escaped-dollar-placeholder/expected.html +0 -2
  289. package/test/autotest/ignorePlaceholders-attr-escaped-dollar-placeholder/input.htmljs +0 -1
  290. package/test/autotest/ignorePlaceholders-attr-escaped-dollar-placeholder/test.js +0 -1
  291. package/test/autotest/ignorePlaceholders-attr-placeholder/expected.html +0 -2
  292. package/test/autotest/ignorePlaceholders-attr-placeholder/input.htmljs +0 -1
  293. package/test/autotest/ignorePlaceholders-attr-placeholder/test.js +0 -1
  294. package/test/autotest/invalid-closing-tag/expected.html +0 -4
  295. package/test/autotest/invalid-closing-tag/input.htmljs +0 -1
  296. package/test/autotest/mixed/expected.html +0 -21
  297. package/test/autotest/mixed/input.htmljs +0 -8
  298. package/test/autotest/mixed-bad-indentation/expected.html +0 -7
  299. package/test/autotest/mixed-bad-indentation/input.htmljs +0 -3
  300. package/test/autotest/mixed-cdata/expected.html +0 -7
  301. package/test/autotest/mixed-cdata/input.htmljs +0 -3
  302. package/test/autotest/mixed-comment/expected.html +0 -7
  303. package/test/autotest/mixed-comment/input.htmljs +0 -6
  304. package/test/autotest/mixed-invalid/expected.html +0 -16
  305. package/test/autotest/mixed-invalid/input.htmljs +0 -9
  306. package/test/autotest/mixed-open-tag-only/expected.html +0 -14
  307. package/test/autotest/mixed-open-tag-only/input.htmljs +0 -6
  308. package/test/autotest/multiline-html-block/expected.html +0 -5
  309. package/test/autotest/multiline-html-block/input.htmljs +0 -4
  310. package/test/autotest/multiline-html-block-empty/expected.html +0 -0
  311. package/test/autotest/multiline-html-block-empty/input.htmljs +0 -2
  312. package/test/autotest/multiline-html-block-missing-end/expected.html +0 -7
  313. package/test/autotest/multiline-html-block-missing-end/input.htmljs +0 -12
  314. package/test/autotest/multiline-html-block-nested/expected.html +0 -7
  315. package/test/autotest/multiline-html-block-nested/input.htmljs +0 -5
  316. package/test/autotest/multiline-html-block-nested-empty/expected.html +0 -2
  317. package/test/autotest/multiline-html-block-nested-empty/input.htmljs +0 -3
  318. package/test/autotest/multiline-html-block-same-line/expected.html +0 -6
  319. package/test/autotest/multiline-html-block-same-line/input.htmljs +0 -7
  320. package/test/autotest/multiline-text-block/expected.html +0 -1
  321. package/test/autotest/multiline-text-block/input.htmljs +0 -4
  322. package/test/autotest/multiline-text-block-bad/expected.html +0 -1
  323. package/test/autotest/multiline-text-block-bad/input.htmljs +0 -5
  324. package/test/autotest/multiline-text-block-with-hyphens/expected.html +0 -1
  325. package/test/autotest/multiline-text-block-with-hyphens/input.htmljs +0 -4
  326. package/test/autotest/multiple-tags-on-line-close-next/input.htmljs +0 -2
  327. package/test/autotest/multiple-tags-on-line-close-next/test.js +0 -1
  328. package/test/autotest/nested-pyramid/expected.html +0 -12
  329. package/test/autotest/nested-pyramid/input.htmljs +0 -6
  330. package/test/autotest/nested-siblings/expected.html +0 -6
  331. package/test/autotest/nested-siblings/input.htmljs +0 -3
  332. package/test/autotest/nested-tags/expected.html +0 -4
  333. package/test/autotest/nested-tags/input.htmljs +0 -2
  334. package/test/autotest/nested-text/expected.html +0 -8
  335. package/test/autotest/nested-text/input.htmljs +0 -8
  336. package/test/autotest/open-tag-only/expected.html +0 -12
  337. package/test/autotest/open-tag-only/input.htmljs +0 -1
  338. package/test/autotest/open-tag-only-custom/expected.html +0 -10
  339. package/test/autotest/open-tag-only-custom/input.htmljs +0 -4
  340. package/test/autotest/open-tag-only-custom/test.js +0 -9
  341. package/test/autotest/open-tag-only-with-body/expected.html +0 -4
  342. package/test/autotest/open-tag-only-with-body/input.htmljs +0 -5
  343. package/test/autotest/open-tag-only-with-body-concise/expected.html +0 -3
  344. package/test/autotest/open-tag-only-with-body-concise/input.htmljs +0 -2
  345. package/test/autotest/open-tag-parser-state/expected.html +0 -21
  346. package/test/autotest/open-tag-parser-state/input.htmljs +0 -11
  347. package/test/autotest/open-tag-parser-state/test.js +0 -21
  348. package/test/autotest/open-tag-parser-state-concise/expected.html +0 -19
  349. package/test/autotest/open-tag-parser-state-concise/input.htmljs +0 -17
  350. package/test/autotest/open-tag-parser-state-concise/test.js +0 -17
  351. package/test/autotest/param-tag/expected.html +0 -2
  352. package/test/autotest/param-tag/input.htmljs +0 -1
  353. package/test/autotest/parsed-text-placeholder-in-template-literal-string/expected.html +0 -4
  354. package/test/autotest/parsed-text-placeholder-in-template-literal-string/input.htmljs +0 -3
  355. package/test/autotest/parsed-text-placeholder-in-template-literal-string/test.js +0 -1
  356. package/test/autotest/parsed-text-style-tag/expected.html +0 -3
  357. package/test/autotest/parsed-text-style-tag/input.htmljs +0 -1
  358. package/test/autotest/placeholder-attr-invalid/expected.html +0 -1
  359. package/test/autotest/placeholder-attr-invalid/input.htmljs +0 -1
  360. package/test/autotest/placeholder-attr-string-value/expected.html +0 -3
  361. package/test/autotest/placeholder-attr-string-value/input.htmljs +0 -1
  362. package/test/autotest/placeholder-attr-string-value-mixed-quotes/expected.html +0 -3
  363. package/test/autotest/placeholder-attr-string-value-mixed-quotes/input.htmljs +0 -1
  364. package/test/autotest/placeholder-attr-string-value-parens/expected.html +0 -3
  365. package/test/autotest/placeholder-attr-string-value-parens/input.htmljs +0 -1
  366. package/test/autotest/placeholder-attr-within-placeholder/expected.html +0 -2
  367. package/test/autotest/placeholder-attr-within-placeholder/input.htmljs +0 -1
  368. package/test/autotest/placeholder-attr-within-string-complex/expected.html +0 -2
  369. package/test/autotest/placeholder-attr-within-string-complex/input.htmljs +0 -1
  370. package/test/autotest/placeholder-attr-within-string-simple/expected.html +0 -2
  371. package/test/autotest/placeholder-attr-within-string-simple/input.htmljs +0 -1
  372. package/test/autotest/placeholder-attr-wrapped/expected.html +0 -2
  373. package/test/autotest/placeholder-attr-wrapped/input.htmljs +0 -1
  374. package/test/autotest/placeholder-backslash/expected.html +0 -23
  375. package/test/autotest/placeholder-backslash/input.htmljs +0 -15
  376. package/test/autotest/placeholder-body-multi-line-js-comment/expected.html +0 -3
  377. package/test/autotest/placeholder-body-multi-line-js-comment/input.htmljs +0 -1
  378. package/test/autotest/placeholder-body-single-line-js-comment/expected.html +0 -3
  379. package/test/autotest/placeholder-body-single-line-js-comment/input.htmljs +0 -2
  380. package/test/autotest/placeholder-body-text/expected.html +0 -5
  381. package/test/autotest/placeholder-body-text/input.htmljs +0 -1
  382. package/test/autotest/placeholder-escape/expected.html +0 -5
  383. package/test/autotest/placeholder-escape/input.htmljs +0 -3
  384. package/test/autotest/placeholder-no-escape/expected.html +0 -5
  385. package/test/autotest/placeholder-no-escape/input.htmljs +0 -3
  386. package/test/autotest/placeholder-tag-name-concise/expected.html +0 -2
  387. package/test/autotest/placeholder-tag-name-concise/input.htmljs +0 -1
  388. package/test/autotest/placeholder-tag-name-html/expected.html +0 -2
  389. package/test/autotest/placeholder-tag-name-html/input.htmljs +0 -1
  390. package/test/autotest/placeholder-unnamed-attr/expected.html +0 -2
  391. package/test/autotest/placeholder-unnamed-attr/input.htmljs +0 -1
  392. package/test/autotest/placeholder-unnamed-attr-escaped/expected.html +0 -2
  393. package/test/autotest/placeholder-unnamed-attr-escaped/input.htmljs +0 -1
  394. package/test/autotest/placeholder-unnamed-attr-escaped-escaped/expected.html +0 -2
  395. package/test/autotest/placeholder-unnamed-attr-escaped-escaped/input.htmljs +0 -1
  396. package/test/autotest/placeholder-unnamed-attr-last/expected.html +0 -2
  397. package/test/autotest/placeholder-unnamed-attr-last/input.htmljs +0 -1
  398. package/test/autotest/placeholder-unnamed-attr-last-concise/expected.html +0 -4
  399. package/test/autotest/placeholder-unnamed-attr-last-concise/input.htmljs +0 -2
  400. package/test/autotest/placeholder-unnamed-attr-last-self-closed/expected.html +0 -2
  401. package/test/autotest/placeholder-unnamed-attr-last-self-closed/input.htmljs +0 -1
  402. package/test/autotest/placeholder-unnamed-attr-trailing-text/expected.html +0 -1
  403. package/test/autotest/placeholder-unnamed-attr-trailing-text/input.htmljs +0 -1
  404. package/test/autotest/placeholder-within-placeholder/expected.html +0 -1
  405. package/test/autotest/placeholder-within-placeholder/input.htmljs +0 -1
  406. package/test/autotest/placeholder-within-placeholder-escaping/expected.html +0 -1
  407. package/test/autotest/placeholder-within-placeholder-escaping/input.htmljs +0 -1
  408. package/test/autotest/placeholder-within-script-tag/expected.html +0 -5
  409. package/test/autotest/placeholder-within-script-tag/input.htmljs +0 -1
  410. package/test/autotest/placeholder-within-script-within-string/expected.html +0 -5
  411. package/test/autotest/placeholder-within-script-within-string/input.htmljs +0 -1
  412. package/test/autotest/placeholder-within-string-newlines/expected.html +0 -4
  413. package/test/autotest/placeholder-within-string-newlines/input.htmljs +0 -3
  414. package/test/autotest/root-el/expected.html +0 -2
  415. package/test/autotest/root-el/input.htmljs +0 -1
  416. package/test/autotest/root-els/expected.html +0 -4
  417. package/test/autotest/root-els/input.htmljs +0 -2
  418. package/test/autotest/script/expected.html +0 -3
  419. package/test/autotest/script/input.htmljs +0 -2
  420. package/test/autotest/script-concise/expected.html +0 -6
  421. package/test/autotest/script-concise/input.htmljs +0 -7
  422. package/test/autotest/script-concise-invalid-nested-tag/expected.html +0 -3
  423. package/test/autotest/script-concise-invalid-nested-tag/input.htmljs +0 -3
  424. package/test/autotest/script-empty-concise/expected.html +0 -6
  425. package/test/autotest/script-empty-concise/input.htmljs +0 -3
  426. package/test/autotest/script-escaped-placeholder/expected.html +0 -5
  427. package/test/autotest/script-escaped-placeholder/input.htmljs +0 -4
  428. package/test/autotest/script-self-closed/expected.html +0 -9
  429. package/test/autotest/script-self-closed/input.htmljs +0 -4
  430. package/test/autotest/script-single-line-comment/expected.html +0 -3
  431. package/test/autotest/script-single-line-comment/input.htmljs +0 -1
  432. package/test/autotest/scriptlet-block/expected.html +0 -1
  433. package/test/autotest/scriptlet-block/input.htmljs +0 -4
  434. package/test/autotest/scriptlet-block-division/expected.html +0 -1
  435. package/test/autotest/scriptlet-block-division/input.htmljs +0 -4
  436. package/test/autotest/scriptlet-block-html/expected.html +0 -1
  437. package/test/autotest/scriptlet-block-html/input.htmljs +0 -6
  438. package/test/autotest/scriptlet-block-invalid-comment/expected.html +0 -1
  439. package/test/autotest/scriptlet-block-invalid-comment/input.htmljs +0 -3
  440. package/test/autotest/scriptlet-block-multiline-comment/expected.html +0 -1
  441. package/test/autotest/scriptlet-block-multiline-comment/input.htmljs +0 -4
  442. package/test/autotest/scriptlet-block-nested/expected.html +0 -1
  443. package/test/autotest/scriptlet-block-nested/input.htmljs +0 -16
  444. package/test/autotest/scriptlet-block-regex/expected.html +0 -1
  445. package/test/autotest/scriptlet-block-regex/input.htmljs +0 -4
  446. package/test/autotest/scriptlet-block-single-line-comment/expected.html +0 -1
  447. package/test/autotest/scriptlet-block-single-line-comment/input.htmljs +0 -4
  448. package/test/autotest/scriptlet-block-template-literal-href/expected.html +0 -1
  449. package/test/autotest/scriptlet-block-template-literal-href/input.htmljs +0 -4
  450. package/test/autotest/scriptlet-line/expected.html +0 -1
  451. package/test/autotest/scriptlet-line/input.htmljs +0 -1
  452. package/test/autotest/scriptlet-line-continue/expected.html +0 -1
  453. package/test/autotest/scriptlet-line-continue/input.htmljs +0 -3
  454. package/test/autotest/scriptlet-line-continue-chain/expected.html +0 -3
  455. package/test/autotest/scriptlet-line-continue-chain/input.htmljs +0 -8
  456. package/test/autotest/scriptlet-line-html/expected.html +0 -1
  457. package/test/autotest/scriptlet-line-html/input.htmljs +0 -3
  458. package/test/autotest/scriptlet-line-multiline-comments/expected.html +0 -5
  459. package/test/autotest/scriptlet-line-multiline-comments/input.htmljs +0 -7
  460. package/test/autotest/scriptlet-line-no-middle/expected.html +0 -2
  461. package/test/autotest/scriptlet-line-no-middle/input.htmljs +0 -1
  462. package/test/autotest/scriptlet-line-no-middle-html/expected.html +0 -1
  463. package/test/autotest/scriptlet-line-no-middle-html/input.htmljs +0 -3
  464. package/test/autotest/scriptlet-line-regex-open-bracket/input.htmljs +0 -1
  465. package/test/autotest/scriptlet-line-regex-open-bracket/test.js +0 -1
  466. package/test/autotest/scriptlet-line-regex-open-curly/input.htmljs +0 -1
  467. package/test/autotest/scriptlet-line-regex-open-curly/test.js +0 -1
  468. package/test/autotest/scriptlet-line-template-literal/expected.html +0 -1
  469. package/test/autotest/scriptlet-line-template-literal/input.htmljs +0 -4
  470. package/test/autotest/scriptlet-line-trailing-line-comment/expected.html +0 -5
  471. package/test/autotest/scriptlet-line-trailing-line-comment/input.htmljs +0 -5
  472. package/test/autotest/scriptlet-tag/expected.html +0 -11
  473. package/test/autotest/scriptlet-tag/input.htmljs +0 -6
  474. package/test/autotest/scriptlet-tag-html/expected.html +0 -7
  475. package/test/autotest/scriptlet-tag-html/input.htmljs +0 -8
  476. package/test/autotest/self-closed-tag/expected.html +0 -2
  477. package/test/autotest/self-closed-tag/input.htmljs +0 -1
  478. package/test/autotest/self-closed-tag-attrs/expected.html +0 -2
  479. package/test/autotest/self-closed-tag-attrs/input.htmljs +0 -1
  480. package/test/autotest/self-closing-open-tag-only/expected.html +0 -3
  481. package/test/autotest/self-closing-open-tag-only/input.htmljs +0 -1
  482. package/test/autotest/semicolon-concise/expected.html +0 -4
  483. package/test/autotest/semicolon-concise/input.htmljs +0 -2
  484. package/test/autotest/shorthand-class-dynamic/expected.html +0 -2
  485. package/test/autotest/shorthand-class-dynamic/input.htmljs +0 -1
  486. package/test/autotest/shorthand-class-dynamic-literal-prefix/expected.html +0 -2
  487. package/test/autotest/shorthand-class-dynamic-literal-prefix/input.htmljs +0 -1
  488. package/test/autotest/shorthand-class-dynamic-literal-suffix/expected.html +0 -2
  489. package/test/autotest/shorthand-class-dynamic-literal-suffix/input.htmljs +0 -1
  490. package/test/autotest/shorthand-class-self-closed/expected.html +0 -6
  491. package/test/autotest/shorthand-class-self-closed/input.htmljs +0 -3
  492. package/test/autotest/shorthand-closing-html/expected.html +0 -9
  493. package/test/autotest/shorthand-closing-html/input.htmljs +0 -5
  494. package/test/autotest/shorthand-closing-html2/expected.html +0 -3
  495. package/test/autotest/shorthand-closing-html2/input.htmljs +0 -2
  496. package/test/autotest/shorthand-closing-html3/expected.html +0 -3
  497. package/test/autotest/shorthand-closing-html3/input.htmljs +0 -2
  498. package/test/autotest/shorthand-div-id/expected.html +0 -2
  499. package/test/autotest/shorthand-div-id/input.htmljs +0 -1
  500. package/test/autotest/shorthand-div-id-class/expected.html +0 -2
  501. package/test/autotest/shorthand-div-id-class/input.htmljs +0 -1
  502. package/test/autotest/shorthand-div-id-class-multiple/expected.html +0 -2
  503. package/test/autotest/shorthand-div-id-class-multiple/input.htmljs +0 -1
  504. package/test/autotest/shorthand-id/expected.html +0 -2
  505. package/test/autotest/shorthand-id/input.htmljs +0 -1
  506. package/test/autotest/shorthand-id-class/expected.html +0 -2
  507. package/test/autotest/shorthand-id-class/input.htmljs +0 -1
  508. package/test/autotest/shorthand-id-class-html/expected.html +0 -3
  509. package/test/autotest/shorthand-id-class-html/input.htmljs +0 -2
  510. package/test/autotest/shorthand-id-dup/expected.html +0 -1
  511. package/test/autotest/shorthand-id-dup/input.htmljs +0 -1
  512. package/test/autotest/shorthand-id-dynamic/expected.html +0 -2
  513. package/test/autotest/shorthand-id-dynamic/input.htmljs +0 -1
  514. package/test/autotest/shorthand-id-dynamic-literal-prefix/expected.html +0 -2
  515. package/test/autotest/shorthand-id-dynamic-literal-prefix/input.htmljs +0 -1
  516. package/test/autotest/shorthand-id-dynamic-literal-suffix/expected.html +0 -2
  517. package/test/autotest/shorthand-id-dynamic-literal-suffix/input.htmljs +0 -1
  518. package/test/autotest/shorthand-id-self-closed/expected.html +0 -6
  519. package/test/autotest/shorthand-id-self-closed/input.htmljs +0 -3
  520. package/test/autotest/shorthand-mixed/expected.html +0 -15
  521. package/test/autotest/shorthand-mixed/input.htmljs +0 -5
  522. package/test/autotest/shorthand-mixed-concise/expected.html +0 -11
  523. package/test/autotest/shorthand-mixed-concise/input.htmljs +0 -5
  524. package/test/autotest/simple-text-delimited/expected.html +0 -1
  525. package/test/autotest/simple-text-delimited/input.htmljs +0 -3
  526. package/test/autotest/single-line-text-block/expected.html +0 -2
  527. package/test/autotest/single-line-text-block/input.htmljs +0 -2
  528. package/test/autotest/single-line-text-block-nested/expected.html +0 -4
  529. package/test/autotest/single-line-text-block-nested/input.htmljs +0 -3
  530. package/test/autotest/single-line-text-block-sibling/expected.html +0 -6
  531. package/test/autotest/single-line-text-block-sibling/input.htmljs +0 -5
  532. package/test/autotest/stray-forward-slash-within-open-tag/expected.html +0 -3
  533. package/test/autotest/stray-forward-slash-within-open-tag/input.htmljs +0 -1
  534. package/test/autotest/stray-special-chars/expected.html +0 -3
  535. package/test/autotest/stray-special-chars/input.htmljs +0 -1
  536. package/test/autotest/strip-bom/expected.html +0 -3
  537. package/test/autotest/strip-bom/input-good.htmljs +0 -1
  538. package/test/autotest/strip-bom/input.htmljs +0 -1
  539. package/test/autotest/strip-bom/input.htmljs.txt +0 -60
  540. package/test/autotest/tag-name-expression-literal-prefix/expected.html +0 -3
  541. package/test/autotest/tag-name-expression-literal-prefix/input.htmljs +0 -2
  542. package/test/autotest/tag-name-expression-literal-prefix-attrs/expected.html +0 -3
  543. package/test/autotest/tag-name-expression-literal-prefix-attrs/input.htmljs +0 -2
  544. package/test/autotest/tag-name-expression-literal-prefix-suffix/expected.html +0 -3
  545. package/test/autotest/tag-name-expression-literal-prefix-suffix/input.htmljs +0 -2
  546. package/test/autotest/tag-name-expression-literal-suffix/expected.html +0 -3
  547. package/test/autotest/tag-name-expression-literal-suffix/input.htmljs +0 -2
  548. package/test/autotest/tag-name-expression-shorthand-id/expected.html +0 -2
  549. package/test/autotest/tag-name-expression-shorthand-id/input.htmljs +0 -1
  550. package/test/autotest/tag-name-expression-simple/expected.html +0 -3
  551. package/test/autotest/tag-name-expression-simple/input.htmljs +0 -2
  552. package/test/autotest/tag-name-expression-simple-empty-close/expected.html +0 -3
  553. package/test/autotest/tag-name-expression-simple-empty-close/input.htmljs +0 -2
  554. package/test/autotest/tag-var-declaration/expected.html +0 -38
  555. package/test/autotest/tag-var-declaration/input.htmljs +0 -19
  556. package/test/autotest/tag-var-with-params/expected.html +0 -5
  557. package/test/autotest/tag-var-with-params/input.htmljs +0 -3
  558. package/test/autotest/text-after-semicolon/expected.html +0 -15
  559. package/test/autotest/text-after-semicolon/input.htmljs +0 -8
  560. package/test/autotest/text-after-tag/expected.html +0 -3
  561. package/test/autotest/text-after-tag/input.htmljs +0 -1
  562. package/test/autotest/text-parse-mode-concise/expected.html +0 -5
  563. package/test/autotest/text-parse-mode-concise/input.htmljs +0 -3
  564. package/test/autotest/text-parse-mode-concise/test.js +0 -1
  565. package/test/autotest/text-parse-mode-delimited-block/expected.html +0 -8
  566. package/test/autotest/text-parse-mode-delimited-block/input.htmljs +0 -6
  567. package/test/autotest/text-parse-mode-delimited-block/test.js +0 -1
  568. package/test/autotest/text-parse-mode-html/expected.html +0 -7
  569. package/test/autotest/text-parse-mode-html/input.htmljs +0 -3
  570. package/test/autotest/text-parse-mode-html/test.js +0 -1
  571. package/test/autotest/text-parse-mode-parsed-text/expected.html +0 -11
  572. package/test/autotest/text-parse-mode-parsed-text/input.htmljs +0 -7
  573. package/test/autotest/text-parse-mode-parsed-text/test.js +0 -7
  574. package/test/autotest/text-parse-mode-static-text/expected.html +0 -11
  575. package/test/autotest/text-parse-mode-static-text/input.htmljs +0 -7
  576. package/test/autotest/text-parse-mode-static-text/test.js +0 -7
  577. package/test/autotest/textarea/expected.html +0 -5
  578. package/test/autotest/textarea/input.htmljs +0 -2
  579. package/test/autotest/textarea/test.js +0 -0
  580. package/test/autotest/var/expected.html +0 -9
  581. package/test/autotest/var/input.htmljs +0 -5
  582. package/test/autotest/var-new-Date/expected.html +0 -2
  583. package/test/autotest/var-new-Date/input.htmljs +0 -1
  584. package/test/autotest/whitespace-around-equals/expected.html +0 -2
  585. package/test/autotest/whitespace-around-equals/input.htmljs +0 -1
  586. package/test/autotest/whitespace-empty-lines/expected.html +0 -7
  587. package/test/autotest/whitespace-empty-lines/input.htmljs +0 -4
  588. package/test/autotest/whitespace-empty-lines-indent/expected.html +0 -8
  589. package/test/autotest/whitespace-empty-lines-indent/input.htmljs +0 -4
  590. package/test/autotest/whitespace-newline/expected.html +0 -7
  591. package/test/autotest/whitespace-newline/input.htmljs +0 -6
  592. package/test/autotest/whitespace-newline-indent/expected.html +0 -7
  593. package/test/autotest/whitespace-newline-indent/input.htmljs +0 -6
  594. package/test/autotest/whitespace-only-reset-indent/expected.html +0 -6
  595. package/test/autotest/whitespace-only-reset-indent/input.htmljs +0 -3
  596. package/test/autotest/windows-line-ending/expected.html +0 -10
  597. package/test/autotest/windows-line-ending/test.js +0 -11
  598. package/test/autotest/xml-declaration/expected.html +0 -5
  599. package/test/autotest/xml-declaration/input.htmljs +0 -2
  600. package/test/autotest/xml-declaration-ill-formed/expected.html +0 -5
  601. package/test/autotest/xml-declaration-ill-formed/input.htmljs +0 -2
  602. package/test/autotest-1.x/argument-attr/expected.html +0 -2
  603. package/test/autotest-1.x/argument-attr/input.htmljs +0 -1
  604. package/test/autotest-1.x/argument-attr-extra-whitespace/expected.html +0 -4
  605. package/test/autotest-1.x/argument-attr-extra-whitespace/input.htmljs +0 -2
  606. package/test/autotest-1.x/argument-attr-multiple/expected.html +0 -1
  607. package/test/autotest-1.x/argument-attr-multiple/input.htmljs +0 -1
  608. package/test/autotest-1.x/argument-tag/expected.html +0 -2
  609. package/test/autotest-1.x/argument-tag/input.htmljs +0 -1
  610. package/test/autotest-1.x/argument-tag-attr/expected.html +0 -2
  611. package/test/autotest-1.x/argument-tag-attr/input.htmljs +0 -1
  612. package/test/autotest-1.x/argument-tag-complex/expected.html +0 -2
  613. package/test/autotest-1.x/argument-tag-complex/input.htmljs +0 -1
  614. package/test/autotest-1.x/argument-tag-extra-whitespace/expected.html +0 -2
  615. package/test/autotest-1.x/argument-tag-extra-whitespace/input.htmljs +0 -1
  616. package/test/autotest-1.x/argument-tag-multiple/expected.html +0 -1
  617. package/test/autotest-1.x/argument-tag-multiple/input.htmljs +0 -1
  618. package/test/autotest-1.x/argument-tag-nested-parens/expected.html +0 -3
  619. package/test/autotest-1.x/argument-tag-nested-parens/input.htmljs +0 -4
  620. package/test/autotest-1.x/attr-complex/expected.html +0 -1
  621. package/test/autotest-1.x/attr-complex/input.htmljs +0 -1
  622. package/test/autotest-1.x/attr-escape-characters/expected.html +0 -3
  623. package/test/autotest-1.x/attr-escape-characters/input.htmljs +0 -3
  624. package/test/autotest-1.x/attr-escaped-dollar/expected.html +0 -1
  625. package/test/autotest-1.x/attr-escaped-dollar/input.htmljs +0 -1
  626. package/test/autotest-1.x/attr-escaped-dollar/test.js +0 -5
  627. package/test/autotest-1.x/attr-grouped/expected.html +0 -3
  628. package/test/autotest-1.x/attr-grouped/input.htmljs +0 -5
  629. package/test/autotest-1.x/attr-grouped-2/expected.html +0 -3
  630. package/test/autotest-1.x/attr-grouped-2/input.htmljs +0 -5
  631. package/test/autotest-1.x/attr-grouped-3/expected.html +0 -3
  632. package/test/autotest-1.x/attr-grouped-3/input.htmljs +0 -5
  633. package/test/autotest-1.x/attr-grouped-4/expected.html +0 -3
  634. package/test/autotest-1.x/attr-grouped-4/input.htmljs +0 -5
  635. package/test/autotest-1.x/attr-grouped-invalid/expected.html +0 -1
  636. package/test/autotest-1.x/attr-grouped-invalid/input.htmljs +0 -5
  637. package/test/autotest-1.x/attr-grouped-invalid-eof/expected.html +0 -1
  638. package/test/autotest-1.x/attr-grouped-invalid-eof/input.htmljs +0 -4
  639. package/test/autotest-1.x/attr-grouped-multiple/expected.html +0 -3
  640. package/test/autotest-1.x/attr-grouped-multiple/input.htmljs +0 -4
  641. package/test/autotest-1.x/attr-int-and-id/expected.html +0 -2
  642. package/test/autotest-1.x/attr-int-and-id/input.htmljs +0 -1
  643. package/test/autotest-1.x/attr-literal-false/expected.html +0 -2
  644. package/test/autotest-1.x/attr-literal-false/input.htmljs +0 -1
  645. package/test/autotest-1.x/attr-literal-false/test.js +0 -1
  646. package/test/autotest-1.x/attr-literal-null/expected.html +0 -2
  647. package/test/autotest-1.x/attr-literal-null/input.htmljs +0 -1
  648. package/test/autotest-1.x/attr-literal-null/test.js +0 -1
  649. package/test/autotest-1.x/attr-literal-numbers/expected.html +0 -2
  650. package/test/autotest-1.x/attr-literal-numbers/input.htmljs +0 -1
  651. package/test/autotest-1.x/attr-literal-numbers/test.js +0 -1
  652. package/test/autotest-1.x/attr-literal-string-double-quotes/expected.html +0 -2
  653. package/test/autotest-1.x/attr-literal-string-double-quotes/input.htmljs +0 -1
  654. package/test/autotest-1.x/attr-literal-string-double-quotes/test.js +0 -1
  655. package/test/autotest-1.x/attr-literal-string-single-quotes/expected.html +0 -2
  656. package/test/autotest-1.x/attr-literal-string-single-quotes/input.htmljs +0 -1
  657. package/test/autotest-1.x/attr-literal-string-single-quotes/test.js +0 -1
  658. package/test/autotest-1.x/attr-literal-true/expected.html +0 -2
  659. package/test/autotest-1.x/attr-literal-true/input.htmljs +0 -1
  660. package/test/autotest-1.x/attr-literal-true/test.js +0 -1
  661. package/test/autotest-1.x/attr-literal-undefined/expected.html +0 -2
  662. package/test/autotest-1.x/attr-literal-undefined/input.htmljs +0 -1
  663. package/test/autotest-1.x/attr-literal-undefined/test.js +0 -1
  664. package/test/autotest-1.x/attr-multi-line-comment/expected.html +0 -3
  665. package/test/autotest-1.x/attr-multi-line-comment/input.htmljs +0 -1
  666. package/test/autotest-1.x/attr-multi-line-string/expected.html +0 -2
  667. package/test/autotest-1.x/attr-multi-line-string/input.htmljs +0 -3
  668. package/test/autotest-1.x/attr-name-with-html-chars/expected.html +0 -1
  669. package/test/autotest-1.x/attr-name-with-html-chars/input.htmljs +0 -1
  670. package/test/autotest-1.x/attr-no-value/expected.html +0 -3
  671. package/test/autotest-1.x/attr-no-value/input.htmljs +0 -1
  672. package/test/autotest-1.x/attr-no-value-self-closed/expected.html +0 -2
  673. package/test/autotest-1.x/attr-no-value-self-closed/input.htmljs +0 -1
  674. package/test/autotest-1.x/attr-non-literal/expected.html +0 -5
  675. package/test/autotest-1.x/attr-non-literal/input.htmljs +0 -2
  676. package/test/autotest-1.x/attr-non-literal/test.js +0 -1
  677. package/test/autotest-1.x/attr-object-expressions/expected.html +0 -4
  678. package/test/autotest-1.x/attr-object-expressions/input.htmljs +0 -3
  679. package/test/autotest-1.x/attr-simple-expression/expected.html +0 -3
  680. package/test/autotest-1.x/attr-simple-expression/input.htmljs +0 -1
  681. package/test/autotest-1.x/attr-value-self-closed/expected.html +0 -2
  682. package/test/autotest-1.x/attr-value-self-closed/input.htmljs +0 -1
  683. package/test/autotest-1.x/attr-with-parens-and-double-quoted-strings/expected.html +0 -2
  684. package/test/autotest-1.x/attr-with-parens-and-double-quoted-strings/input.htmljs +0 -1
  685. package/test/autotest-1.x/attr-with-parens-and-single-quoted-strings/expected.html +0 -2
  686. package/test/autotest-1.x/attr-with-parens-and-single-quoted-strings/input.htmljs +0 -1
  687. package/test/autotest-1.x/attr-with-right-angle-bracket/expected.html +0 -3
  688. package/test/autotest-1.x/attr-with-right-angle-bracket/input.htmljs +0 -1
  689. package/test/autotest-1.x/attr-with-right-angle-bracket-parens/expected.html +0 -3
  690. package/test/autotest-1.x/attr-with-right-angle-bracket-parens/input.htmljs +0 -1
  691. package/test/autotest-1.x/attr-without-delimiters/expected.html +0 -2
  692. package/test/autotest-1.x/attr-without-delimiters/input.htmljs +0 -1
  693. package/test/autotest-1.x/backtick-string/expected.html +0 -3
  694. package/test/autotest-1.x/backtick-string/input.htmljs +0 -2
  695. package/test/autotest-1.x/backtick-string-eof/expected.html +0 -1
  696. package/test/autotest-1.x/backtick-string-eof/input.htmljs +0 -2
  697. package/test/autotest-1.x/bad-tag-indent/expected.html +0 -1
  698. package/test/autotest-1.x/bad-tag-indent/input.htmljs +0 -1
  699. package/test/autotest-1.x/cdata/expected.html +0 -3
  700. package/test/autotest-1.x/cdata/input.htmljs +0 -1
  701. package/test/autotest-1.x/cdata-2/expected.html +0 -5
  702. package/test/autotest-1.x/cdata-2/input.htmljs +0 -3
  703. package/test/autotest-1.x/cdata-pos/expected.html +0 -7
  704. package/test/autotest-1.x/cdata-pos/input.htmljs +0 -4
  705. package/test/autotest-1.x/cdata-pos/test.js +0 -1
  706. package/test/autotest-1.x/comment-concise-js-block/expected.html +0 -4
  707. package/test/autotest-1.x/comment-concise-js-block/input.htmljs +0 -6
  708. package/test/autotest-1.x/comment-concise-js-block-trailing/expected.html +0 -4
  709. package/test/autotest-1.x/comment-concise-js-block-trailing/input.htmljs +0 -6
  710. package/test/autotest-1.x/comment-concise-js-line/expected.html +0 -4
  711. package/test/autotest-1.x/comment-concise-js-line/input.htmljs +0 -3
  712. package/test/autotest-1.x/comments-within-open-tag/expected.html +0 -2
  713. package/test/autotest-1.x/comments-within-open-tag/input.htmljs +0 -1
  714. package/test/autotest-1.x/complex/expected.html +0 -24
  715. package/test/autotest-1.x/complex/input.htmljs +0 -22
  716. package/test/autotest-1.x/complex-attr-name/expected.html +0 -2
  717. package/test/autotest-1.x/complex-attr-name/input.htmljs +0 -1
  718. package/test/autotest-1.x/concise-complex-tag-name/expected.html +0 -2
  719. package/test/autotest-1.x/concise-complex-tag-name/input.htmljs +0 -1
  720. package/test/autotest-1.x/concise-contentplaceholder-html-start/expected.html +0 -5
  721. package/test/autotest-1.x/concise-contentplaceholder-html-start/input.htmljs +0 -1
  722. package/test/autotest-1.x/concise-contentplaceholder-start/expected.html +0 -1
  723. package/test/autotest-1.x/concise-contentplaceholder-start/input.htmljs +0 -1
  724. package/test/autotest-1.x/declaration/expected.html +0 -1
  725. package/test/autotest-1.x/declaration/input.htmljs +0 -1
  726. package/test/autotest-1.x/double-hyphen-block/expected.html +0 -12
  727. package/test/autotest-1.x/double-hyphen-block/input.htmljs +0 -8
  728. package/test/autotest-1.x/double-hyphen-line/expected.html +0 -12
  729. package/test/autotest-1.x/double-hyphen-line/input.htmljs +0 -5
  730. package/test/autotest-1.x/double-hyphen-line-start/expected.html +0 -12
  731. package/test/autotest-1.x/double-hyphen-line-start/input.htmljs +0 -6
  732. package/test/autotest-1.x/dtd/expected.html +0 -1
  733. package/test/autotest-1.x/dtd/input.htmljs +0 -1
  734. package/test/autotest-1.x/empty-closing-tag/expected.html +0 -8
  735. package/test/autotest-1.x/empty-closing-tag/input.htmljs +0 -6
  736. package/test/autotest-1.x/empty-closing-tag2/expected.html +0 -9
  737. package/test/autotest-1.x/empty-closing-tag2/input.htmljs +0 -5
  738. package/test/autotest-1.x/eof-attr-argument/expected.html +0 -1
  739. package/test/autotest-1.x/eof-attr-argument/input.htmljs +0 -1
  740. package/test/autotest-1.x/eof-attr-name/expected.html +0 -3
  741. package/test/autotest-1.x/eof-attr-name/input.htmljs +0 -1
  742. package/test/autotest-1.x/eof-attr-value/expected.html +0 -3
  743. package/test/autotest-1.x/eof-attr-value/input.htmljs +0 -1
  744. package/test/autotest-1.x/eof-attr-value-js-comment-comment/expected.html +0 -3
  745. package/test/autotest-1.x/eof-attr-value-js-comment-comment/input.htmljs +0 -1
  746. package/test/autotest-1.x/eof-attr-value-js-comment-comment-concise/expected.html +0 -1
  747. package/test/autotest-1.x/eof-attr-value-js-comment-comment-concise/input.htmljs +0 -1
  748. package/test/autotest-1.x/eof-attr-value-string/expected.html +0 -1
  749. package/test/autotest-1.x/eof-attr-value-string/input.htmljs +0 -1
  750. package/test/autotest-1.x/eof-doctype/expected.html +0 -1
  751. package/test/autotest-1.x/eof-doctype/input.htmljs +0 -1
  752. package/test/autotest-1.x/eof-placeholder-body-escaped/expected.html +0 -4
  753. package/test/autotest-1.x/eof-placeholder-body-escaped/input.htmljs +0 -1
  754. package/test/autotest-1.x/eof-placeholder-body-non-escaped/expected.html +0 -4
  755. package/test/autotest-1.x/eof-placeholder-body-non-escaped/input.htmljs +0 -4
  756. package/test/autotest-1.x/eof-placeholder-concise/expected.html +0 -3
  757. package/test/autotest-1.x/eof-placeholder-concise/input.htmljs +0 -2
  758. package/test/autotest-1.x/eof-placeholder-script-body-escaped/expected.html +0 -4
  759. package/test/autotest-1.x/eof-placeholder-script-body-escaped/input.htmljs +0 -1
  760. package/test/autotest-1.x/eof-placeholder-script-body-non-escaped/expected.html +0 -4
  761. package/test/autotest-1.x/eof-placeholder-script-body-non-escaped/input.htmljs +0 -1
  762. package/test/autotest-1.x/eof-placeholder-string/expected.html +0 -4
  763. package/test/autotest-1.x/eof-placeholder-string/input.htmljs +0 -1
  764. package/test/autotest-1.x/eof-script-body/expected.html +0 -4
  765. package/test/autotest-1.x/eof-script-body/input.htmljs +0 -2
  766. package/test/autotest-1.x/eof-style/expected.html +0 -4
  767. package/test/autotest-1.x/eof-style/input.htmljs +0 -1
  768. package/test/autotest-1.x/eof-tag-start/expected.html +0 -3
  769. package/test/autotest-1.x/eof-tag-start/input.htmljs +0 -1
  770. package/test/autotest-1.x/eof-xml-declaration/expected.html +0 -1
  771. package/test/autotest-1.x/eof-xml-declaration/input.htmljs +0 -1
  772. package/test/autotest-1.x/html-block-after-tag/expected.html +0 -6
  773. package/test/autotest-1.x/html-block-after-tag/input.htmljs +0 -1
  774. package/test/autotest-1.x/html-comments/expected.html +0 -3
  775. package/test/autotest-1.x/html-comments/input.htmljs +0 -1
  776. package/test/autotest-1.x/html-comments-ignore-placeholders/expected.html +0 -1
  777. package/test/autotest-1.x/html-comments-ignore-placeholders/input.htmljs +0 -1
  778. package/test/autotest-1.x/ignorePlaceholders-attr-double-escaped-dollar-placeholder/expected.html +0 -2
  779. package/test/autotest-1.x/ignorePlaceholders-attr-double-escaped-dollar-placeholder/input.htmljs +0 -1
  780. package/test/autotest-1.x/ignorePlaceholders-attr-double-escaped-dollar-placeholder/test.js +0 -1
  781. package/test/autotest-1.x/ignorePlaceholders-attr-escaped-dollar-placeholder/expected.html +0 -2
  782. package/test/autotest-1.x/ignorePlaceholders-attr-escaped-dollar-placeholder/input.htmljs +0 -1
  783. package/test/autotest-1.x/ignorePlaceholders-attr-escaped-dollar-placeholder/test.js +0 -1
  784. package/test/autotest-1.x/ignorePlaceholders-attr-placeholder/expected.html +0 -2
  785. package/test/autotest-1.x/ignorePlaceholders-attr-placeholder/input.htmljs +0 -1
  786. package/test/autotest-1.x/ignorePlaceholders-attr-placeholder/test.js +0 -1
  787. package/test/autotest-1.x/invalid-closing-tag/expected.html +0 -4
  788. package/test/autotest-1.x/invalid-closing-tag/input.htmljs +0 -1
  789. package/test/autotest-1.x/mixed/expected.html +0 -21
  790. package/test/autotest-1.x/mixed/input.htmljs +0 -8
  791. package/test/autotest-1.x/mixed-bad-indentation/expected.html +0 -7
  792. package/test/autotest-1.x/mixed-bad-indentation/input.htmljs +0 -3
  793. package/test/autotest-1.x/mixed-cdata/expected.html +0 -7
  794. package/test/autotest-1.x/mixed-cdata/input.htmljs +0 -3
  795. package/test/autotest-1.x/mixed-comment/expected.html +0 -7
  796. package/test/autotest-1.x/mixed-comment/input.htmljs +0 -6
  797. package/test/autotest-1.x/mixed-invalid/expected.html +0 -16
  798. package/test/autotest-1.x/mixed-invalid/input.htmljs +0 -9
  799. package/test/autotest-1.x/mixed-open-tag-only/expected.html +0 -14
  800. package/test/autotest-1.x/mixed-open-tag-only/input.htmljs +0 -6
  801. package/test/autotest-1.x/multiline-html-block/expected.html +0 -5
  802. package/test/autotest-1.x/multiline-html-block/input.htmljs +0 -4
  803. package/test/autotest-1.x/multiline-html-block-empty/expected.html +0 -0
  804. package/test/autotest-1.x/multiline-html-block-empty/input.htmljs +0 -2
  805. package/test/autotest-1.x/multiline-html-block-missing-end/expected.html +0 -1
  806. package/test/autotest-1.x/multiline-html-block-missing-end/input.htmljs +0 -3
  807. package/test/autotest-1.x/multiline-html-block-nested/expected.html +0 -7
  808. package/test/autotest-1.x/multiline-html-block-nested/input.htmljs +0 -5
  809. package/test/autotest-1.x/multiline-html-block-nested-empty/expected.html +0 -2
  810. package/test/autotest-1.x/multiline-html-block-nested-empty/input.htmljs +0 -3
  811. package/test/autotest-1.x/multiline-text-block/expected.html +0 -1
  812. package/test/autotest-1.x/multiline-text-block/input.htmljs +0 -4
  813. package/test/autotest-1.x/multiline-text-block-bad/expected.html +0 -1
  814. package/test/autotest-1.x/multiline-text-block-bad/input.htmljs +0 -5
  815. package/test/autotest-1.x/multiline-text-block-with-hyphens/expected.html +0 -1
  816. package/test/autotest-1.x/multiline-text-block-with-hyphens/input.htmljs +0 -4
  817. package/test/autotest-1.x/nested-pyramid/expected.html +0 -12
  818. package/test/autotest-1.x/nested-pyramid/input.htmljs +0 -6
  819. package/test/autotest-1.x/nested-siblings/expected.html +0 -6
  820. package/test/autotest-1.x/nested-siblings/input.htmljs +0 -3
  821. package/test/autotest-1.x/nested-tags/expected.html +0 -4
  822. package/test/autotest-1.x/nested-tags/input.htmljs +0 -2
  823. package/test/autotest-1.x/nested-text/expected.html +0 -8
  824. package/test/autotest-1.x/nested-text/input.htmljs +0 -8
  825. package/test/autotest-1.x/new-attr-prefix/expected.html +0 -3
  826. package/test/autotest-1.x/new-attr-prefix/input.htmljs +0 -1
  827. package/test/autotest-1.x/open-tag-only/expected.html +0 -12
  828. package/test/autotest-1.x/open-tag-only/input.htmljs +0 -1
  829. package/test/autotest-1.x/open-tag-only-custom/expected.html +0 -10
  830. package/test/autotest-1.x/open-tag-only-custom/input.htmljs +0 -4
  831. package/test/autotest-1.x/open-tag-only-custom/test.js +0 -9
  832. package/test/autotest-1.x/open-tag-only-with-body/expected.html +0 -4
  833. package/test/autotest-1.x/open-tag-only-with-body/input.htmljs +0 -5
  834. package/test/autotest-1.x/open-tag-only-with-body-concise/expected.html +0 -3
  835. package/test/autotest-1.x/open-tag-only-with-body-concise/input.htmljs +0 -2
  836. package/test/autotest-1.x/open-tag-parser-state/expected.html +0 -21
  837. package/test/autotest-1.x/open-tag-parser-state/input.htmljs +0 -11
  838. package/test/autotest-1.x/open-tag-parser-state/test.js +0 -21
  839. package/test/autotest-1.x/open-tag-parser-state-concise/expected.html +0 -19
  840. package/test/autotest-1.x/open-tag-parser-state-concise/input.htmljs +0 -17
  841. package/test/autotest-1.x/open-tag-parser-state-concise/test.js +0 -17
  842. package/test/autotest-1.x/parsed-text-style-tag/expected.html +0 -3
  843. package/test/autotest-1.x/parsed-text-style-tag/input.htmljs +0 -1
  844. package/test/autotest-1.x/parsed-text-style-tag-class/expected.html +0 -12
  845. package/test/autotest-1.x/parsed-text-style-tag-class/input.htmljs +0 -3
  846. package/test/autotest-1.x/placeholder-attr-invalid/expected.html +0 -1
  847. package/test/autotest-1.x/placeholder-attr-invalid/input.htmljs +0 -1
  848. package/test/autotest-1.x/placeholder-attr-string-value/expected.html +0 -3
  849. package/test/autotest-1.x/placeholder-attr-string-value/input.htmljs +0 -1
  850. package/test/autotest-1.x/placeholder-attr-string-value-mixed-quotes/expected.html +0 -3
  851. package/test/autotest-1.x/placeholder-attr-string-value-mixed-quotes/input.htmljs +0 -1
  852. package/test/autotest-1.x/placeholder-attr-string-value-parens/expected.html +0 -3
  853. package/test/autotest-1.x/placeholder-attr-string-value-parens/input.htmljs +0 -1
  854. package/test/autotest-1.x/placeholder-attr-within-placeholder/expected.html +0 -2
  855. package/test/autotest-1.x/placeholder-attr-within-placeholder/input.htmljs +0 -1
  856. package/test/autotest-1.x/placeholder-attr-within-string-complex/expected.html +0 -2
  857. package/test/autotest-1.x/placeholder-attr-within-string-complex/input.htmljs +0 -1
  858. package/test/autotest-1.x/placeholder-attr-within-string-simple/expected.html +0 -2
  859. package/test/autotest-1.x/placeholder-attr-within-string-simple/input.htmljs +0 -1
  860. package/test/autotest-1.x/placeholder-attr-wrapped/expected.html +0 -2
  861. package/test/autotest-1.x/placeholder-attr-wrapped/input.htmljs +0 -1
  862. package/test/autotest-1.x/placeholder-backslash/expected.html +0 -23
  863. package/test/autotest-1.x/placeholder-backslash/input.htmljs +0 -15
  864. package/test/autotest-1.x/placeholder-body-multi-line-js-comment/expected.html +0 -3
  865. package/test/autotest-1.x/placeholder-body-multi-line-js-comment/input.htmljs +0 -1
  866. package/test/autotest-1.x/placeholder-body-single-line-js-comment/expected.html +0 -3
  867. package/test/autotest-1.x/placeholder-body-single-line-js-comment/input.htmljs +0 -2
  868. package/test/autotest-1.x/placeholder-body-text/expected.html +0 -5
  869. package/test/autotest-1.x/placeholder-body-text/input.htmljs +0 -1
  870. package/test/autotest-1.x/placeholder-escape/expected.html +0 -5
  871. package/test/autotest-1.x/placeholder-escape/input.htmljs +0 -3
  872. package/test/autotest-1.x/placeholder-no-escape/expected.html +0 -5
  873. package/test/autotest-1.x/placeholder-no-escape/input.htmljs +0 -3
  874. package/test/autotest-1.x/placeholder-unnamed-attr/expected.html +0 -2
  875. package/test/autotest-1.x/placeholder-unnamed-attr/input.htmljs +0 -1
  876. package/test/autotest-1.x/placeholder-unnamed-attr-escaped/expected.html +0 -2
  877. package/test/autotest-1.x/placeholder-unnamed-attr-escaped/input.htmljs +0 -1
  878. package/test/autotest-1.x/placeholder-unnamed-attr-escaped-escaped/expected.html +0 -2
  879. package/test/autotest-1.x/placeholder-unnamed-attr-escaped-escaped/input.htmljs +0 -1
  880. package/test/autotest-1.x/placeholder-unnamed-attr-last/expected.html +0 -2
  881. package/test/autotest-1.x/placeholder-unnamed-attr-last/input.htmljs +0 -1
  882. package/test/autotest-1.x/placeholder-unnamed-attr-last-concise/expected.html +0 -4
  883. package/test/autotest-1.x/placeholder-unnamed-attr-last-concise/input.htmljs +0 -2
  884. package/test/autotest-1.x/placeholder-unnamed-attr-last-self-closed/expected.html +0 -2
  885. package/test/autotest-1.x/placeholder-unnamed-attr-last-self-closed/input.htmljs +0 -1
  886. package/test/autotest-1.x/placeholder-unnamed-attr-trailing-text/expected.html +0 -1
  887. package/test/autotest-1.x/placeholder-unnamed-attr-trailing-text/input.htmljs +0 -1
  888. package/test/autotest-1.x/placeholder-within-placeholder/expected.html +0 -1
  889. package/test/autotest-1.x/placeholder-within-placeholder/input.htmljs +0 -1
  890. package/test/autotest-1.x/placeholder-within-placeholder-escaping/expected.html +0 -1
  891. package/test/autotest-1.x/placeholder-within-placeholder-escaping/input.htmljs +0 -1
  892. package/test/autotest-1.x/placeholder-within-script-tag/expected.html +0 -5
  893. package/test/autotest-1.x/placeholder-within-script-tag/input.htmljs +0 -1
  894. package/test/autotest-1.x/placeholder-within-script-within-string/expected.html +0 -5
  895. package/test/autotest-1.x/placeholder-within-script-within-string/input.htmljs +0 -1
  896. package/test/autotest-1.x/placeholder-within-string-newlines/expected.html +0 -4
  897. package/test/autotest-1.x/placeholder-within-string-newlines/input.htmljs +0 -3
  898. package/test/autotest-1.x/root-el/expected.html +0 -2
  899. package/test/autotest-1.x/root-el/input.htmljs +0 -1
  900. package/test/autotest-1.x/root-els/expected.html +0 -4
  901. package/test/autotest-1.x/root-els/input.htmljs +0 -2
  902. package/test/autotest-1.x/script/expected.html +0 -3
  903. package/test/autotest-1.x/script/input.htmljs +0 -2
  904. package/test/autotest-1.x/script-concise/expected.html +0 -6
  905. package/test/autotest-1.x/script-concise/input.htmljs +0 -7
  906. package/test/autotest-1.x/script-concise-invalid-nested-tag/expected.html +0 -3
  907. package/test/autotest-1.x/script-concise-invalid-nested-tag/input.htmljs +0 -3
  908. package/test/autotest-1.x/script-empty-concise/expected.html +0 -6
  909. package/test/autotest-1.x/script-empty-concise/input.htmljs +0 -3
  910. package/test/autotest-1.x/script-self-closed/expected.html +0 -9
  911. package/test/autotest-1.x/script-self-closed/input.htmljs +0 -4
  912. package/test/autotest-1.x/script-single-line-comment/expected.html +0 -3
  913. package/test/autotest-1.x/script-single-line-comment/input.htmljs +0 -1
  914. package/test/autotest-1.x/scriptlet/expected.html +0 -11
  915. package/test/autotest-1.x/scriptlet/input.htmljs +0 -6
  916. package/test/autotest-1.x/scriptlet-html-block/expected.html +0 -7
  917. package/test/autotest-1.x/scriptlet-html-block/input.htmljs +0 -8
  918. package/test/autotest-1.x/self-closed-tag/expected.html +0 -2
  919. package/test/autotest-1.x/self-closed-tag/input.htmljs +0 -1
  920. package/test/autotest-1.x/self-closed-tag-attrs/expected.html +0 -2
  921. package/test/autotest-1.x/self-closed-tag-attrs/input.htmljs +0 -1
  922. package/test/autotest-1.x/self-closing-open-tag-only/expected.html +0 -3
  923. package/test/autotest-1.x/self-closing-open-tag-only/input.htmljs +0 -1
  924. package/test/autotest-1.x/shorthand-class-dynamic/expected.html +0 -2
  925. package/test/autotest-1.x/shorthand-class-dynamic/input.htmljs +0 -1
  926. package/test/autotest-1.x/shorthand-class-dynamic-literal-prefix/expected.html +0 -2
  927. package/test/autotest-1.x/shorthand-class-dynamic-literal-prefix/input.htmljs +0 -1
  928. package/test/autotest-1.x/shorthand-class-dynamic-literal-suffix/expected.html +0 -2
  929. package/test/autotest-1.x/shorthand-class-dynamic-literal-suffix/input.htmljs +0 -1
  930. package/test/autotest-1.x/shorthand-class-self-closed/expected.html +0 -6
  931. package/test/autotest-1.x/shorthand-class-self-closed/input.htmljs +0 -3
  932. package/test/autotest-1.x/shorthand-closing-html/expected.html +0 -9
  933. package/test/autotest-1.x/shorthand-closing-html/input.htmljs +0 -5
  934. package/test/autotest-1.x/shorthand-closing-html2/expected.html +0 -3
  935. package/test/autotest-1.x/shorthand-closing-html2/input.htmljs +0 -2
  936. package/test/autotest-1.x/shorthand-closing-html3/expected.html +0 -3
  937. package/test/autotest-1.x/shorthand-closing-html3/input.htmljs +0 -2
  938. package/test/autotest-1.x/shorthand-div-id/expected.html +0 -2
  939. package/test/autotest-1.x/shorthand-div-id/input.htmljs +0 -1
  940. package/test/autotest-1.x/shorthand-div-id-class/expected.html +0 -2
  941. package/test/autotest-1.x/shorthand-div-id-class/input.htmljs +0 -1
  942. package/test/autotest-1.x/shorthand-div-id-class-multiple/expected.html +0 -2
  943. package/test/autotest-1.x/shorthand-div-id-class-multiple/input.htmljs +0 -1
  944. package/test/autotest-1.x/shorthand-id/expected.html +0 -2
  945. package/test/autotest-1.x/shorthand-id/input.htmljs +0 -1
  946. package/test/autotest-1.x/shorthand-id-class/expected.html +0 -2
  947. package/test/autotest-1.x/shorthand-id-class/input.htmljs +0 -1
  948. package/test/autotest-1.x/shorthand-id-class-html/expected.html +0 -3
  949. package/test/autotest-1.x/shorthand-id-class-html/input.htmljs +0 -2
  950. package/test/autotest-1.x/shorthand-id-dup/expected.html +0 -1
  951. package/test/autotest-1.x/shorthand-id-dup/input.htmljs +0 -1
  952. package/test/autotest-1.x/shorthand-id-dynamic/expected.html +0 -2
  953. package/test/autotest-1.x/shorthand-id-dynamic/input.htmljs +0 -1
  954. package/test/autotest-1.x/shorthand-id-dynamic-literal-prefix/expected.html +0 -2
  955. package/test/autotest-1.x/shorthand-id-dynamic-literal-prefix/input.htmljs +0 -1
  956. package/test/autotest-1.x/shorthand-id-dynamic-literal-suffix/expected.html +0 -2
  957. package/test/autotest-1.x/shorthand-id-dynamic-literal-suffix/input.htmljs +0 -1
  958. package/test/autotest-1.x/shorthand-id-self-closed/expected.html +0 -6
  959. package/test/autotest-1.x/shorthand-id-self-closed/input.htmljs +0 -3
  960. package/test/autotest-1.x/shorthand-mixed/expected.html +0 -15
  961. package/test/autotest-1.x/shorthand-mixed/input.htmljs +0 -5
  962. package/test/autotest-1.x/shorthand-mixed-concise/expected.html +0 -11
  963. package/test/autotest-1.x/shorthand-mixed-concise/input.htmljs +0 -5
  964. package/test/autotest-1.x/simple-text-delimited/expected.html +0 -1
  965. package/test/autotest-1.x/simple-text-delimited/input.htmljs +0 -3
  966. package/test/autotest-1.x/single-hyphen-after-attr/expected.html +0 -3
  967. package/test/autotest-1.x/single-hyphen-after-attr/input.htmljs +0 -1
  968. package/test/autotest-1.x/single-line-text-block/expected.html +0 -2
  969. package/test/autotest-1.x/single-line-text-block/input.htmljs +0 -2
  970. package/test/autotest-1.x/single-line-text-block-nested/expected.html +0 -4
  971. package/test/autotest-1.x/single-line-text-block-nested/input.htmljs +0 -3
  972. package/test/autotest-1.x/single-line-text-block-sibling/expected.html +0 -6
  973. package/test/autotest-1.x/single-line-text-block-sibling/input.htmljs +0 -5
  974. package/test/autotest-1.x/stray-forward-slash-within-open-tag/expected.html +0 -3
  975. package/test/autotest-1.x/stray-forward-slash-within-open-tag/input.htmljs +0 -1
  976. package/test/autotest-1.x/stray-special-chars/expected.html +0 -3
  977. package/test/autotest-1.x/stray-special-chars/input.htmljs +0 -1
  978. package/test/autotest-1.x/strip-bom/expected.html +0 -3
  979. package/test/autotest-1.x/strip-bom/input-good.htmljs +0 -1
  980. package/test/autotest-1.x/strip-bom/input.htmljs +0 -1
  981. package/test/autotest-1.x/strip-bom/input.htmljs.txt +0 -60
  982. package/test/autotest-1.x/tag-name-expression-literal-prefix/expected.html +0 -3
  983. package/test/autotest-1.x/tag-name-expression-literal-prefix/input.htmljs +0 -2
  984. package/test/autotest-1.x/tag-name-expression-literal-prefix-attrs/expected.html +0 -3
  985. package/test/autotest-1.x/tag-name-expression-literal-prefix-attrs/input.htmljs +0 -2
  986. package/test/autotest-1.x/tag-name-expression-literal-prefix-suffix/expected.html +0 -3
  987. package/test/autotest-1.x/tag-name-expression-literal-prefix-suffix/input.htmljs +0 -2
  988. package/test/autotest-1.x/tag-name-expression-literal-suffix/expected.html +0 -3
  989. package/test/autotest-1.x/tag-name-expression-literal-suffix/input.htmljs +0 -2
  990. package/test/autotest-1.x/tag-name-expression-shorthand-id/expected.html +0 -2
  991. package/test/autotest-1.x/tag-name-expression-shorthand-id/input.htmljs +0 -1
  992. package/test/autotest-1.x/tag-name-expression-simple/expected.html +0 -3
  993. package/test/autotest-1.x/tag-name-expression-simple/input.htmljs +0 -2
  994. package/test/autotest-1.x/tag-name-expression-simple-empty-close/expected.html +0 -3
  995. package/test/autotest-1.x/tag-name-expression-simple-empty-close/input.htmljs +0 -2
  996. package/test/autotest-1.x/text-after-tag/expected.html +0 -3
  997. package/test/autotest-1.x/text-after-tag/input.htmljs +0 -1
  998. package/test/autotest-1.x/text-parse-mode-concise/expected.html +0 -5
  999. package/test/autotest-1.x/text-parse-mode-concise/input.htmljs +0 -3
  1000. package/test/autotest-1.x/text-parse-mode-concise/test.js +0 -1
  1001. package/test/autotest-1.x/text-parse-mode-delimited-block/expected.html +0 -8
  1002. package/test/autotest-1.x/text-parse-mode-delimited-block/input.htmljs +0 -6
  1003. package/test/autotest-1.x/text-parse-mode-delimited-block/test.js +0 -1
  1004. package/test/autotest-1.x/text-parse-mode-html/expected.html +0 -7
  1005. package/test/autotest-1.x/text-parse-mode-html/input.htmljs +0 -3
  1006. package/test/autotest-1.x/text-parse-mode-html/test.js +0 -1
  1007. package/test/autotest-1.x/text-parse-mode-parsed-text/expected.html +0 -11
  1008. package/test/autotest-1.x/text-parse-mode-parsed-text/input.htmljs +0 -7
  1009. package/test/autotest-1.x/text-parse-mode-parsed-text/test.js +0 -7
  1010. package/test/autotest-1.x/text-parse-mode-static-text/expected.html +0 -11
  1011. package/test/autotest-1.x/text-parse-mode-static-text/input.htmljs +0 -7
  1012. package/test/autotest-1.x/text-parse-mode-static-text/test.js +0 -7
  1013. package/test/autotest-1.x/var/expected.html +0 -9
  1014. package/test/autotest-1.x/var/input.htmljs +0 -5
  1015. package/test/autotest-1.x/whitespace-empty-lines/expected.html +0 -7
  1016. package/test/autotest-1.x/whitespace-empty-lines/input.htmljs +0 -4
  1017. package/test/autotest-1.x/whitespace-empty-lines-indent/expected.html +0 -8
  1018. package/test/autotest-1.x/whitespace-empty-lines-indent/input.htmljs +0 -4
  1019. package/test/autotest-1.x/whitespace-newline/expected.html +0 -7
  1020. package/test/autotest-1.x/whitespace-newline/input.htmljs +0 -6
  1021. package/test/autotest-1.x/whitespace-newline-indent/expected.html +0 -7
  1022. package/test/autotest-1.x/whitespace-newline-indent/input.htmljs +0 -6
  1023. package/test/autotest-1.x/windows-line-ending/expected.html +0 -10
  1024. package/test/autotest-1.x/windows-line-ending/test.js +0 -11
  1025. package/test/autotest-1.x/xml-declaration/expected.html +0 -5
  1026. package/test/autotest-1.x/xml-declaration/input.htmljs +0 -2
  1027. package/test/autotest-1.x/xml-declaration-ill-formed/expected.html +0 -5
  1028. package/test/autotest-1.x/xml-declaration-ill-formed/input.htmljs +0 -2
  1029. package/test/test.js +0 -6
  1030. package/test/util/TreeBuilder.js +0 -417
  1031. package/test/util/runDirTest.js +0 -76
package/Parser.js DELETED
@@ -1,3324 +0,0 @@
1
- 'use strict';
2
- var BaseParser = require('./BaseParser');
3
- var operators = require('./operators');
4
- var notifyUtil = require('./notify-util');
5
- var complain = require('complain');
6
- var charProps = require('char-props');
7
-
8
- function isWhitespaceCode(code) {
9
- // For all practical purposes, the space character (32) and all the
10
- // control characters below it are whitespace. We simplify this
11
- // condition for performance reasons.
12
- // NOTE: This might be slightly non-conforming.
13
- return (code <= 32);
14
- }
15
-
16
- var NUMBER_REGEX = /^[\-\+]?\d*(?:\.\d+)?(?:e[\-\+]?\d+)?$/;
17
-
18
- /**
19
- * Takes a string expression such as `"foo"` or `'foo "bar"'`
20
- * and returns the literal String value.
21
- */
22
- function evaluateStringExpression(expression, pos, notifyError) {
23
- // We could just use eval(expression) to get the literal String value,
24
- // but there is a small chance we could be introducing a security threat
25
- // by accidently running malicous code. Instead, we will use
26
- // JSON.parse(expression). JSON.parse() only allows strings
27
- // that use double quotes so we have to do extra processing if
28
- // we detect that the String uses single quotes
29
-
30
- if (expression.charAt(0) === "'") {
31
- expression = expression.substring(1, expression.length - 1);
32
-
33
- // Make sure there are no unescaped double quotes in the string expression...
34
- expression = expression.replace(/\\\\|\\[']|\\["]|["]/g, function(match) {
35
- if (match === "\\'"){
36
- // Don't escape single quotes since we are using double quotes
37
- return "'";
38
- } else if (match === '"'){
39
- // Return an escaped double quote if we encounter an
40
- // unescaped double quote
41
- return '\\"';
42
- } else {
43
- // Return the escape sequence
44
- return match;
45
- }
46
- });
47
-
48
- expression = '"' + expression + '"';
49
- }
50
-
51
- try {
52
- return JSON.parse(expression);
53
- } catch(e) {
54
- notifyError(pos,
55
- 'INVALID_STRING',
56
- 'Invalid string (' + expression + '): ' + e);
57
- }
58
- }
59
-
60
-
61
- function peek(array) {
62
- var len = array.length;
63
- if (!len) {
64
- return undefined;
65
- }
66
- return array[len - 1];
67
- }
68
-
69
- const MODE_HTML = 1;
70
- const MODE_CONCISE = 2;
71
-
72
- const CODE_BACK_SLASH = 92;
73
- const CODE_FORWARD_SLASH = 47;
74
- const CODE_OPEN_ANGLE_BRACKET = 60;
75
- const CODE_CLOSE_ANGLE_BRACKET = 62;
76
- const CODE_EXCLAMATION = 33;
77
- const CODE_QUESTION = 63;
78
- const CODE_OPEN_SQUARE_BRACKET = 91;
79
- const CODE_CLOSE_SQUARE_BRACKET = 93;
80
- const CODE_EQUAL = 61;
81
- const CODE_SINGLE_QUOTE = 39;
82
- const CODE_DOUBLE_QUOTE = 34;
83
- const CODE_BACKTICK = 96;
84
- const CODE_OPEN_PAREN = 40;
85
- const CODE_CLOSE_PAREN = 41;
86
- const CODE_OPEN_CURLY_BRACE = 123;
87
- const CODE_CLOSE_CURLY_BRACE = 125;
88
- const CODE_ASTERISK = 42;
89
- const CODE_HYPHEN = 45;
90
- const CODE_HTML_BLOCK_DELIMITER = CODE_HYPHEN;
91
- const CODE_DOLLAR = 36;
92
- const CODE_PERCENT = 37;
93
- const CODE_PERIOD = 46;
94
- const CODE_COMMA = 44;
95
- const CODE_COLON = 58;
96
- const CODE_SEMICOLON = 59;
97
- const CODE_NUMBER_SIGN = 35;
98
- const CODE_PIPE = 124;
99
-
100
- const BODY_PARSED_TEXT = 1; // Body of a tag is treated as text, but placeholders will be parsed
101
- const BODY_STATIC_TEXT = 2;// Body of a tag is treated as text and placeholders will *not* be parsed
102
-
103
- const EMPTY_ATTRIBUTES = [];
104
- const htmlTags = require('./html-tags');
105
-
106
- class Parser extends BaseParser {
107
- constructor(listeners, options) {
108
- super(options);
109
-
110
- var parser = this;
111
-
112
- function outputDeprecationWarning(message) {
113
- var srcCharProps = charProps(parser.src);
114
- var line = srcCharProps.lineAt(parser.pos);
115
- var column = srcCharProps.columnAt(parser.pos);
116
- var filename = parser.filename;
117
- var location = (filename || '(unknown file)') + ':' + line + ':' + column;
118
- complain(message, { location: location });
119
- }
120
-
121
- var notifiers = notifyUtil.createNotifiers(parser, listeners);
122
- this.notifiers = notifiers;
123
-
124
- var defaultMode = options && options.concise === false ? MODE_HTML : MODE_CONCISE;
125
- var userIsOpenTagOnly = options && options.isOpenTagOnly;
126
- var ignorePlaceholders = options && options.ignorePlaceholders;
127
- var ignoreNonstandardStringPlaceholders = options && options.ignoreNonstandardStringPlaceholders;
128
- var legacyCompatibility = options.legacyCompatibility === true;
129
-
130
- var currentOpenTag; // Used to reference the current open tag that is being parsed
131
- var currentAttribute; // Used to reference the current attribute that is being parsed
132
- var closeTagName; // Used to keep track of the current close tag name as it is being parsed
133
- var closeTagPos; // Used to keep track of the position of the current closing tag
134
- var expectedCloseTagName; // Used to figure out when a text block has been ended (HTML tags are ignored)
135
- var text; // Used to buffer text that is found within the body of a tag
136
- var withinOpenTag;// Set to true if the parser is within the open tag
137
- var blockStack; // Used to keep track of HTML tags and HTML blocks
138
- var partStack; // Used to keep track of parts such as CDATA, expressions, declarations, etc.
139
- var currentPart; // The current part at the top of the part stack
140
- var indent; // Used to build the indent for the current concise line
141
- var isConcise; // Set to true if parser is currently in concise mode
142
- var isWithinSingleLineHtmlBlock; // Set to true if the current block is for a single line HTML block
143
- var htmlBlockDelimiter; // Current delimiter for multiline HTML blocks nested within a concise tag. e.g. "--"
144
- var htmlBlockIndent; // Used to hold the indentation for a delimited, multiline HTML block
145
- var beginMixedMode; // Used as a flag to mark that the next HTML block should enter the parser into HTML mode
146
- var endingMixedModeAtEOL; // Used as a flag to record that the next EOL to exit HTML mode and go back to concise
147
- var placeholderDepth; // Used as an easy way to know if an exptression is within a placeholder
148
- var textParseMode = 'html';
149
-
150
- this.reset = function() {
151
- BaseParser.prototype.reset.call(this);
152
- text = '';
153
- currentOpenTag = undefined;
154
- currentAttribute = undefined;
155
- closeTagName = undefined;
156
- closeTagPos = undefined;
157
- expectedCloseTagName = undefined;
158
- withinOpenTag = false;
159
- blockStack = [];
160
- partStack = [];
161
- currentPart = undefined;
162
- indent = '';
163
- isConcise = defaultMode === MODE_CONCISE;
164
- isWithinSingleLineHtmlBlock = false;
165
- htmlBlockDelimiter = null;
166
- htmlBlockIndent = null;
167
- beginMixedMode = false;
168
- endingMixedModeAtEOL = false;
169
- placeholderDepth = 0;
170
- };
171
-
172
- this.reset();
173
-
174
- /**
175
- * This function is called to determine if a tag is an "open only tag". Open only tags such as <img>
176
- * are immediately closed.
177
- * @param {String} tagName The name of the tag (e.g. "img")
178
- */
179
- function isOpenTagOnly(tagName) {
180
- if (!tagName) {
181
- return false;
182
- }
183
-
184
- tagName = tagName.toLowerCase();
185
-
186
- var openTagOnly = userIsOpenTagOnly && userIsOpenTagOnly(tagName);
187
- if (openTagOnly == null) {
188
- openTagOnly = htmlTags.isOpenTagOnly(tagName);
189
- }
190
-
191
- return openTagOnly;
192
- }
193
-
194
- /**
195
- * Clear out any buffered body text and notify any listeners
196
- */
197
- function endText(txt) {
198
- if (arguments.length === 0) {
199
- txt = text;
200
- }
201
-
202
- notifiers.notifyText(txt, textParseMode);
203
-
204
- // always clear text buffer...
205
- text = '';
206
- }
207
-
208
-
209
- function openTagEOL() {
210
- if (isConcise && !currentOpenTag.withinAttrGroup) {
211
- // In concise mode we always end the open tag
212
- finishOpenTag();
213
- }
214
- }
215
-
216
- /**
217
- * This function is used to enter into "HTML" parsing mode instead
218
- * of concise HTML. We push a block on to the stack so that we know when
219
- * return back to the previous parsing mode and to ensure that all
220
- * tags within a block are properly closed.
221
- */
222
- function beginHtmlBlock(delimiter) {
223
- htmlBlockIndent = indent;
224
- htmlBlockDelimiter = delimiter;
225
-
226
- var parent = peek(blockStack);
227
- blockStack.push({
228
- type: 'html',
229
- delimiter: delimiter,
230
- indent: indent
231
- });
232
-
233
- if (parent && parent.body) {
234
- if (parent.body === BODY_PARSED_TEXT) {
235
- parser.enterState(STATE_PARSED_TEXT_CONTENT);
236
- } else if (parent.body === BODY_STATIC_TEXT) {
237
- parser.enterState(STATE_STATIC_TEXT_CONTENT);
238
- } else {
239
- throw new Error('Illegal value for parent.body: ' + parent.body);
240
- }
241
- } else {
242
- return parser.enterState(STATE_HTML_CONTENT);
243
- }
244
- }
245
-
246
- /**
247
- * This method gets called when we are in non-concise mode
248
- * and we are exiting out of non-concise mode.
249
- */
250
- function endHtmlBlock() {
251
- if (text && (isWithinSingleLineHtmlBlock || htmlBlockDelimiter)) {
252
- // Remove the new line that was required to end a single line
253
- // HTML block or a delimited block
254
- text = text.replace(/(\r\n|\n)$/, '');
255
- }
256
-
257
- // End any text
258
- endText();
259
-
260
- // Make sure all tags in this HTML block are closed
261
- for (let i=blockStack.length-1; i>=0; i--) {
262
- var curBlock = blockStack[i];
263
- if (curBlock.type === 'html') {
264
- // Remove the HTML block from the stack since it has ended
265
- blockStack.pop();
266
- // We have reached the point where the HTML block started
267
- // so we can stop
268
- break;
269
- } else {
270
- // The current block is for an HTML tag and it still open. When a tag is tag is closed
271
- // it is removed from the stack
272
- notifyError(curBlock.pos,
273
- 'MISSING_END_TAG',
274
- 'Missing ending "' + curBlock.tagName + '" tag');
275
- return;
276
- }
277
- }
278
-
279
- // Resert variables associated with parsing an HTML block
280
- htmlBlockIndent = null;
281
- htmlBlockDelimiter = null;
282
- isWithinSingleLineHtmlBlock = false;
283
-
284
- if (parser.state !== STATE_CONCISE_HTML_CONTENT) {
285
- parser.enterState(STATE_CONCISE_HTML_CONTENT);
286
- }
287
- }
288
-
289
- /**
290
- * This function gets called when we reach EOF outside of a tag.
291
- */
292
- function htmlEOF() {
293
- endText();
294
-
295
- while(blockStack.length) {
296
- var curBlock = peek(blockStack);
297
- if (curBlock.type === 'tag') {
298
- if (curBlock.concise) {
299
- closeTag(curBlock.expectedCloseTagName);
300
- } else {
301
- // We found an unclosed tag on the stack that is not for a concise tag. That means
302
- // there is a problem with the template because all open tags should have a closing
303
- // tag
304
- //
305
- // NOTE: We have already closed tags that are open tag only or self-closed
306
- notifyError(curBlock.pos,
307
- 'MISSING_END_TAG',
308
- 'Missing ending "' + curBlock.tagName + '" tag');
309
- return;
310
- }
311
- } else if (curBlock.type === 'html') {
312
- // We reached the end of file while still within a single line HTML block. That's okay
313
- // though since we know the line is completely. We'll continue ending all open concise tags.
314
- blockStack.pop();
315
- } else {
316
- // There is a bug in our parser...
317
- throw new Error('Illegal state. There should not be any non-concise tags on the stack when in concise mode');
318
- }
319
- }
320
- }
321
-
322
- function openTagEOF() {
323
- if (isConcise) {
324
- if (currentOpenTag.withinAttrGroup) {
325
- notifyError(currentOpenTag.pos,
326
- 'MALFORMED_OPEN_TAG',
327
- 'EOF reached while within an attribute group (e.g. "[ ... ]").');
328
- return;
329
- }
330
-
331
- // If we reach EOF inside an open tag when in concise-mode
332
- // then we just end the tag and all other open tags on the stack
333
- finishOpenTag();
334
- htmlEOF();
335
- } else {
336
- // Otherwise, in non-concise mode we consider this malformed input
337
- // since the end '>' was not found.
338
- notifyError(currentOpenTag.pos,
339
- 'MALFORMED_OPEN_TAG',
340
- 'EOF reached while parsing open tag');
341
- }
342
- }
343
-
344
- var notifyCDATA = notifiers.notifyCDATA;
345
- var notifyComment = notifiers.notifyComment;
346
- var notifyOpenTag = notifiers.notifyOpenTag;
347
- var notifyOpenTagName = notifiers.notifyOpenTagName;
348
- var notifyCloseTag = notifiers.notifyCloseTag;
349
- var notifyDocumentType = notifiers.notifyDocumentType;
350
- var notifyDeclaration = notifiers.notifyDeclaration;
351
- var notifyPlaceholder = notifiers.notifyPlaceholder;
352
- var notifyScriptlet = notifiers.notifyScriptlet;
353
-
354
- function notifyError(pos, errorCode, message) {
355
- parser.end();
356
- notifiers.notifyError(pos, errorCode, message);
357
- }
358
-
359
- function beginAttribute() {
360
- currentAttribute = {};
361
- if (currentOpenTag.attributes === EMPTY_ATTRIBUTES) {
362
- currentOpenTag.attributes = [currentAttribute];
363
- } else {
364
- currentOpenTag.attributes.push(currentAttribute);
365
- }
366
- parser.enterState(STATE_ATTRIBUTE_NAME);
367
- return currentAttribute;
368
- }
369
-
370
- function endAttribute() {
371
- currentAttribute = null;
372
- if (parser.state !== STATE_WITHIN_OPEN_TAG) {
373
- parser.enterState(STATE_WITHIN_OPEN_TAG);
374
- }
375
- }
376
-
377
- function beginOpenTag() {
378
- endText();
379
-
380
- var tagInfo = {
381
- type: 'tag',
382
- tagName: '',
383
- tagNameParts: null,
384
- attributes: [],
385
- argument: undefined,
386
- params: undefined,
387
- pos: parser.pos,
388
- indent: indent,
389
- nestedIndent: null, // This will get set when we know what hte nested indent is
390
- concise: isConcise
391
- };
392
-
393
- withinOpenTag = true;
394
-
395
- if (beginMixedMode) {
396
- tagInfo.beginMixedMode = true;
397
- beginMixedMode = false;
398
- }
399
-
400
- blockStack.push(tagInfo);
401
-
402
- currentOpenTag = tagInfo;
403
-
404
- parser.enterState(STATE_TAG_NAME);
405
-
406
- return currentOpenTag;
407
- }
408
-
409
- function finishOpenTag(selfClosed) {
410
- var tagName = currentOpenTag.tagName;
411
- var attributes = currentOpenTag.attributes;
412
- var parseOptions = currentOpenTag.parseOptions;
413
-
414
- var ignoreAttributes = parseOptions && parseOptions.ignoreAttributes === true;
415
-
416
- if (ignoreAttributes) {
417
- attributes.length = 0;
418
- } else {
419
- if (currentOpenTag.requiresCommas && attributes.length > 1) {
420
- for(let i = 0; i < attributes.length-1; i++) {
421
- if(!attributes[i].endedWithComma) {
422
-
423
-
424
- if (!parseOptions || parseOptions.relaxRequireCommas !== true) {
425
- notifyError(attributes[i].pos,
426
- 'COMMAS_REQUIRED',
427
- 'if commas are used, they must be used to separate all attributes for a tag');
428
- }
429
- }
430
- }
431
- }
432
- }
433
-
434
-
435
- currentOpenTag.expectedCloseTagName = expectedCloseTagName =
436
- parser.substring(currentOpenTag.tagNameStart, currentOpenTag.tagNameEnd);
437
-
438
- var openTagOnly = currentOpenTag.openTagOnly = isOpenTagOnly(tagName);
439
- var endPos = parser.pos;
440
-
441
- if (!isConcise) {
442
- if (selfClosed) {
443
- endPos += 2; // Skip past '/>'
444
- } else {
445
- endPos += 1;
446
- }
447
- }
448
-
449
- if (currentOpenTag.tagNameParts) {
450
- currentOpenTag.tagNameExpression = currentOpenTag.tagNameParts.join('+');
451
- }
452
-
453
- currentOpenTag.endPos = endPos;
454
- currentOpenTag.selfClosed = selfClosed === true;
455
-
456
- if (!currentOpenTag.tagName && !currentOpenTag.emptyTagName) {
457
- tagName = currentOpenTag.tagName = 'div';
458
- }
459
-
460
- var origState = parser.state;
461
- notifyOpenTag(currentOpenTag);
462
-
463
- var shouldClose = false;
464
-
465
- if (selfClosed) {
466
- shouldClose = true;
467
- } else if (openTagOnly) {
468
- if (!isConcise) {
469
- // Only close the tag if we are not in concise mode. In concise mode
470
- // we want to keep the tag on the stack to make sure nothing is nested below it
471
- shouldClose = true;
472
- }
473
- }
474
-
475
- if (shouldClose) {
476
- closeTag(expectedCloseTagName);
477
- }
478
-
479
- withinOpenTag = false;
480
-
481
- if (shouldClose) {
482
- if (isConcise) {
483
- parser.enterConciseHtmlContentState();
484
- } else {
485
- parser.enterHtmlContentState();
486
- }
487
- } else {
488
- // Did the parser stay in the same state after
489
- // notifying listeners about openTag?
490
- if (parser.state === origState) {
491
- // The listener didn't transition the parser to a new state
492
- // so we use some simple rules to find the appropriate state.
493
- if (tagName === 'script') {
494
- parser.enterJsContentState();
495
- } else if (tagName === 'style') {
496
- parser.enterCssContentState();
497
- } else {
498
- if (isConcise) {
499
- parser.enterConciseHtmlContentState();
500
- } else {
501
- parser.enterHtmlContentState();
502
- }
503
-
504
- }
505
- }
506
- }
507
-
508
- // We need to record the "expected close tag name" if we transition into
509
- // either STATE_STATIC_TEXT_CONTENT or STATE_PARSED_TEXT_CONTENT
510
- currentOpenTag = undefined;
511
- }
512
-
513
- function closeTag(tagName, pos, endPos) {
514
- if (!tagName) {
515
- throw new Error('Illegal state. Invalid tag name');
516
- }
517
- var lastTag = blockStack.length ? blockStack.pop() : undefined;
518
-
519
- if (pos == null && closeTagPos != null) {
520
- pos = closeTagPos;
521
- endPos = parser.pos + 1;
522
- }
523
-
524
- if (!lastTag || lastTag.type !== 'tag') {
525
- return notifyError(pos,
526
- 'EXTRA_CLOSING_TAG',
527
- 'The closing "' + tagName + '" tag was not expected');
528
- }
529
-
530
- if (!lastTag || (lastTag.expectedCloseTagName !== tagName && lastTag.tagName !== tagName)) {
531
- return notifyError(pos,
532
- 'MISMATCHED_CLOSING_TAG',
533
- 'The closing "' + tagName + '" tag does not match the corresponding opening "' + lastTag.expectedCloseTagName + '" tag');
534
- }
535
-
536
- tagName = lastTag.tagName;
537
-
538
- notifyCloseTag(tagName, pos, endPos);
539
-
540
- if (lastTag.beginMixedMode) {
541
- endingMixedModeAtEOL = true;
542
- }
543
-
544
- closeTagName = null;
545
- closeTagPos = null;
546
-
547
- lastTag = peek(blockStack);
548
- expectedCloseTagName = lastTag && lastTag.expectedCloseTagName;
549
- }
550
-
551
- function beginPart() {
552
- currentPart = {
553
- pos: parser.pos,
554
- parentState: parser.state
555
- };
556
-
557
- partStack.push(currentPart);
558
-
559
- return currentPart;
560
- }
561
-
562
- function endPart() {
563
- var last = partStack.pop();
564
- parser.endPos = parser.pos;
565
- parser.enterState(last.parentState);
566
- currentPart = partStack.length ? peek(partStack) : undefined;
567
- return last;
568
- }
569
-
570
- // Expression
571
-
572
- function beginExpression(endAfterGroup) {
573
- var expression = beginPart();
574
- expression.value = '';
575
- expression.groupStack = [];
576
- expression.endAfterGroup = endAfterGroup === true;
577
- expression.isStringLiteral = null;
578
- parser.enterState(STATE_EXPRESSION);
579
- return expression;
580
- }
581
-
582
- function endExpression() {
583
- var expression = endPart();
584
- // Probably shouldn't do this, but it makes it easier to test!
585
- if(expression.parentState === STATE_ATTRIBUTE_VALUE && expression.hasUnenclosedWhitespace) {
586
- expression.value = '('+expression.value+')';
587
- }
588
- expression.parentState.expression(expression);
589
- }
590
-
591
- // --------------------------
592
-
593
- // String
594
-
595
- function beginString(quoteChar, quoteCharCode) {
596
- var string = beginPart();
597
- string.stringParts = [];
598
- string.currentText = '';
599
- string.quoteChar = quoteChar;
600
- string.quoteCharCode = quoteCharCode;
601
- string.isStringLiteral = true;
602
- parser.enterState(STATE_STRING);
603
- return string;
604
- }
605
-
606
- function endString() {
607
- var string = endPart();
608
- string.value = notifiers.notifyString(string);
609
- string.parentState.string(string);
610
- }
611
-
612
- // --------------------------
613
-
614
- // Template String
615
-
616
- function beginTemplateString() {
617
- var templateString = beginPart();
618
- templateString.value = '`';
619
- parser.enterState(STATE_TEMPLATE_STRING);
620
- return templateString;
621
- }
622
-
623
- function endTemplateString() {
624
- var templateString = endPart();
625
- templateString.parentState.templateString(templateString);
626
- }
627
-
628
- // --------------------------
629
-
630
- // Regular Expression
631
-
632
- function beginRegularExpression() {
633
- var regularExpression = beginPart();
634
- regularExpression.value = '/';
635
- parser.enterState(STATE_REGULAR_EXPRESSION);
636
- return regularExpression;
637
- }
638
-
639
- function endRegularExpression() {
640
- var regularExpression = endPart();
641
- regularExpression.parentState.regularExpression(regularExpression);
642
- }
643
-
644
- // --------------------------
645
-
646
-
647
- // Scriptlet
648
-
649
- function beginScriptlet() {
650
- endText();
651
-
652
- var scriptlet = beginPart();
653
- scriptlet.tag = true;
654
- scriptlet.value = '';
655
- scriptlet.quoteCharCode = null;
656
- parser.enterState(STATE_SCRIPTLET);
657
- return scriptlet;
658
- }
659
-
660
- function endScriptlet(endPos) {
661
- var scriptlet = endPart();
662
- scriptlet.endPos = endPos;
663
- notifyScriptlet(scriptlet);
664
- }
665
-
666
- // InlineScript
667
-
668
- function beginInlineScript() {
669
- endText();
670
-
671
- var inlineScript = beginPart();
672
- inlineScript.value = '';
673
- inlineScript.endMatches = [];
674
- parser.enterState(STATE_INLINE_SCRIPT);
675
- return inlineScript;
676
- }
677
-
678
- function endInlineScript(endPos) {
679
- var inlineScript = endPart();
680
- var value = inlineScript.value;
681
- inlineScript.endPos = endPos;
682
-
683
- if (value[0] === '{' && value[value.length-1] === '}') {
684
- inlineScript.value = value.slice(1, -1);
685
- inlineScript.block = true;
686
- } else {
687
- inlineScript.line = true;
688
- }
689
-
690
- notifyScriptlet(inlineScript);
691
- }
692
-
693
- // --------------------------
694
-
695
-
696
- // DTD
697
-
698
- function beginDocumentType() {
699
- endText();
700
-
701
- var documentType = beginPart();
702
- documentType.value = '';
703
-
704
- parser.enterState(STATE_DTD);
705
- return documentType;
706
- }
707
-
708
- function endDocumentType() {
709
- var documentType = endPart();
710
- notifyDocumentType(documentType);
711
- }
712
-
713
- // --------------------------
714
-
715
- // Declaration
716
- function beginDeclaration() {
717
- endText();
718
-
719
- var declaration = beginPart();
720
- declaration.value = '';
721
- parser.enterState(STATE_DECLARATION);
722
- return declaration;
723
- }
724
-
725
- function endDeclaration() {
726
- var declaration = endPart();
727
- notifyDeclaration(declaration);
728
- }
729
-
730
- // --------------------------
731
-
732
- // CDATA
733
-
734
- function beginCDATA() {
735
- endText();
736
-
737
- var cdata = beginPart();
738
- cdata.value = '';
739
- parser.enterState(STATE_CDATA);
740
- return cdata;
741
- }
742
-
743
- function endCDATA() {
744
- var cdata = endPart();
745
- notifyCDATA(cdata.value, cdata.pos, parser.pos + 3);
746
- }
747
-
748
- // --------------------------
749
-
750
- // JavaScript Comments
751
- function beginLineComment() {
752
- var comment = beginPart();
753
- comment.value = '';
754
- comment.type = 'line';
755
- parser.enterState(STATE_JS_COMMENT_LINE);
756
- return comment;
757
- }
758
-
759
- function beginBlockComment() {
760
- var comment = beginPart();
761
- comment.value = '';
762
- comment.type = 'block';
763
- parser.enterState(STATE_JS_COMMENT_BLOCK);
764
- return comment;
765
- }
766
-
767
- function endJavaScriptComment() {
768
- var comment = endPart();
769
- comment.rawValue = comment.type === 'line' ?
770
- '//' + comment.value :
771
- '/*' + comment.value + '*/';
772
- comment.parentState.comment(comment);
773
- }
774
- // --------------------------
775
-
776
- // HTML Comment
777
-
778
- function beginHtmlComment() {
779
- endText();
780
- var comment = beginPart();
781
- comment.value = '';
782
- parser.enterState(STATE_HTML_COMMENT);
783
- return comment;
784
- }
785
-
786
- function endHtmlComment() {
787
- var comment = endPart();
788
- comment.endPos = parser.pos + 3;
789
- notifyComment(comment);
790
- }
791
-
792
- // --------------------------
793
-
794
- // Trailing whitespace
795
-
796
- function beginCheckTrailingWhitespace(handler) {
797
- var part = beginPart();
798
- part.handler = handler;
799
- if (typeof handler !== 'function') {
800
- throw new Error('Invalid handler');
801
- }
802
- parser.enterState(STATE_CHECK_TRAILING_WHITESPACE);
803
- }
804
-
805
- function endCheckTrailingWhitespace(err, eof) {
806
- var part = endPart();
807
- part.handler(err, eof);
808
- }
809
-
810
- function handleTrailingWhitespaceJavaScriptComment(err) {
811
- if (err) {
812
- // This is a non-whitespace! We don't allow non-whitespace
813
- // after matching two or more hyphens. This is user error...
814
- notifyError(parser.pos,
815
- 'INVALID_CHARACTER',
816
- 'A non-whitespace of "' + err.ch + '" was found after a JavaScript block comment.');
817
- }
818
-
819
- return;
820
- }
821
-
822
- function handleTrailingWhitespaceMultilineHtmlBlock(err, eof) {
823
- if (err) {
824
- // This is a non-whitespace! We don't allow non-whitespace
825
- // after matching two or more hyphens. This is user error...
826
- notifyError(parser.pos,
827
- 'INVALID_CHARACTER',
828
- 'A non-whitespace of "' + err.ch + '" was found on the same line as the ending delimiter ("' + htmlBlockDelimiter + '") for a multiline HTML block');
829
- return;
830
- }
831
-
832
- endHtmlBlock();
833
-
834
- if (eof) {
835
- htmlEOF();
836
- }
837
-
838
- return;
839
- }
840
-
841
- // --------------------------
842
-
843
- // Placeholder
844
-
845
- function beginPlaceholder(escape, withinTagName) {
846
- var placeholder = beginPart();
847
- placeholder.value = '';
848
- placeholder.escape = escape !== false;
849
- placeholder.type = 'placeholder';
850
- placeholder.withinBody = withinOpenTag !== true;
851
- placeholder.withinAttribute = currentAttribute != null;
852
- placeholder.withinString = placeholder.parentState === STATE_STRING;
853
- placeholder.withinTemplateString = placeholder.parentState === STATE_TEMPLATE_STRING;
854
- placeholder.withinOpenTag = withinOpenTag === true && currentAttribute == null;
855
- placeholder.withinTagName = withinTagName;
856
- placeholderDepth++;
857
- parser.enterState(STATE_PLACEHOLDER);
858
- return placeholder;
859
- }
860
-
861
- function endPlaceholder() {
862
- var placeholder = endPart();
863
- placeholderDepth--;
864
- if (!placeholder.withinTemplateString) {
865
- var newExpression = notifyPlaceholder(placeholder);
866
- placeholder.value = newExpression;
867
- }
868
- placeholder.parentState.placeholder(placeholder);
869
- }
870
-
871
- // --------------------------
872
-
873
- // Placeholder
874
-
875
- function beginTagNameShorthand(escape, withinTagName) {
876
- var shorthand = beginPart();
877
- shorthand.currentPart = null;
878
- shorthand.hasId = false;
879
- shorthand.beginPart = function(type) {
880
- shorthand.currentPart = {
881
- type: type,
882
- stringParts: [],
883
- rawParts: [],
884
- text: '',
885
- _endText() {
886
- var text = this.text;
887
-
888
- if (text) {
889
- this.stringParts.push(JSON.stringify(text));
890
- this.rawParts.push({
891
- text: text,
892
- pos: parser.pos - text.length,
893
- endPos: parser.pos
894
- });
895
- }
896
-
897
- this.text = '';
898
- },
899
- addPlaceholder(placeholder) {
900
- var startPos = placeholder.pos + (placeholder.escape ? 2 : 3);
901
- var endPos = placeholder.endPos - 1;
902
- this._endText();
903
- this.stringParts.push('(' + placeholder.value + ')');
904
- this.rawParts.push({
905
- expression: parser.src.slice(startPos, endPos),
906
- pos: startPos,
907
- endPos: endPos
908
- });
909
- },
910
- end() {
911
- this._endText();
912
-
913
- var expression = this.stringParts.join('+');
914
-
915
- if (type === 'id') {
916
- currentOpenTag.shorthandId = {
917
- value: expression,
918
- rawParts: this.rawParts
919
- };
920
- } else if (type === 'class') {
921
- if (!currentOpenTag.shorthandClassNames) {
922
- currentOpenTag.shorthandClassNames = [];
923
- }
924
-
925
- currentOpenTag.shorthandClassNames.push({
926
- value: expression,
927
- rawParts: this.rawParts
928
- });
929
- }
930
- }
931
- };
932
- };
933
- parser.enterState(STATE_TAG_NAME_SHORTHAND);
934
- return shorthand;
935
- }
936
-
937
- function endTagNameShorthand() {
938
- var shorthand = endPart();
939
- if (shorthand.currentPart) {
940
- shorthand.currentPart.end();
941
- }
942
- parser.enterState(STATE_WITHIN_OPEN_TAG);
943
- }
944
-
945
- // --------------------------
946
-
947
- function getAndRemoveArgument(expression) {
948
- let start = expression.lastLeftParenPos;
949
- if (start != null) {
950
- // The tag has an argument that we need to slice off
951
- let end = expression.lastRightParenPos;
952
- if (end === expression.value.length - 1) {
953
- var argument = {
954
- value: expression.value.substring(start+1, end),
955
- pos: expression.pos + start,
956
- endPos: expression.pos + end + 1
957
- };
958
-
959
- // Chop off the argument from the expression
960
- expression.value = expression.value.substring(0, start);
961
- // Fix the end position for the expression
962
- expression.endPos = expression.pos + expression.value.length;
963
-
964
- return argument;
965
- }
966
- }
967
-
968
- return undefined;
969
- }
970
-
971
- function getAndRemoveMethod(expression) {
972
- if (expression.method) {
973
- let start = expression.lastLeftParenPos;
974
- let end = expression.value.length;
975
- var method = {
976
- value: 'function' + expression.value.substring(start, end),
977
- pos: expression.pos + start,
978
- endPos: expression.pos + end
979
- };
980
-
981
- // Chop off the method from the expression
982
- expression.value = expression.value.substring(0, start);
983
- // Fix the end position for the expression
984
- expression.endPos = expression.pos + expression.value.length;
985
-
986
- return method;
987
- }
988
-
989
- return undefined;
990
- }
991
-
992
- // --------------------------
993
-
994
- function checkForPlaceholder(ch, code) {
995
- if (code === CODE_DOLLAR) {
996
- var nextCode = parser.lookAtCharCodeAhead(1);
997
- if (nextCode === CODE_OPEN_CURLY_BRACE) {
998
- // We expect to start a placeholder at the first curly brace (the next character)
999
- beginPlaceholder(true);
1000
- return true;
1001
- } else if (nextCode === CODE_EXCLAMATION) {
1002
- var afterExclamationCode = parser.lookAtCharCodeAhead(2);
1003
- if (afterExclamationCode === CODE_OPEN_CURLY_BRACE) {
1004
- // We expect to start a placeholder at the first curly brace so skip
1005
- // past the exclamation point
1006
- beginPlaceholder(false);
1007
- parser.skip(1);
1008
- return true;
1009
- }
1010
- }
1011
- }
1012
-
1013
- return false;
1014
- }
1015
-
1016
- function checkForEscapedPlaceholder(ch, code) {
1017
- // Look for \${ and \$!{
1018
- if (code === CODE_BACK_SLASH) {
1019
- if (parser.lookAtCharCodeAhead(1) === CODE_DOLLAR) {
1020
- if (parser.lookAtCharCodeAhead(2) === CODE_OPEN_CURLY_BRACE) {
1021
- return true;
1022
- } else if (parser.lookAtCharCodeAhead(2) === CODE_EXCLAMATION) {
1023
- if (parser.lookAtCharCodeAhead(3) === CODE_OPEN_CURLY_BRACE) {
1024
- return true;
1025
- }
1026
- }
1027
- }
1028
- }
1029
-
1030
- return false;
1031
- }
1032
-
1033
- function checkForEscapedEscapedPlaceholder(ch, code) {
1034
- // Look for \\${ and \\$!{
1035
- if (code === CODE_BACK_SLASH) {
1036
- if (parser.lookAtCharCodeAhead(1) === CODE_BACK_SLASH) {
1037
- if (parser.lookAtCharCodeAhead(2) === CODE_DOLLAR) {
1038
- if (parser.lookAtCharCodeAhead(3) === CODE_OPEN_CURLY_BRACE) {
1039
- return true;
1040
- } else if (parser.lookAtCharCodeAhead(3) === CODE_EXCLAMATION) {
1041
- if (parser.lookAtCharCodeAhead(4) === CODE_OPEN_CURLY_BRACE) {
1042
- return true;
1043
- }
1044
- }
1045
- }
1046
- }
1047
- }
1048
-
1049
- return false;
1050
- }
1051
-
1052
- function lookPastWhitespaceFor(str, start) {
1053
- var ahead = start == null ? 1 : start;
1054
- while(isWhitespaceCode(parser.lookAtCharCodeAhead(ahead))) ahead++;
1055
- return !!parser.lookAheadFor(str, parser.pos+ahead);
1056
- }
1057
-
1058
- function getPreviousNonWhitespaceChar(start) {
1059
- var behind = start == null ? -1 : start;
1060
- while(isWhitespaceCode(parser.lookAtCharCodeAhead(behind))) behind--;
1061
- return parser.lookAtCharAhead(behind);
1062
- }
1063
-
1064
- function getNextIndent() {
1065
- var match = /[^\n]*\n(\s+)/.exec(parser.substring(parser.pos));
1066
- if(match) {
1067
- var whitespace = match[1].split(/\n/g);
1068
- return whitespace[whitespace.length-1];
1069
- }
1070
- }
1071
-
1072
- function onlyWhitespaceRemainsOnLine(offset) {
1073
- offset = offset == null ? 1 : offset;
1074
- return /^\s*\n/.test(parser.substring(parser.pos+offset));
1075
- }
1076
-
1077
- function consumeWhitespace() {
1078
- var ahead = 1;
1079
- var whitespace = '';
1080
- while(isWhitespaceCode(parser.lookAtCharCodeAhead(ahead))) {
1081
- whitespace += parser.lookAtCharAhead(ahead++);
1082
- }
1083
- parser.skip(whitespace.length);
1084
- return whitespace;
1085
- }
1086
-
1087
- function isBeginningOfLine() {
1088
- var before = parser.substring(0, parser.pos);
1089
- var lines = before.split('\n');
1090
- var lastLine = lines[lines.length-1];
1091
- return /^\s*$/.test(lastLine);
1092
- }
1093
-
1094
- function checkForClosingTag() {
1095
- // Look ahead to see if we found the closing tag that will
1096
- // take us out of the EXPRESSION state...
1097
- var match = (
1098
- parser.lookAheadFor('/>') ||
1099
- parser.lookAheadFor('/' + peek(blockStack).tagName + '>') ||
1100
- parser.lookAheadFor('/' + expectedCloseTagName + '>')
1101
- );
1102
-
1103
- if (match) {
1104
- if (parser.state === STATE_JS_COMMENT_LINE) {
1105
- endJavaScriptComment();
1106
- }
1107
- endText();
1108
-
1109
- closeTag(expectedCloseTagName, parser.pos, parser.pos + 1 + match.length);
1110
- parser.skip(match.length);
1111
- parser.enterState(STATE_HTML_CONTENT);
1112
- return true;
1113
- }
1114
-
1115
- return false;
1116
- }
1117
-
1118
- function checkForCDATA() {
1119
- if (parser.lookAheadFor('![CDATA[')) {
1120
- beginCDATA();
1121
- parser.skip(8);
1122
- return true;
1123
- }
1124
-
1125
- return false;
1126
- }
1127
-
1128
- function checkForOperator() {
1129
- var remaining = parser.data.substring(parser.pos);
1130
- var matches = operators.patternNext.exec(remaining);
1131
-
1132
- if (matches) {
1133
- var match = matches[0];
1134
- var operator = matches[1];
1135
-
1136
- if (legacyCompatibility && operator === '-') {
1137
- return false;
1138
- }
1139
-
1140
- var isIgnoredOperator = isConcise ? match.includes('[') : match.includes('>');
1141
- if (!isIgnoredOperator) {
1142
- parser.skip(match.length-1);
1143
- return match;
1144
- }
1145
- } else {
1146
- var previous = parser.substring(parser.pos-operators.longest, parser.pos);
1147
- var match2 = operators.patternPrev.exec(previous);
1148
- if(match2) {
1149
- parser.rewind(1);
1150
- var whitespace = consumeWhitespace();
1151
- return whitespace;
1152
- }
1153
- }
1154
-
1155
- return false;
1156
- }
1157
-
1158
- function checkForTypeofOperator() {
1159
- var remaining = parser.data.substring(parser.pos);
1160
- var matches = /^\s+typeof\s+/.exec(remaining);
1161
-
1162
- if (matches) {
1163
- return matches[0];
1164
- }
1165
-
1166
- return false;
1167
- }
1168
-
1169
- function checkForTypeofOperatorAtStart() {
1170
- var remaining = parser.data.substring(parser.pos);
1171
- var matches = /^typeof\s+/.exec(remaining);
1172
-
1173
- if (matches) {
1174
- return matches[0];
1175
- }
1176
-
1177
- return false;
1178
- }
1179
-
1180
- function handleDelimitedBlockEOL(newLine) {
1181
- // If we are within a delimited HTML block then we want to check if the next line is the end
1182
- // delimiter. Since we are currently positioned at the start of the new line character our lookahead
1183
- // will need to include the new line character, followed by the expected indentation, followed by
1184
- // the delimiter.
1185
- let endHtmlBlockLookahead = htmlBlockIndent + htmlBlockDelimiter;
1186
-
1187
- if (parser.lookAheadFor(endHtmlBlockLookahead, parser.pos + newLine.length)) {
1188
- parser.skip(htmlBlockIndent.length);
1189
- parser.skip(htmlBlockDelimiter.length);
1190
-
1191
- parser.enterState(STATE_CONCISE_HTML_CONTENT);
1192
-
1193
- beginCheckTrailingWhitespace(handleTrailingWhitespaceMultilineHtmlBlock);
1194
- return;
1195
- } else if (parser.lookAheadFor(htmlBlockIndent, parser.pos + newLine.length)) {
1196
- // We know the next line does not end the multiline HTML block, but we need to check if there
1197
- // is any indentation that we need to skip over as we continue parsing the HTML in this
1198
- // multiline HTML block
1199
-
1200
- parser.skip(htmlBlockIndent.length);
1201
- // We stay in the same state since we are still parsing a multiline, delimited HTML block
1202
- } else if(htmlBlockIndent && !onlyWhitespaceRemainsOnLine()) {
1203
- // the next line does not have enough indentation
1204
- // so unless it is black (whitespace only),
1205
- // we will end the block
1206
- endHtmlBlock();
1207
- }
1208
- }
1209
-
1210
- // In STATE_HTML_CONTENT we are looking for tags and placeholders but
1211
- // everything in between is treated as text.
1212
- var STATE_HTML_CONTENT = Parser.createState({
1213
- name: 'STATE_HTML_CONTENT',
1214
-
1215
- placeholder(placeholder) {
1216
- // We found a placeholder while parsing the HTML content. This function is called
1217
- // from endPlaceholder(). We have already notified the listener of the placeholder so there is
1218
- // nothing to do here
1219
- },
1220
-
1221
- eol(newLine) {
1222
- text += newLine;
1223
-
1224
- if (beginMixedMode) {
1225
- beginMixedMode = false;
1226
- endHtmlBlock();
1227
- } else if (endingMixedModeAtEOL) {
1228
- endingMixedModeAtEOL = false;
1229
- endHtmlBlock();
1230
- } else if (isWithinSingleLineHtmlBlock) {
1231
- // We are parsing "HTML" and we reached the end of the line. If we are within a single
1232
- // line HTML block then we should return back to the state to parse concise HTML.
1233
- // A single line HTML block can be at the end of the tag or on its own line:
1234
- //
1235
- // span class="hello" - This is an HTML block at the end of a tag
1236
- // - This is an HTML block on its own line
1237
- //
1238
- endHtmlBlock();
1239
- } else if (htmlBlockDelimiter) {
1240
- handleDelimitedBlockEOL(newLine);
1241
- }
1242
- },
1243
-
1244
- eof: htmlEOF,
1245
-
1246
- enter() {
1247
- textParseMode = 'html';
1248
- isConcise = false; // Back into non-concise HTML parsing
1249
- },
1250
-
1251
- char(ch, code) {
1252
- if (code === CODE_OPEN_ANGLE_BRACKET) {
1253
- if (checkForCDATA()) {
1254
- return;
1255
- }
1256
-
1257
- var nextCode = parser.lookAtCharCodeAhead(1);
1258
-
1259
- if (nextCode === CODE_PERCENT) {
1260
- beginScriptlet();
1261
- parser.skip(1);
1262
- } else if (parser.lookAheadFor('!--')) {
1263
- beginHtmlComment();
1264
- parser.skip(3);
1265
- } else if (nextCode === CODE_EXCLAMATION) {
1266
- // something like:
1267
- // <!DOCTYPE html>
1268
- // NOTE: We already checked for CDATA earlier and <!--
1269
- beginDocumentType();
1270
- parser.skip(1);
1271
- } else if (nextCode === CODE_QUESTION) {
1272
- // something like:
1273
- // <?xml version="1.0"?>
1274
- beginDeclaration();
1275
- parser.skip(1);
1276
- } else if (nextCode === CODE_FORWARD_SLASH) {
1277
- closeTagPos = parser.pos;
1278
- closeTagName = null;
1279
-
1280
- parser.skip(1);
1281
- // something like:
1282
- // </html>
1283
- endText();
1284
-
1285
- parser.enterState(STATE_CLOSE_TAG);
1286
- } else if (nextCode === CODE_CLOSE_ANGLE_BRACKET ||
1287
- nextCode === CODE_OPEN_ANGLE_BRACKET ||
1288
- isWhitespaceCode(nextCode)) {
1289
- // something like:
1290
- // "<>"
1291
- // "<<"
1292
- // "< "
1293
- // We'll treat this left angle brakect as text
1294
- text += '<';
1295
- } else {
1296
- beginOpenTag();
1297
- currentOpenTag.tagNameStart = parser.pos+1;
1298
- }
1299
- } else if (!ignorePlaceholders && checkForEscapedEscapedPlaceholder(ch, code)) {
1300
- text += '\\';
1301
- parser.skip(1);
1302
- } else if (!ignorePlaceholders && checkForEscapedPlaceholder(ch, code)) {
1303
- text += '$';
1304
- parser.skip(1);
1305
- } else if (!ignorePlaceholders && checkForPlaceholder(ch, code)) {
1306
- // We went into placeholder state...
1307
- endText();
1308
- } else if (!legacyCompatibility && code === CODE_DOLLAR && isWhitespaceCode(parser.lookAtCharCodeAhead(1)) && isBeginningOfLine()) {
1309
- parser.skip(1);
1310
- beginInlineScript();
1311
- } else {
1312
- text += ch;
1313
- }
1314
- }
1315
- });
1316
-
1317
- // In STATE_CONCISE_HTML_CONTENT we are looking for concise tags and text blocks based on indent
1318
- var STATE_CONCISE_HTML_CONTENT = Parser.createState({
1319
- name: 'STATE_CONCISE_HTML_CONTENT',
1320
-
1321
- eol(newLine) {
1322
- text += newLine;
1323
- indent = '';
1324
- },
1325
-
1326
- eof: htmlEOF,
1327
-
1328
- enter() {
1329
- isConcise = true;
1330
- indent = '';
1331
- },
1332
-
1333
- comment(comment) {
1334
- var value = comment.value;
1335
-
1336
- value = value.trim();
1337
-
1338
- notifyComment({
1339
- value: value,
1340
- pos: comment.pos,
1341
- endPos: comment.endPos
1342
- });
1343
-
1344
- if (comment.type === 'block') {
1345
- // Make sure there is only whitespace on the line
1346
- // after the ending "*/" sequence
1347
- beginCheckTrailingWhitespace(handleTrailingWhitespaceJavaScriptComment);
1348
- }
1349
- },
1350
-
1351
- endTrailingWhitespace(eof) {
1352
- endHtmlBlock();
1353
-
1354
- if (eof) {
1355
- htmlEOF();
1356
- }
1357
- },
1358
-
1359
- char(ch, code) {
1360
- if (isWhitespaceCode(code)) {
1361
- indent += ch;
1362
- } else {
1363
- while(true) {
1364
- let len = blockStack.length;
1365
- if (len) {
1366
- let curBlock = blockStack[len - 1];
1367
- if (curBlock.indent.length >= indent.length) {
1368
- closeTag(curBlock.expectedCloseTagName);
1369
- } else {
1370
- // Indentation is greater than the last tag so we are starting a
1371
- // nested tag and there are no more tags to end
1372
- break;
1373
- }
1374
- } else {
1375
- if (indent) {
1376
- notifyError(parser.pos,
1377
- 'BAD_INDENTATION',
1378
- 'Line has extra indentation at the beginning');
1379
- return;
1380
- }
1381
- break;
1382
- }
1383
- }
1384
-
1385
- var parent = blockStack.length && blockStack[blockStack.length - 1];
1386
- var body;
1387
-
1388
- if (parent) {
1389
- body = parent.body;
1390
- if (parent.openTagOnly) {
1391
- notifyError(parser.pos,
1392
- 'INVALID_BODY',
1393
- 'The "' + parent.tagName + '" tag does not allow nested body content');
1394
- return;
1395
- }
1396
-
1397
- if (parent.nestedIndent) {
1398
- if (parent.nestedIndent.length !== indent.length) {
1399
- notifyError(parser.pos,
1400
- 'BAD_INDENTATION',
1401
- 'Line indentation does match indentation of previous line');
1402
- return;
1403
- }
1404
- } else {
1405
- parent.nestedIndent = indent;
1406
- }
1407
- }
1408
-
1409
- if (body && code !== CODE_HTML_BLOCK_DELIMITER) {
1410
- notifyError(parser.pos,
1411
- 'ILLEGAL_LINE_START',
1412
- 'A line within a tag that only allows text content must begin with a "-" character');
1413
- return;
1414
- }
1415
-
1416
- if (code === CODE_OPEN_ANGLE_BRACKET || (legacyCompatibility && code === CODE_DOLLAR)) {
1417
- if (code === CODE_DOLLAR) {
1418
- outputDeprecationWarning('Handling of a placeholder (i.e. "${...}") at the start of a concise line will be changing.\nA placeholder at the start of a concise line will now be handled as a tag name placeholder instead of a body text placeholder.\nSwitch to using "-- ${...}" to avoid breakage.\nSee: https://github.com/marko-js/htmljs-parser/issues/48');
1419
- }
1420
- beginMixedMode = true;
1421
- parser.rewind(1);
1422
- beginHtmlBlock();
1423
- return;
1424
- }
1425
-
1426
- if (!legacyCompatibility && code === CODE_DOLLAR && isWhitespaceCode(parser.lookAtCharCodeAhead(1))) {
1427
- parser.skip(1);
1428
- beginInlineScript();
1429
- return;
1430
- }
1431
-
1432
- if (code === CODE_HTML_BLOCK_DELIMITER) {
1433
- if (parser.lookAtCharCodeAhead(1) !== CODE_HTML_BLOCK_DELIMITER) {
1434
- if (legacyCompatibility) {
1435
- outputDeprecationWarning('The usage of a single hyphen at the start of a concise line is now deprecated. Use "--" instead.\nSee: https://github.com/marko-js/htmljs-parser/issues/43');
1436
- } else {
1437
- notifyError(parser.pos,
1438
- 'ILLEGAL_LINE_START',
1439
- 'A line in concise mode cannot start with a single hyphen. Use "--" instead. See: https://github.com/marko-js/htmljs-parser/issues/43');
1440
- return;
1441
- }
1442
- }
1443
-
1444
- htmlBlockDelimiter = ch;
1445
- return parser.enterState(STATE_BEGIN_DELIMITED_HTML_BLOCK);
1446
- } else if (code === CODE_FORWARD_SLASH) {
1447
- // Check next character to see if we are in a comment
1448
- var nextCode = parser.lookAtCharCodeAhead(1);
1449
- if (nextCode === CODE_FORWARD_SLASH) {
1450
- beginLineComment();
1451
- parser.skip(1);
1452
- return;
1453
- } else if (nextCode === CODE_ASTERISK) {
1454
- beginBlockComment();
1455
- parser.skip(1);
1456
- return;
1457
- } else {
1458
- notifyError(parser.pos,
1459
- 'ILLEGAL_LINE_START',
1460
- 'A line in concise mode cannot start with "/" unless it starts a "//" or "/*" comment');
1461
- return;
1462
- }
1463
- } else {
1464
- beginOpenTag();
1465
- currentOpenTag.tagNameStart = parser.pos;
1466
- parser.rewind(1); // START_TAG_NAME expects to start at the first character
1467
- }
1468
-
1469
- }
1470
- }
1471
- });
1472
-
1473
- // In STATE_BEGIN_DELIMITED_HTML_BLOCK we have already found two consecutive hyphens. We expect
1474
- // to reach the end of the line with only whitespace characters
1475
- var STATE_BEGIN_DELIMITED_HTML_BLOCK = Parser.createState({
1476
- name: 'STATE_BEGIN_DELIMITED_HTML_BLOCK',
1477
-
1478
- eol: function(newLine) {
1479
- // We have reached the end of the first delimiter... we need to skip over any indentation on the next
1480
- // line and we might also find that the multi-line, delimited block is immediately ended
1481
- beginHtmlBlock(htmlBlockDelimiter);
1482
- handleDelimitedBlockEOL(newLine);
1483
- },
1484
-
1485
- eof: htmlEOF,
1486
-
1487
- char(ch, code) {
1488
- if (code === CODE_HTML_BLOCK_DELIMITER) {
1489
- htmlBlockDelimiter += ch;
1490
- } else if(!onlyWhitespaceRemainsOnLine()) {
1491
- isWithinSingleLineHtmlBlock = true;
1492
- beginHtmlBlock();
1493
- }
1494
- }
1495
- });
1496
-
1497
- var STATE_CHECK_TRAILING_WHITESPACE = Parser.createState({
1498
- name: 'STATE_CHECK_TRAILING_WHITESPACE',
1499
-
1500
- eol: function() {
1501
- endCheckTrailingWhitespace(null /* no error */, false /* not EOF */);
1502
- },
1503
-
1504
- eof: function() {
1505
- endCheckTrailingWhitespace(null /* no error */, true /* EOF */);
1506
- },
1507
-
1508
- char(ch, code) {
1509
- if (isWhitespaceCode(code)) {
1510
- // Just whitespace... we are still good
1511
- } else {
1512
- endCheckTrailingWhitespace({
1513
- ch: ch
1514
- });
1515
- }
1516
- }
1517
- });
1518
-
1519
- // We enter STATE_STATIC_TEXT_CONTENT when a listener manually chooses
1520
- // to enter this state after seeing an openTag event for a tag
1521
- // whose content should not be parsed at all (except for the purpose
1522
- // of looking for the end tag).
1523
- var STATE_STATIC_TEXT_CONTENT = Parser.createState({
1524
- name: 'STATE_STATIC_TEXT_CONTENT',
1525
-
1526
- enter() {
1527
- textParseMode = 'static-text';
1528
- },
1529
-
1530
- eol(newLine) {
1531
- text += newLine;
1532
-
1533
- if (isWithinSingleLineHtmlBlock) {
1534
- // We are parsing "HTML" and we reached the end of the line. If we are within a single
1535
- // line HTML block then we should return back to the state to parse concise HTML.
1536
- // A single line HTML block can be at the end of the tag or on its own line:
1537
- //
1538
- // span class="hello" - This is an HTML block at the end of a tag
1539
- // - This is an HTML block on its own line
1540
- //
1541
- endHtmlBlock();
1542
- } else if (htmlBlockDelimiter) {
1543
- handleDelimitedBlockEOL(newLine);
1544
- }
1545
- },
1546
-
1547
- eof: htmlEOF,
1548
-
1549
- char(ch, code) {
1550
- // See if we need to see if we reached the closing tag...
1551
- if (!isConcise && code === CODE_OPEN_ANGLE_BRACKET) {
1552
- if (checkForClosingTag()) {
1553
- return;
1554
- }
1555
- }
1556
-
1557
- text += ch;
1558
- }
1559
- });
1560
-
1561
- // We enter STATE_PARSED_TEXT_CONTENT when we are parsing
1562
- // the body of a tag does not contain HTML tags but may contains
1563
- // placeholders
1564
- var STATE_PARSED_TEXT_CONTENT = Parser.createState({
1565
- name: 'STATE_PARSED_TEXT_CONTENT',
1566
-
1567
- enter() {
1568
- textParseMode = 'parsed-text';
1569
- },
1570
-
1571
- placeholder: STATE_HTML_CONTENT.placeholder,
1572
-
1573
- comment(comment) {
1574
- text += comment.rawValue;
1575
-
1576
- if (htmlBlockDelimiter && comment.eol) {
1577
- handleDelimitedBlockEOL(comment.eol);
1578
- }
1579
- },
1580
-
1581
- templateString(templateString) {
1582
- text += templateString.value;
1583
- },
1584
-
1585
- eol(newLine) {
1586
- text += newLine;
1587
-
1588
- if (isWithinSingleLineHtmlBlock) {
1589
- // We are parsing "HTML" and we reached the end of the line. If we are within a single
1590
- // line HTML block then we should return back to the state to parse concise HTML.
1591
- // A single line HTML block can be at the end of the tag or on its own line:
1592
- //
1593
- // span class="hello" - This is an HTML block at the end of a tag
1594
- // - This is an HTML block on its own line
1595
- //
1596
- endHtmlBlock();
1597
- } else if (htmlBlockDelimiter) {
1598
- handleDelimitedBlockEOL(newLine);
1599
- }
1600
- },
1601
-
1602
- eof: htmlEOF,
1603
-
1604
- char(ch, code) {
1605
- if (!isConcise && code === CODE_OPEN_ANGLE_BRACKET) {
1606
- // First, see if we need to see if we reached the closing tag
1607
- // and then check if we encountered CDATA
1608
- if (checkForClosingTag()) {
1609
- return;
1610
- } else if (checkForCDATA()) {
1611
- return;
1612
- } else if (parser.lookAtCharCodeAhead(1) === CODE_PERCENT) {
1613
- beginScriptlet();
1614
- parser.skip(1);
1615
- return;
1616
- }
1617
- }
1618
-
1619
-
1620
- if (code === CODE_FORWARD_SLASH) {
1621
- if (parser.lookAtCharCodeAhead(1) === CODE_ASTERISK) {
1622
- // Skip over code inside a JavaScript block comment
1623
- beginBlockComment();
1624
- parser.skip(1);
1625
- return;
1626
- } else if (parser.lookAtCharCodeAhead(1) === CODE_FORWARD_SLASH) {
1627
- beginLineComment();
1628
- parser.skip(1);
1629
- return;
1630
- }
1631
- }
1632
-
1633
- if (code === CODE_BACKTICK) {
1634
- beginTemplateString();
1635
- return;
1636
-
1637
- }
1638
-
1639
- if (!ignorePlaceholders && checkForEscapedEscapedPlaceholder(ch, code)) {
1640
- parser.skip(1);
1641
- } else if (!ignorePlaceholders && checkForEscapedPlaceholder(ch, code)) {
1642
- text += '$';
1643
- parser.skip(1);
1644
- return;
1645
- } else if (!ignorePlaceholders && checkForPlaceholder(ch, code)) {
1646
- // We went into placeholder state...
1647
- endText();
1648
- return;
1649
- }
1650
-
1651
- text += ch;
1652
- }
1653
- });
1654
-
1655
- // We enter STATE_TAG_NAME after we encounter a "<"
1656
- // followed by a non-special character
1657
- var STATE_TAG_NAME = Parser.createState({
1658
- name: 'STATE_TAG_NAME',
1659
-
1660
- eol: openTagEOL,
1661
-
1662
- eof: openTagEOF,
1663
-
1664
- expression(expression) {
1665
- currentOpenTag.tagNameEnd = expression.endPos;
1666
-
1667
- if (expression.value) {
1668
- currentOpenTag.tagName += expression.value;
1669
-
1670
- if (currentOpenTag.tagNameParts) {
1671
- currentOpenTag.tagNameParts.push(JSON.stringify(expression.value));
1672
- }
1673
- }
1674
- },
1675
-
1676
- placeholder(placeholder) {
1677
- if (!currentOpenTag.tagNameParts) {
1678
- currentOpenTag.tagNameParts = [];
1679
-
1680
- if (currentOpenTag.tagName) {
1681
- currentOpenTag.tagNameParts.push(JSON.stringify(currentOpenTag.tagName));
1682
- }
1683
- }
1684
-
1685
- currentOpenTag.tagName += parser.substring(placeholder.pos, placeholder.endPos);
1686
- currentOpenTag.tagNameParts.push('(' + placeholder.value + ')');
1687
- currentOpenTag.tagNameEnd = placeholder.endPos;
1688
- var nextCode = parser.lookAtCharCodeAhead(1);
1689
- if (nextCode === CODE_OPEN_PAREN) {
1690
- endExpression();
1691
- parser.enterState(STATE_TAG_ARGS);
1692
- }
1693
- },
1694
-
1695
- enter(oldState) {
1696
- if (oldState !== STATE_EXPRESSION) {
1697
- beginExpression();
1698
- }
1699
- },
1700
-
1701
- char(ch, code) {
1702
- throw new Error('Illegal state');
1703
- }
1704
- });
1705
-
1706
- var STATE_TAG_ARGS = Parser.createState({
1707
- name: 'STATE_TAG_ARGS',
1708
-
1709
- eol: openTagEOL,
1710
-
1711
- eof: openTagEOF,
1712
-
1713
- expression(expression) {
1714
- var method = getAndRemoveMethod(expression);
1715
- if (method) {
1716
- beginAttribute();
1717
- currentAttribute.name = "default";
1718
- currentAttribute.default = true;
1719
- currentAttribute.method = true;
1720
- currentAttribute.value = method.value;
1721
- currentAttribute.pos = method.pos;
1722
- currentAttribute.endPos = method.endPos;
1723
- endAttribute();
1724
- if (STATE_WITHIN_OPEN_TAG !== parser.state) {
1725
- parser.enterState(STATE_WITHIN_OPEN_TAG);
1726
- }
1727
- } else {
1728
- var value = expression.value;
1729
- if (value.charCodeAt(value.length-1) !== CODE_CLOSE_PAREN) {
1730
- throw new Error('Invalid argument');
1731
- }
1732
- expression.value = value.slice(1, value.length-1);
1733
- expression.pos += 1;
1734
- expression.endPos -= 1;
1735
- currentOpenTag.argument = expression;
1736
-
1737
- if (parser.lookAtCharCodeAhead(1) === CODE_PIPE) {
1738
- parser.enterState(STATE_TAG_PARAMS);
1739
- } else {
1740
- parser.enterState(STATE_WITHIN_OPEN_TAG);
1741
- }
1742
- }
1743
- },
1744
-
1745
- enter(oldState) {
1746
- beginExpression();
1747
- },
1748
-
1749
- char(ch, code) {
1750
- throw new Error('Illegal state');
1751
- }
1752
- });
1753
-
1754
- var STATE_TAG_PARAMS = Parser.createState({
1755
- name: 'STATE_TAG_PARAMS',
1756
-
1757
- eol: openTagEOL,
1758
-
1759
- eof: openTagEOF,
1760
-
1761
- expression(expression) {
1762
- var value = expression.value;
1763
- expression.value = value.slice(1);
1764
- expression.pos += 1;
1765
- currentOpenTag.params = expression;
1766
- parser.enterState(STATE_WITHIN_OPEN_TAG);
1767
- },
1768
-
1769
- enter(oldState) {
1770
- if (oldState !== STATE_EXPRESSION) {
1771
- beginExpression();
1772
- }
1773
- },
1774
-
1775
- char(ch, code) {
1776
- throw new Error('Illegal state');
1777
- }
1778
- });
1779
-
1780
- var STATE_TAG_VAR = Parser.createState({
1781
- name: 'STATE_TAG_VAR',
1782
-
1783
- eol: openTagEOL,
1784
-
1785
- eof: openTagEOF,
1786
-
1787
- expression(expression) {
1788
- var value = expression.value;
1789
- expression.value = value.slice(1);
1790
- expression.pos += 1;
1791
- currentOpenTag.var = expression;
1792
- if (parser.lookAtCharCodeAhead(1) === CODE_PIPE) {
1793
- parser.enterState(STATE_TAG_PARAMS);
1794
- } else if (parser.lookAtCharCodeAhead(1) === CODE_OPEN_PAREN) {
1795
- parser.enterState(STATE_TAG_ARGS);
1796
- } else {
1797
- parser.enterState(STATE_WITHIN_OPEN_TAG);
1798
- }
1799
- },
1800
-
1801
- enter(oldState) {
1802
- if (oldState !== STATE_EXPRESSION) {
1803
- beginExpression();
1804
- }
1805
- },
1806
-
1807
- char(ch, code) {
1808
- throw new Error('Illegal state');
1809
- }
1810
- });
1811
-
1812
- // We enter STATE_CDATA after we see "<![CDATA["
1813
- var STATE_CDATA = Parser.createState({
1814
- name: 'STATE_CDATA',
1815
-
1816
- enter() {
1817
- textParseMode = 'cdata';
1818
- },
1819
-
1820
- eof() {
1821
- notifyError(currentPart.pos,
1822
- 'MALFORMED_CDATA',
1823
- 'EOF reached while parsing CDATA');
1824
- },
1825
-
1826
- char(ch, code) {
1827
- if (code === CODE_CLOSE_SQUARE_BRACKET) {
1828
- var match = parser.lookAheadFor(']>');
1829
- if (match) {
1830
- endCDATA();
1831
- parser.skip(match.length);
1832
- return;
1833
- }
1834
- }
1835
-
1836
- currentPart.value += ch;
1837
- }
1838
- });
1839
-
1840
- // We enter STATE_CLOSE_TAG after we see "</"
1841
- var STATE_CLOSE_TAG = Parser.createState({
1842
- name: 'STATE_CLOSE_TAG',
1843
- eof() {
1844
- notifyError(closeTag.pos,
1845
- 'MALFORMED_CLOSE_TAG',
1846
- 'EOF reached while parsing closing tag');
1847
- },
1848
-
1849
- enter() {
1850
- closeTagName = '';
1851
- },
1852
-
1853
- char(ch, code) {
1854
- if (code === CODE_CLOSE_ANGLE_BRACKET) {
1855
- if (closeTagName.length > 0) {
1856
- closeTag(closeTagName, closeTagPos, parser.pos + 1);
1857
- } else {
1858
- closeTag(expectedCloseTagName, closeTagPos, parser.pos + 1);
1859
- }
1860
-
1861
- parser.enterState(STATE_HTML_CONTENT);
1862
- } else {
1863
- closeTagName += ch;
1864
- }
1865
- }
1866
- });
1867
-
1868
- // We enter STATE_WITHIN_OPEN_TAG after we have fully
1869
- // read in the tag name and encountered a whitespace character
1870
- var STATE_WITHIN_OPEN_TAG = Parser.createState({
1871
- name: 'STATE_WITHIN_OPEN_TAG',
1872
-
1873
- eol: openTagEOL,
1874
-
1875
- eof: openTagEOF,
1876
-
1877
- enter() {
1878
- if (!currentOpenTag.notifiedOpenTagName) {
1879
- currentOpenTag.notifiedOpenTagName = true;
1880
- currentOpenTag.tagNameEndPos = parser.pos;
1881
- notifyOpenTagName(currentOpenTag);
1882
- }
1883
- },
1884
-
1885
- expression(expression) {
1886
- var argument = getAndRemoveArgument(expression);
1887
- var method = getAndRemoveMethod(expression);
1888
-
1889
- if (method) {
1890
- let targetAttribute;
1891
- if (currentOpenTag.attributes.length === 0) {
1892
- targetAttribute = beginAttribute();
1893
- currentAttribute.name = "default";
1894
- currentAttribute.default = true;
1895
- } else {
1896
- targetAttribute = currentAttribute || peek(currentOpenTag.attributes);
1897
- }
1898
- targetAttribute.method = true;
1899
- targetAttribute.value = method.value;
1900
- targetAttribute.pos = method.pos;
1901
- targetAttribute.endPos = method.endPos;
1902
- } else if (argument) {
1903
- // We found an argument... the argument could be for an attribute or the tag
1904
- if (currentOpenTag.attributes.length === 0) {
1905
- if (currentOpenTag.argument != null) {
1906
- notifyError(expression.endPos,
1907
- 'ILLEGAL_TAG_ARGUMENT',
1908
- 'A tag can only have one argument');
1909
- return;
1910
- }
1911
- currentOpenTag.argument = argument;
1912
- } else {
1913
- let targetAttribute = currentAttribute || peek(currentOpenTag.attributes);
1914
-
1915
- if (targetAttribute.argument != null) {
1916
- notifyError(expression.endPos,
1917
- 'ILLEGAL_ATTRIBUTE_ARGUMENT',
1918
- 'An attribute can only have one argument');
1919
- return;
1920
- }
1921
- targetAttribute.argument = argument;
1922
- }
1923
- }
1924
- },
1925
-
1926
- placeholder(placeholder) {
1927
- var attr = beginAttribute();
1928
- attr.value = placeholder.value;
1929
- endAttribute();
1930
-
1931
- parser.enterState(STATE_AFTER_PLACEHOLDER_WITHIN_TAG);
1932
- },
1933
-
1934
- comment(comment) {
1935
- /* Ignore comments within an open tag */
1936
- },
1937
-
1938
- char(ch, code) {
1939
- if (isConcise) {
1940
- if (code === CODE_HTML_BLOCK_DELIMITER) {
1941
- if (parser.lookAtCharCodeAhead(1) !== CODE_HTML_BLOCK_DELIMITER) {
1942
- if (legacyCompatibility) {
1943
- outputDeprecationWarning('The usage of a single hyphen in a concise line is now deprecated. Use "--" instead.\nSee: https://github.com/marko-js/htmljs-parser/issues/43');
1944
- } else {
1945
- notifyError(currentOpenTag.pos,
1946
- 'MALFORMED_OPEN_TAG',
1947
- '"-" not allowed as first character of attribute name');
1948
- return;
1949
- }
1950
- }
1951
-
1952
- if (currentOpenTag.withinAttrGroup) {
1953
- notifyError(parser.pos,
1954
- 'MALFORMED_OPEN_TAG',
1955
- 'Attribute group was not properly ended');
1956
- return;
1957
- }
1958
-
1959
- // The open tag is complete
1960
- finishOpenTag();
1961
-
1962
- htmlBlockDelimiter = ch;
1963
- var nextIndent = getNextIndent();
1964
- if(nextIndent > indent) {
1965
- indent = nextIndent;
1966
- }
1967
- parser.enterState(STATE_BEGIN_DELIMITED_HTML_BLOCK);
1968
- return;
1969
- } else if (code === CODE_OPEN_SQUARE_BRACKET) {
1970
- if (currentOpenTag.withinAttrGroup) {
1971
- notifyError(parser.pos,
1972
- 'MALFORMED_OPEN_TAG',
1973
- 'Unexpected "[" character within open tag.');
1974
- return;
1975
- }
1976
-
1977
- currentOpenTag.withinAttrGroup = true;
1978
- return;
1979
- } else if (code === CODE_CLOSE_SQUARE_BRACKET) {
1980
- if (!currentOpenTag.withinAttrGroup) {
1981
- notifyError(parser.pos,
1982
- 'MALFORMED_OPEN_TAG',
1983
- 'Unexpected "]" character within open tag.');
1984
- return;
1985
- }
1986
-
1987
- currentOpenTag.withinAttrGroup = false;
1988
- return;
1989
- }
1990
- } else {
1991
- if (code === CODE_CLOSE_ANGLE_BRACKET) {
1992
- finishOpenTag();
1993
- return;
1994
- } else if (code === CODE_FORWARD_SLASH) {
1995
- let nextCode = parser.lookAtCharCodeAhead(1);
1996
- if (nextCode === CODE_CLOSE_ANGLE_BRACKET) {
1997
- finishOpenTag(true /* self closed */);
1998
- parser.skip(1);
1999
- return;
2000
- }
2001
- }
2002
- }
2003
-
2004
- if (checkForEscapedEscapedPlaceholder(ch, code)) {
2005
- let attr = beginAttribute();
2006
- attr.name = '\\';
2007
- parser.skip(1);
2008
- return;
2009
- } else if (checkForEscapedPlaceholder(ch, code)) {
2010
- let attr = beginAttribute();
2011
- attr.name = '$';
2012
- parser.skip(1);
2013
- return;
2014
- } else if (checkForPlaceholder(ch, code)) {
2015
- return;
2016
- }
2017
-
2018
- if (code === CODE_OPEN_ANGLE_BRACKET) {
2019
- return notifyError(parser.pos,
2020
- 'ILLEGAL_ATTRIBUTE_NAME',
2021
- 'Invalid attribute name. Attribute name cannot begin with the "<" character.');
2022
- }
2023
-
2024
- if (code === CODE_FORWARD_SLASH && parser.lookAtCharCodeAhead(1) === CODE_ASTERISK) {
2025
- // Skip over code inside a JavaScript block comment
2026
- beginBlockComment();
2027
- parser.skip(1);
2028
- return;
2029
- }
2030
-
2031
- if (isWhitespaceCode(code)) {
2032
- // ignore whitespace within element...
2033
- } else if (code === CODE_OPEN_PAREN) {
2034
- parser.rewind(1);
2035
- beginExpression();
2036
- // encountered something like:
2037
- // <for (var i = 0; i < len; i++)>
2038
- } else {
2039
- parser.rewind(1);
2040
- // attribute name is initially the first non-whitespace
2041
- // character that we found
2042
- beginAttribute();
2043
- }
2044
- }
2045
- });
2046
-
2047
- // We enter STATE_ATTRIBUTE_NAME when we see a non-whitespace
2048
- // character after reading the tag name
2049
- var STATE_ATTRIBUTE_NAME = Parser.createState({
2050
- name: 'STATE_ATTRIBUTE_NAME',
2051
-
2052
- eol: openTagEOL,
2053
-
2054
- eof: openTagEOF,
2055
-
2056
- expression(expression) {
2057
- var argument = getAndRemoveArgument(expression);
2058
- var method = getAndRemoveMethod(expression);
2059
-
2060
- if(expression.endedWithComma) {
2061
- // consume all following whitespace,
2062
- // including new lines (which allows attributes to
2063
- // span multiple lines in concise mode)
2064
- consumeWhitespace();
2065
- currentOpenTag.requiresCommas = true;
2066
- currentAttribute.endedWithComma = true;
2067
- } else if(!lookPastWhitespaceFor('=', 0)){
2068
- currentOpenTag.lastAttrNoComma = true;
2069
- }
2070
-
2071
- currentAttribute.name = currentAttribute.name ? currentAttribute.name + expression.value : expression.value;
2072
- currentAttribute.pos = expression.pos;
2073
- currentAttribute.endPos = expression.endPos;
2074
-
2075
- if (!currentAttribute.name) {
2076
- currentAttribute.name = "default";
2077
- currentAttribute.default = true;
2078
- }
2079
-
2080
- if (argument) {
2081
- currentAttribute.argument = argument;
2082
- } else if (method) {
2083
- currentAttribute.method = true;
2084
- currentAttribute.value = method.value;
2085
- currentAttribute.pos = method.pos;
2086
- currentAttribute.endPos = method.endPos;
2087
- }
2088
- },
2089
-
2090
- enter(oldState) {
2091
- if (currentOpenTag.requiresCommas && currentOpenTag.lastAttrNoComma) {
2092
- var parseOptions = currentOpenTag.parseOptions;
2093
-
2094
- if (!parseOptions || parseOptions.relaxRequireCommas !== true) {
2095
- return notifyError(parser.pos,
2096
- 'COMMAS_REQUIRED',
2097
- 'if commas are used, they must be used to separate all attributes for a tag');
2098
- }
2099
- }
2100
-
2101
- if (oldState !== STATE_EXPRESSION) {
2102
- beginExpression();
2103
- }
2104
- },
2105
-
2106
- char(ch, code) {
2107
- throw new Error('Illegal state');
2108
- }
2109
- });
2110
-
2111
- // We enter STATE_ATTRIBUTE_VALUE when we see a "=" while in
2112
- // the ATTRIBUTE_NAME state.
2113
- var STATE_ATTRIBUTE_VALUE = Parser.createState({
2114
- name: 'STATE_ATTRIBUTE_VALUE',
2115
-
2116
- expression(expression) {
2117
- var value = expression.value;
2118
-
2119
- if (value === '') {
2120
-
2121
- return notifyError(expression.pos,
2122
- 'ILLEGAL_ATTRIBUTE_VALUE',
2123
- 'No attribute value found after "="');
2124
- }
2125
-
2126
- if(expression.endedWithComma) {
2127
- // consume all following whitespace,
2128
- // including new lines (which allows attributes to
2129
- // span multiple lines in concise mode)
2130
- consumeWhitespace();
2131
- currentOpenTag.requiresCommas = true;
2132
- currentAttribute.endedWithComma = true;
2133
- } else {
2134
- currentOpenTag.lastAttrNoComma = true;
2135
- }
2136
-
2137
- if(expression.hasUnenclosedWhitespace) {
2138
- currentOpenTag.hasUnenclosedWhitespace = true;
2139
- }
2140
-
2141
- currentAttribute.value = value;
2142
- currentAttribute.pos = expression.pos;
2143
- currentAttribute.endPos = expression.endPos;
2144
-
2145
- // If the expression evaluates to a literal value then add the
2146
- // `literalValue` property to the attribute
2147
- if (expression.isStringLiteral) {
2148
- currentAttribute.literalValue = evaluateStringExpression(value, expression.pos, notifyError);
2149
- } else if (value === 'true') {
2150
- currentAttribute.literalValue = true;
2151
- } else if (value === 'false') {
2152
- currentAttribute.literalValue = false;
2153
- } else if (value === 'null') {
2154
- currentAttribute.literalValue = null;
2155
- } else if (value === 'undefined') {
2156
- currentAttribute.literalValue = undefined;
2157
- } else if (NUMBER_REGEX.test(value)) {
2158
- currentAttribute.literalValue = Number(value);
2159
- }
2160
-
2161
- // We encountered a whitespace character while parsing the attribute name. That
2162
- // means the attribute name has ended and we should continue parsing within the
2163
- // open tag
2164
- endAttribute();
2165
- },
2166
-
2167
- eol: openTagEOL,
2168
-
2169
- eof: openTagEOF,
2170
-
2171
- enter(oldState) {
2172
- if (oldState !== STATE_EXPRESSION) {
2173
- beginExpression();
2174
- }
2175
- },
2176
-
2177
- char(ch, code) {
2178
- throw new Error('Illegal state');
2179
- }
2180
- });
2181
-
2182
- var STATE_EXPRESSION = Parser.createState({
2183
- name: 'STATE_EXPRESSION',
2184
-
2185
- eol(str) {
2186
- let depth = currentPart.groupStack.length;
2187
-
2188
- if (depth === 0) {
2189
- if (currentPart.parentState === STATE_ATTRIBUTE_NAME || currentPart.parentState === STATE_ATTRIBUTE_VALUE) {
2190
- currentPart.endPos = parser.pos;
2191
- endExpression();
2192
- // We encountered a whitespace character while parsing the attribute name. That
2193
- // means the attribute name has ended and we should continue parsing within the
2194
- // open tag
2195
- endAttribute();
2196
-
2197
- if (isConcise) {
2198
- openTagEOL();
2199
- }
2200
- return;
2201
- } else if (
2202
- currentPart.parentState === STATE_TAG_NAME ||
2203
- (isConcise && (
2204
- currentPart.parentState === STATE_TAG_ARGS ||
2205
- currentPart.parentState === STATE_WITHIN_OPEN_TAG)
2206
- )
2207
- ) {
2208
- currentPart.endPos = parser.pos;
2209
- endExpression();
2210
-
2211
- // We encountered a whitespace character while parsing the attribute name. That
2212
- // means the attribute name has ended and we should continue parsing within the
2213
- // open tag
2214
- if (parser.state !== STATE_WITHIN_OPEN_TAG) {
2215
- // Make sure we transition into parsing within the open tag
2216
- parser.enterState(STATE_WITHIN_OPEN_TAG);
2217
- }
2218
-
2219
- if (isConcise) {
2220
- openTagEOL();
2221
- }
2222
-
2223
- return;
2224
- }
2225
- }
2226
-
2227
- currentPart.value += str;
2228
- },
2229
-
2230
- eof() {
2231
- if (isConcise && currentPart.groupStack.length === 0) {
2232
- currentPart.endPos = parser.pos;
2233
- endExpression();
2234
- openTagEOF();
2235
- } else {
2236
- let parentState = currentPart.parentState;
2237
-
2238
- if (parentState === STATE_ATTRIBUTE_NAME) {
2239
- return notifyError(currentPart.pos,
2240
- 'MALFORMED_OPEN_TAG',
2241
- 'EOF reached while parsing attribute name for the "' + currentOpenTag.tagName + '" tag');
2242
- } else if (parentState === STATE_ATTRIBUTE_VALUE) {
2243
- return notifyError(currentPart.pos,
2244
- 'MALFORMED_OPEN_TAG',
2245
- 'EOF reached while parsing attribute value for the "' + currentAttribute.name + '" attribute');
2246
- } else if (parentState === STATE_TAG_NAME) {
2247
- return notifyError(currentPart.pos,
2248
- 'MALFORMED_OPEN_TAG',
2249
- 'EOF reached while parsing tag name');
2250
- } else if (parentState === STATE_PLACEHOLDER) {
2251
- return notifyError(currentPart.pos,
2252
- 'MALFORMED_PLACEHOLDER',
2253
- 'EOF reached while parsing placeholder');
2254
- }
2255
-
2256
- return notifyError(currentPart.pos,
2257
- 'INVALID_EXPRESSION',
2258
- 'EOF reached while parsing expression');
2259
- }
2260
- },
2261
-
2262
- string(string) {
2263
- if (currentPart.value === '') {
2264
- currentPart.isStringLiteral = string.isStringLiteral === true;
2265
- } else {
2266
- // More than one strings means it is for sure not a string literal...
2267
- currentPart.isStringLiteral = false;
2268
- }
2269
-
2270
- currentPart.value += string.value;
2271
- },
2272
-
2273
- comment(comment) {
2274
- currentPart.isStringLiteral = false;
2275
- currentPart.value += comment.rawValue;
2276
- },
2277
-
2278
- templateString(templateString) {
2279
- currentPart.isStringLiteral = false;
2280
- currentPart.value += templateString.value;
2281
- },
2282
-
2283
- regularExpression(regularExpression) {
2284
- currentPart.isStringLiteral = false;
2285
- currentPart.value += regularExpression.value;
2286
- },
2287
-
2288
- char(ch, code) {
2289
- let depth = currentPart.groupStack.length;
2290
- let parentState = currentPart.parentState;
2291
-
2292
- if (code === CODE_SINGLE_QUOTE) {
2293
- return beginString("'", CODE_SINGLE_QUOTE);
2294
- } else if (code === CODE_DOUBLE_QUOTE) {
2295
- return beginString('"', CODE_DOUBLE_QUOTE);
2296
- } else if (code === CODE_BACKTICK) {
2297
- return beginTemplateString();
2298
- } else if (code === CODE_FORWARD_SLASH) {
2299
- // Check next character to see if we are in a comment
2300
- var nextCode = parser.lookAtCharCodeAhead(1);
2301
- if (nextCode === CODE_FORWARD_SLASH) {
2302
- beginLineComment();
2303
- parser.skip(1);
2304
- return;
2305
- } else if (nextCode === CODE_ASTERISK) {
2306
- beginBlockComment();
2307
- parser.skip(1);
2308
- return;
2309
- } else if (depth === 0 && !isConcise && nextCode === CODE_CLOSE_ANGLE_BRACKET) {
2310
- // Let the STATE_WITHIN_OPEN_TAG state deal with the ending tag sequence
2311
- currentPart.endPos = parser.pos;
2312
- endExpression();
2313
- parser.rewind(1);
2314
-
2315
- if (parser.state !== STATE_WITHIN_OPEN_TAG) {
2316
- // Make sure we transition into parsing within the open tag
2317
- parser.enterState(STATE_WITHIN_OPEN_TAG);
2318
- }
2319
- return;
2320
- } else if (!/[\]})A-Z0-9.<%]/i.test(getPreviousNonWhitespaceChar())) {
2321
- beginRegularExpression();
2322
- return;
2323
- }
2324
- } else if (code === CODE_PIPE && parentState === STATE_TAG_PARAMS) {
2325
- if (depth === 0) {
2326
- currentPart.groupStack.push(code);
2327
- currentPart.isStringLiteral = false;
2328
- currentPart.value += ch;
2329
- return;
2330
- } else if (depth === 1) {
2331
- endExpression();
2332
- return;
2333
- }
2334
- } else if (code === CODE_OPEN_PAREN ||
2335
- code === CODE_OPEN_SQUARE_BRACKET ||
2336
- code === CODE_OPEN_CURLY_BRACE) {
2337
-
2338
- if (depth === 0 && code === CODE_OPEN_PAREN) {
2339
- currentPart.lastLeftParenPos = currentPart.value.length;
2340
- }
2341
-
2342
- currentPart.groupStack.push(code);
2343
- currentPart.isStringLiteral = false;
2344
- currentPart.value += ch;
2345
- return;
2346
- } else if (code === CODE_CLOSE_PAREN ||
2347
- code === CODE_CLOSE_SQUARE_BRACKET ||
2348
- code === CODE_CLOSE_CURLY_BRACE) {
2349
-
2350
- if (depth === 0) {
2351
- if (code === CODE_CLOSE_SQUARE_BRACKET) {
2352
- // We are ending the attribute group so end this expression and let the
2353
- // STATE_WITHIN_OPEN_TAG state deal with the ending attribute group
2354
- if (currentOpenTag.withinAttrGroup) {
2355
- currentPart.endPos = parser.pos + 1;
2356
- endExpression();
2357
- // Let the STATE_WITHIN_OPEN_TAG state deal with the ending tag sequence
2358
- parser.rewind(1);
2359
- if (parser.state !== STATE_WITHIN_OPEN_TAG) {
2360
- // Make sure we transition into parsing within the open tag
2361
- parser.enterState(STATE_WITHIN_OPEN_TAG);
2362
- }
2363
- return;
2364
- }
2365
- } else {
2366
- return notifyError(currentPart.pos,
2367
- 'INVALID_EXPRESSION',
2368
- 'Mismatched group. A closing "' + ch + '" character was found but it is not matched with a corresponding opening character.');
2369
- }
2370
- }
2371
-
2372
-
2373
- let matchingGroupCharCode = currentPart.groupStack.pop();
2374
-
2375
- if ((code === CODE_CLOSE_PAREN && matchingGroupCharCode !== CODE_OPEN_PAREN) ||
2376
- (code === CODE_CLOSE_SQUARE_BRACKET && matchingGroupCharCode !== CODE_OPEN_SQUARE_BRACKET) ||
2377
- (code === CODE_CLOSE_CURLY_BRACE && matchingGroupCharCode !== CODE_OPEN_CURLY_BRACE)) {
2378
- return notifyError(currentPart.pos,
2379
- 'INVALID_EXPRESSION',
2380
- 'Mismatched group. A "' + ch + '" character was found when "' + String.fromCharCode(matchingGroupCharCode) + '" was expected.');
2381
- }
2382
-
2383
- currentPart.value += ch;
2384
-
2385
- if (currentPart.groupStack.length === 0) {
2386
- if (code === CODE_CLOSE_PAREN) {
2387
- currentPart.lastRightParenPos = currentPart.value.length - 1;
2388
- if ((parentState == STATE_ATTRIBUTE_NAME || parentState == STATE_TAG_ARGS || parentState == STATE_WITHIN_OPEN_TAG) && lookPastWhitespaceFor('{')) {
2389
- currentPart.method = true;
2390
- currentPart.value += consumeWhitespace();
2391
- return;
2392
- }
2393
- }
2394
- var endPlaceholder = code === CODE_CLOSE_CURLY_BRACE && parentState === STATE_PLACEHOLDER;
2395
- var endTagArgs = code === CODE_CLOSE_PAREN && parentState === STATE_TAG_ARGS;
2396
- if (endPlaceholder || endTagArgs) {
2397
- currentPart.endPos = parser.pos + 1;
2398
- endExpression();
2399
- return;
2400
- }
2401
- }
2402
-
2403
- return;
2404
- }
2405
-
2406
- if (depth === 0) {
2407
-
2408
- if (!isConcise) {
2409
- if (code === CODE_CLOSE_ANGLE_BRACKET &&
2410
- (parentState === STATE_TAG_NAME ||
2411
- parentState === STATE_ATTRIBUTE_NAME ||
2412
- parentState === STATE_ATTRIBUTE_VALUE ||
2413
- parentState === STATE_WITHIN_OPEN_TAG)) {
2414
- currentPart.endPos = parser.pos;
2415
- endExpression();
2416
- endAttribute();
2417
- // Let the STATE_WITHIN_OPEN_TAG state deal with the ending tag sequence
2418
- parser.rewind(1);
2419
- if (parser.state !== STATE_WITHIN_OPEN_TAG) {
2420
- // Make sure we transition into parsing within the open tag
2421
- parser.enterState(STATE_WITHIN_OPEN_TAG);
2422
- }
2423
- return;
2424
- }
2425
- }
2426
-
2427
- if (code === CODE_SEMICOLON) {
2428
- endExpression();
2429
- endAttribute();
2430
- if(isConcise) {
2431
- finishOpenTag();
2432
- beginCheckTrailingWhitespace(function(hasChar) {
2433
- if(hasChar) {
2434
- var code = hasChar.ch.charCodeAt(0);
2435
-
2436
- if(code === CODE_FORWARD_SLASH) {
2437
- if(parser.lookAheadFor('/')) {
2438
- beginLineComment();
2439
- parser.skip(1);
2440
- return;
2441
- } else if(parser.lookAheadFor('*')) {
2442
- beginBlockComment();
2443
- parser.skip(1);
2444
- return;
2445
- }
2446
- } else if (code === CODE_OPEN_ANGLE_BRACKET && parser.lookAheadFor('!--')) {
2447
- // html comment
2448
- beginHtmlComment();
2449
- parser.skip(3);
2450
- return;
2451
- }
2452
-
2453
- notifyError(parser.pos,
2454
- 'INVALID_CODE_AFTER_SEMICOLON',
2455
- 'A semicolon indicates the end of a line. Only comments may follow it.');
2456
- }
2457
- });
2458
- }
2459
- return;
2460
- }
2461
-
2462
- if (code === CODE_COMMA || isWhitespaceCode(code)) {
2463
- if (code === CODE_COMMA || lookPastWhitespaceFor(',')) {
2464
- if(code !== CODE_COMMA) {
2465
- consumeWhitespace();
2466
- parser.skip(1);
2467
- }
2468
-
2469
- currentPart.endedWithComma = true;
2470
- } else if (currentPart.parentState === STATE_ATTRIBUTE_NAME && lookPastWhitespaceFor('=')) {
2471
- consumeWhitespace();
2472
- return;
2473
- } else if (parentState !== STATE_TAG_NAME) {
2474
- var typeofExpression = checkForTypeofOperator();
2475
- if (typeofExpression) {
2476
- currentPart.value += typeofExpression;
2477
- currentPart.isStringLiteral = false;
2478
- currentPart.hasUnenclosedWhitespace = true;
2479
- parser.skip(typeofExpression.length-1);
2480
- return;
2481
- }
2482
-
2483
- var prevPos = parser.pos;
2484
- var operator = checkForOperator();
2485
-
2486
- if (parser.src[parser.pos] === ":" && parser.src[parser.pos+1] === "=") {
2487
- currentPart.endPos = prevPos;
2488
- endExpression();
2489
- if (parentState === STATE_ATTRIBUTE_NAME) {
2490
- parser.skip(1);
2491
- parser.enterState(STATE_ATTRIBUTE_VALUE);
2492
- currentAttribute.bound = true;
2493
- consumeWhitespace();
2494
- } else {
2495
- parser.rewind(1);
2496
- beginAttribute();
2497
- }
2498
- return;
2499
- }
2500
-
2501
- if (operator) {
2502
- currentPart.isStringLiteral = false;
2503
- currentPart.hasUnenclosedWhitespace = true;
2504
- currentPart.value += operator;
2505
- return;
2506
- }
2507
- }
2508
-
2509
- currentPart.endPos = parser.pos;
2510
- endExpression();
2511
- endAttribute();
2512
- if (parser.state !== STATE_WITHIN_OPEN_TAG) {
2513
- // Make sure we transition into parsing within the open tag
2514
- parser.enterState(STATE_WITHIN_OPEN_TAG);
2515
- }
2516
- return;
2517
- } else if ((code === CODE_EQUAL || (code === CODE_COLON && parser.lookAtCharCodeAhead(1) === CODE_EQUAL)) && parentState === STATE_ATTRIBUTE_NAME) {
2518
- currentPart.endPos = parser.pos;
2519
- endExpression();
2520
- // We encountered "=" which means we need to start reading
2521
- // the attribute value.
2522
-
2523
- if (code === CODE_COLON) {
2524
- parser.skip(1);
2525
- }
2526
- parser.enterState(STATE_ATTRIBUTE_VALUE);
2527
- if (code === CODE_COLON) {
2528
- currentAttribute.bound = true;
2529
- }
2530
- consumeWhitespace();
2531
- return;
2532
- }
2533
-
2534
- if (currentPart.value === '') {
2535
- let typeofExpression = checkForTypeofOperatorAtStart();
2536
- if (typeofExpression) {
2537
- currentPart.value += typeofExpression;
2538
- currentPart.isStringLiteral = false;
2539
- currentPart.hasUnenclosedWhitespace = true;
2540
- parser.skip(typeofExpression.length-1);
2541
- return;
2542
- }
2543
- }
2544
-
2545
- if (currentPart.parentState === STATE_TAG_PARAMS) {
2546
- if (code === CODE_PIPE) {
2547
- endExpression();
2548
- parser.rewind(1);
2549
- parser.enterState(STATE_TAG_PARAMS);
2550
- return;
2551
- }
2552
- }
2553
-
2554
- if (currentPart.parentState === STATE_TAG_VAR) {
2555
- if (code === CODE_EQUAL || (code === CODE_COLON && parser.lookAtCharCodeAhead(1) === CODE_EQUAL) || code === CODE_CLOSE_ANGLE_BRACKET) {
2556
- endExpression();
2557
- parser.rewind(1);
2558
- if (parser.state !== STATE_WITHIN_OPEN_TAG) {
2559
- // Make sure we transition into parsing within the open tag
2560
- parser.enterState(STATE_WITHIN_OPEN_TAG);
2561
- }
2562
- return;
2563
- }
2564
- }
2565
-
2566
- if (currentPart.parentState === STATE_TAG_NAME) {
2567
- if (checkForEscapedEscapedPlaceholder(ch, code)) {
2568
- currentPart.value += '\\';
2569
- parser.skip(1);
2570
- return;
2571
- } else if (checkForEscapedPlaceholder(ch, code)) {
2572
- currentPart.value += '$';
2573
- parser.skip(1);
2574
- return;
2575
- } else if (code === CODE_DOLLAR && parser.lookAtCharCodeAhead(1) === CODE_OPEN_CURLY_BRACE) {
2576
- currentPart.endPos = parser.pos;
2577
- endExpression();
2578
- // We expect to start a placeholder at the first curly brace (the next character)
2579
- beginPlaceholder(true, true /* tag name */);
2580
- return;
2581
- } else if (code === CODE_PERIOD || code === CODE_NUMBER_SIGN) {
2582
- endExpression();
2583
- parser.rewind(1);
2584
- beginTagNameShorthand();
2585
- return;
2586
- } else if (code === CODE_FORWARD_SLASH) {
2587
- endExpression();
2588
- parser.rewind(1);
2589
- parser.enterState(STATE_TAG_VAR);
2590
- return;
2591
- }
2592
- }
2593
-
2594
- if (currentPart.parentState === STATE_TAG_NAME || currentPart.parentState === STATE_TAG_VAR) {
2595
- if (code === CODE_PIPE) {
2596
- endExpression();
2597
- parser.rewind(1);
2598
- parser.enterState(STATE_TAG_PARAMS);
2599
- return;
2600
- } else if (code === CODE_EQUAL || (code === CODE_COLON && parser.lookAtCharCodeAhead(1) === CODE_EQUAL)) {
2601
- endExpression();
2602
- parser.rewind(1);
2603
- parser.enterState(STATE_WITHIN_OPEN_TAG);
2604
- return;
2605
- } else if (
2606
- parser.lookAtCharCodeAhead(1) === CODE_OPEN_PAREN &&
2607
- (currentPart.parentState === STATE_TAG_NAME || currentPart.value)
2608
- ) {
2609
- currentPart.value += ch;
2610
- endExpression();
2611
- parser.enterState(STATE_TAG_ARGS);
2612
- return;
2613
- }
2614
- }
2615
- }
2616
-
2617
- // If we got here then we didn't find a string part so we know
2618
- // the current expression is not a string literal
2619
- currentPart.isStringLiteral = false;
2620
- currentPart.value += ch;
2621
- }
2622
- });
2623
-
2624
- var STATE_TAG_NAME_SHORTHAND = Parser.createState({
2625
- name: 'STATE_TAG_NAME_SHORTHAND',
2626
-
2627
- placeholder(placeholder) {
2628
- var shorthand = currentPart;
2629
- shorthand.currentPart.addPlaceholder(placeholder);
2630
- },
2631
-
2632
- eol(str) {
2633
- currentOpenTag.tagNameEnd = parser.pos;
2634
- endTagNameShorthand();
2635
-
2636
- if (parser.state !== STATE_WITHIN_OPEN_TAG) {
2637
- // Make sure we transition into parsing within the open tag
2638
- parser.enterState(STATE_WITHIN_OPEN_TAG);
2639
- }
2640
-
2641
- if (isConcise) {
2642
- openTagEOL();
2643
- }
2644
- },
2645
-
2646
- eof() {
2647
- endTagNameShorthand();
2648
-
2649
- if (isConcise) {
2650
- openTagEOF();
2651
- } else {
2652
- return notifyError(currentPart.pos,
2653
- 'INVALID_TAG_SHORTHAND',
2654
- 'EOF reached will parsing id/class shorthand in tag name');
2655
- }
2656
- },
2657
-
2658
- char(ch, code) {
2659
- var shorthand = currentPart;
2660
- if (!isConcise) {
2661
- if (code === CODE_CLOSE_ANGLE_BRACKET || code === CODE_FORWARD_SLASH) {
2662
- currentOpenTag.tagNameEnd = parser.pos;
2663
- endTagNameShorthand();
2664
- parser.rewind(1);
2665
- return;
2666
- }
2667
- }
2668
-
2669
- if (isWhitespaceCode(code)) {
2670
- endTagNameShorthand();
2671
- currentOpenTag.tagNameEnd = parser.pos;
2672
- if (parser.state !== STATE_WITHIN_OPEN_TAG) {
2673
- parser.enterState(STATE_WITHIN_OPEN_TAG);
2674
- }
2675
- return;
2676
- }
2677
-
2678
- if (code === CODE_PERIOD) {
2679
- if (shorthand.currentPart) {
2680
- shorthand.currentPart.end();
2681
- }
2682
-
2683
- shorthand.beginPart('class');
2684
- } else if (code === CODE_NUMBER_SIGN) {
2685
- if (shorthand.hasId) {
2686
- return notifyError(currentPart.pos,
2687
- 'INVALID_TAG_SHORTHAND',
2688
- 'Multiple shorthand ID parts are not allowed on the same tag');
2689
- }
2690
-
2691
- shorthand.hasId = true;
2692
-
2693
- if (shorthand.currentPart) {
2694
- shorthand.currentPart.end();
2695
- }
2696
-
2697
- shorthand.beginPart('id');
2698
- }
2699
-
2700
- else if (!ignorePlaceholders && checkForEscapedEscapedPlaceholder(ch, code)) {
2701
- shorthand.currentPart.text += '\\';
2702
- parser.skip(1);
2703
- } else if (!ignorePlaceholders && checkForEscapedPlaceholder(ch, code)) {
2704
- shorthand.currentPart.text += '$';
2705
- parser.skip(1);
2706
- } else if (!ignorePlaceholders && checkForPlaceholder(ch, code)) {
2707
- // We went into placeholder state...
2708
- } else if (code === CODE_OPEN_PAREN) {
2709
- endTagNameShorthand();
2710
- parser.rewind(1);
2711
- parser.enterState(STATE_TAG_ARGS);
2712
- } else if (code === CODE_PIPE) {
2713
- endTagNameShorthand();
2714
- parser.rewind(1);
2715
- parser.enterState(STATE_TAG_PARAMS);
2716
- } else {
2717
- shorthand.currentPart.text += ch;
2718
- }
2719
- }
2720
- });
2721
-
2722
- // We enter STATE_WITHIN_OPEN_TAG after we have fully
2723
- // read in the tag name and encountered a whitespace character
2724
- var STATE_AFTER_PLACEHOLDER_WITHIN_TAG = Parser.createState({
2725
- name: 'STATE_AFTER_PLACEHOLDER_WITHIN_TAG',
2726
-
2727
- eol: openTagEOL,
2728
-
2729
- eof: openTagEOF,
2730
-
2731
- char(ch, code) {
2732
-
2733
- if (!isConcise) {
2734
- if (code === CODE_CLOSE_ANGLE_BRACKET) {
2735
- finishOpenTag();
2736
- return;
2737
- } else if (code === CODE_FORWARD_SLASH) {
2738
- let nextCode = parser.lookAtCharCodeAhead(1);
2739
- if (nextCode === CODE_CLOSE_ANGLE_BRACKET) {
2740
- finishOpenTag(true /* self closed */);
2741
- parser.skip(1);
2742
- return;
2743
- }
2744
- }
2745
- }
2746
-
2747
- if (isWhitespaceCode(code)) {
2748
- parser.enterState(STATE_WITHIN_OPEN_TAG);
2749
- } else {
2750
- notifyError(parser.pos,
2751
- 'UNEXPECTED_TEXT_AFTER_PLACEHOLDER_IN_TAG',
2752
- `An unexpected "${ch}" character was found after a placeoholder within the open tag.`);
2753
- return;
2754
- }
2755
- }
2756
- });
2757
-
2758
- var STATE_PLACEHOLDER = Parser.createState({
2759
- name: 'STATE_PLACEHOLDER',
2760
-
2761
- expression(expression) {
2762
- currentPart.value = expression.value.slice(1, -1); // Chop off the curly braces
2763
- currentPart.endPos = expression.endPos;
2764
- endPlaceholder();
2765
- },
2766
-
2767
- eol(str) {
2768
- throw new Error('Illegal state. EOL not expected');
2769
- },
2770
-
2771
- eof() {
2772
- throw new Error('Illegal state. EOF not expected');
2773
- },
2774
-
2775
- enter(oldState) {
2776
- if (oldState !== STATE_EXPRESSION) {
2777
- beginExpression();
2778
- }
2779
- }
2780
- });
2781
-
2782
- var STATE_STRING = Parser.createState({
2783
- name: 'STATE_STRING',
2784
-
2785
- placeholder(placeholder) {
2786
- if (currentPart.currentText) {
2787
- currentPart.stringParts.push(currentPart.currentText);
2788
- currentPart.currentText = '';
2789
- }
2790
- currentPart.isStringLiteral = false;
2791
- currentPart.stringParts.push(placeholder);
2792
- },
2793
-
2794
- eol(str) {
2795
- // New line characters are not allowed in JavaScript string expressions. We need to use
2796
- // a different character sequence, but we don't want to through off positions so we need
2797
- // to use a replacement sequence with the same number of characters.
2798
- if (str.length === 2) {
2799
- currentPart.currentText += '\\r\\n';
2800
- } else {
2801
- currentPart.currentText += '\\n';
2802
- }
2803
-
2804
- },
2805
-
2806
- eof() {
2807
- if (placeholderDepth > 0) {
2808
- notifyError(parser.pos,
2809
- 'INVALID_STRING',
2810
- 'EOF reached while parsing string expression found inside placeholder');
2811
- return;
2812
- }
2813
- notifyError(parser.pos,
2814
- 'INVALID_STRING',
2815
- 'EOF reached while parsing string expression');
2816
- },
2817
-
2818
- char(ch, code) {
2819
- var stringParts = currentPart.stringParts;
2820
-
2821
- var nextCh;
2822
- var quoteCharCode = currentPart.quoteCharCode;
2823
-
2824
- if (code === CODE_BACK_SLASH) {
2825
- if (checkForEscapedEscapedPlaceholder(ch, code)) {
2826
- if (ignorePlaceholders) {
2827
- // We are actually adding two escaped backslashes here...
2828
- currentPart.currentText += '\\\\\\\\';
2829
- } else {
2830
- currentPart.currentText += '\\';
2831
- }
2832
- } else if (checkForEscapedPlaceholder(ch, code)) {
2833
- if (ignorePlaceholders) {
2834
- // We are actually adding one escaped backslashes here...
2835
- currentPart.currentText += '\\\\$';
2836
- } else {
2837
- currentPart.currentText += '$';
2838
- }
2839
- } else {
2840
- // Handle string escape sequence
2841
- nextCh = parser.lookAtCharAhead(1);
2842
- currentPart.currentText += ch + nextCh;
2843
- }
2844
-
2845
- parser.skip(1);
2846
- } else if (code === quoteCharCode) {
2847
- // We encountered the end delimiter
2848
- if (currentPart.currentText) {
2849
- stringParts.push(currentPart.currentText);
2850
- }
2851
-
2852
- let stringExpr = '';
2853
- let quoteChar = currentPart.quoteChar;
2854
-
2855
- if (stringParts.length) {
2856
- for (let i=0; i<stringParts.length; i++) {
2857
- let part = stringParts[i];
2858
- if (i !== 0) {
2859
- stringExpr += '+';
2860
- }
2861
-
2862
- if (typeof part === 'string') {
2863
- stringExpr += quoteChar + part + quoteChar;
2864
- } else {
2865
- stringExpr += '(' + part.value + ')';
2866
- }
2867
- }
2868
- } else {
2869
- // Just an empty string...
2870
- stringExpr = quoteChar + quoteChar;
2871
- }
2872
-
2873
- if (stringParts.length > 1) {
2874
- stringExpr = '(' + stringExpr + ')';
2875
- }
2876
-
2877
- currentPart.value = stringExpr;
2878
- endString();
2879
- } else if (!ignorePlaceholders && !ignoreNonstandardStringPlaceholders && checkForPlaceholder(ch, code)) {
2880
- if (currentPart.currentText) {
2881
- stringParts.push(currentPart.currentText);
2882
- }
2883
-
2884
- currentPart.currentText = '';
2885
- // We encountered nested placeholder...
2886
- currentPart.isStringLiteral = false;
2887
- } else {
2888
- currentPart.currentText += ch;
2889
- }
2890
- }
2891
- });
2892
-
2893
- var STATE_TEMPLATE_STRING = Parser.createState({
2894
- name: 'STATE_TEMPLATE_STRING',
2895
-
2896
- placeholder: function(placeholder) {
2897
- currentPart.value += '${' + placeholder.value + '}';
2898
- },
2899
-
2900
- eol(str) {
2901
- currentPart.value += str;
2902
- },
2903
-
2904
- eof() {
2905
- notifyError(parser.pos,
2906
- 'INVALID_TEMPLATE_STRING',
2907
- 'EOF reached while parsing template string expression');
2908
- },
2909
-
2910
- char(ch, code) {
2911
- var nextCh;
2912
- if (code === CODE_DOLLAR && parser.lookAtCharCodeAhead(1) === CODE_OPEN_CURLY_BRACE) {
2913
- beginPlaceholder(false);
2914
- } else {
2915
- currentPart.value += ch;
2916
- if (code === CODE_BACK_SLASH) {
2917
- // Handle string escape sequence
2918
- nextCh = parser.lookAtCharAhead(1);
2919
- parser.skip(1);
2920
-
2921
- currentPart.value += nextCh;
2922
- } else if (code === CODE_BACKTICK) {
2923
- endTemplateString();
2924
- }
2925
- }
2926
- }
2927
- });
2928
-
2929
- var STATE_REGULAR_EXPRESSION = Parser.createState({
2930
- name: 'STATE_REGULAR_EXPRESSION',
2931
-
2932
- eol() {
2933
- notifyError(parser.pos,
2934
- 'INVALID_REGULAR_EXPRESSION',
2935
- 'EOL reached while parsing regular expression');
2936
- },
2937
-
2938
- eof() {
2939
- notifyError(parser.pos,
2940
- 'INVALID_REGULAR_EXPRESSION',
2941
- 'EOF reached while parsing regular expression');
2942
- },
2943
-
2944
- char(ch, code) {
2945
- var nextCh;
2946
- currentPart.value += ch;
2947
- if (code === CODE_BACK_SLASH) {
2948
- // Handle escape sequence
2949
- nextCh = parser.lookAtCharAhead(1);
2950
- parser.skip(1);
2951
- currentPart.value += nextCh;
2952
- } else if (code === CODE_OPEN_SQUARE_BRACKET && currentPart.inCharacterSet) {
2953
- currentPart.inCharacterSet = true;
2954
- } else if (code === CODE_CLOSE_SQUARE_BRACKET && currentPart.inCharacterSet) {
2955
- currentPart.inCharacterSet = false;
2956
- } else if (code === CODE_FORWARD_SLASH && !currentPart.inCharacterSet) {
2957
- endRegularExpression();
2958
- }
2959
- }
2960
- });
2961
-
2962
- // We enter STATE_JS_COMMENT_BLOCK after we encounter a "/*" sequence
2963
- // while in STATE_ATTRIBUTE_VALUE or STATE_DELIMITED_EXPRESSION.
2964
- // We leave STATE_JS_COMMENT_BLOCK when we see a "*/" sequence.
2965
- var STATE_JS_COMMENT_BLOCK = Parser.createState({
2966
- name: 'STATE_JS_COMMENT_BLOCK',
2967
-
2968
- eol(str) {
2969
- currentPart.value += str;
2970
- },
2971
-
2972
- eof() {
2973
- notifyError(currentPart.pos,
2974
- 'MALFORMED_COMMENT',
2975
- 'EOF reached while parsing multi-line JavaScript comment');
2976
- },
2977
-
2978
- char(ch, code) {
2979
- if (code === CODE_ASTERISK) {
2980
- var nextCode = parser.lookAtCharCodeAhead(1);
2981
- if (nextCode === CODE_FORWARD_SLASH) {
2982
- currentPart.endPos = parser.pos + 2;
2983
- endJavaScriptComment();
2984
- parser.skip(1);
2985
- return;
2986
- }
2987
- }
2988
-
2989
- currentPart.value += ch;
2990
- }
2991
- });
2992
-
2993
- // We enter STATE_JS_COMMENT_LINE after we encounter a "//" sequence
2994
- // when parsing JavaScript code.
2995
- // We leave STATE_JS_COMMENT_LINE when we see a newline character.
2996
- var STATE_JS_COMMENT_LINE = Parser.createState({
2997
- name: 'STATE_JS_COMMENT_LINE',
2998
-
2999
- eol(str) {
3000
- parser.rewind(str.length);
3001
- currentPart.endPos = parser.pos;
3002
- endJavaScriptComment();
3003
- },
3004
-
3005
- eof() {
3006
- currentPart.endPos = parser.pos;
3007
- endJavaScriptComment();
3008
- },
3009
-
3010
- char(ch, code) {
3011
- if (currentPart.parentState === STATE_PARSED_TEXT_CONTENT) {
3012
- if (!isConcise && code === CODE_OPEN_ANGLE_BRACKET) {
3013
- // First, see if we need to see if we reached the closing tag
3014
- // and then check if we encountered CDATA
3015
- if (checkForClosingTag()) {
3016
- return;
3017
- }
3018
- }
3019
- }
3020
-
3021
- currentPart.value += ch;
3022
- }
3023
- });
3024
-
3025
- // We enter STATE_DTD after we encounter a "<!" while in the STATE_HTML_CONTENT.
3026
- // We leave STATE_DTD if we see a ">".
3027
- var STATE_DTD = Parser.createState({
3028
- name: 'STATE_DTD',
3029
-
3030
- eol(str) {
3031
- currentPart.value += str;
3032
- },
3033
-
3034
- eof() {
3035
- notifyError(currentPart.pos,
3036
- 'MALFORMED_DOCUMENT_TYPE',
3037
- 'EOF reached while parsing document type');
3038
- },
3039
-
3040
- char(ch, code) {
3041
- if (code === CODE_CLOSE_ANGLE_BRACKET) {
3042
- currentPart.endPos = parser.pos + 1;
3043
- endDocumentType();
3044
- } else {
3045
- currentPart.value += ch;
3046
- }
3047
- }
3048
- });
3049
-
3050
- // We enter STATE_DECLARATION after we encounter a "<?"
3051
- // while in the STATE_HTML_CONTENT.
3052
- // We leave STATE_DECLARATION if we see a "?>" or ">".
3053
- var STATE_DECLARATION = Parser.createState({
3054
- name: 'STATE_DECLARATION',
3055
-
3056
- eol(str) {
3057
- currentPart.value += str;
3058
- },
3059
-
3060
- eof() {
3061
- notifyError(currentPart.pos,
3062
- 'MALFORMED_DECLARATION',
3063
- 'EOF reached while parsing declaration');
3064
- },
3065
-
3066
- char(ch, code) {
3067
- if (code === CODE_QUESTION) {
3068
- var nextCode = parser.lookAtCharCodeAhead(1);
3069
- if (nextCode === CODE_CLOSE_ANGLE_BRACKET) {
3070
- currentPart.endPos = parser.pos + 2;
3071
- endDeclaration();
3072
- parser.skip(1);
3073
- }
3074
- } else if (code === CODE_CLOSE_ANGLE_BRACKET) {
3075
- currentPart.endPos = parser.pos + 1;
3076
- endDeclaration();
3077
- } else {
3078
- currentPart.value += ch;
3079
- }
3080
- }
3081
- });
3082
-
3083
- // We enter STATE_HTML_COMMENT after we encounter a "<--"
3084
- // while in the STATE_HTML_CONTENT.
3085
- // We leave STATE_HTML_COMMENT when we see a "-->".
3086
- var STATE_HTML_COMMENT = Parser.createState({
3087
- name: 'STATE_HTML_COMMENT',
3088
-
3089
- eol(newLineChars) {
3090
- currentPart.value += newLineChars;
3091
- },
3092
-
3093
- eof() {
3094
- notifyError(currentPart.pos,
3095
- 'MALFORMED_COMMENT',
3096
- 'EOF reached while parsing comment');
3097
- },
3098
-
3099
- char(ch, code) {
3100
- if (code === CODE_HYPHEN) {
3101
- var match = parser.lookAheadFor('->');
3102
- if (match) {
3103
- currentPart.endPos = parser.pos + 3;
3104
- endHtmlComment();
3105
- parser.skip(match.length);
3106
- } else {
3107
- currentPart.value += ch;
3108
- }
3109
- } else {
3110
- currentPart.value += ch;
3111
- }
3112
- }
3113
- });
3114
-
3115
- // We enter STATE_SCRIPTLET after we encounter a "<%" while in STATE_HTML_CONTENT.
3116
- // We leave STATE_SCRIPTLET if we see a "%>".
3117
- var STATE_SCRIPTLET = Parser.createState({
3118
- name: 'STATE_SCRIPTLET',
3119
-
3120
- eol(str) {
3121
- currentPart.value += str;
3122
- },
3123
-
3124
- eof() {
3125
- notifyError(currentPart.pos,
3126
- 'MALFORMED_SCRIPTLET',
3127
- 'EOF reached while parsing scriptlet');
3128
- },
3129
-
3130
- comment(comment) {
3131
- currentPart.value += comment.rawValue;
3132
- },
3133
-
3134
- char(ch, code) {
3135
- if (currentPart.quoteCharCode) {
3136
- currentPart.value += ch;
3137
-
3138
- // We are within a string... only look for ending string code
3139
- if (code === CODE_BACK_SLASH) {
3140
- // Handle string escape sequence
3141
- currentPart.value += parser.lookAtCharAhead(1);
3142
- parser.skip(1);
3143
- } else if (code === currentPart.quoteCharCode) {
3144
- currentPart.quoteCharCode = null;
3145
- }
3146
- return;
3147
- } else if (code === CODE_FORWARD_SLASH) {
3148
- if (parser.lookAtCharCodeAhead(1) === CODE_ASTERISK) {
3149
- // Skip over code inside a JavaScript block comment
3150
- beginBlockComment();
3151
- parser.skip(1);
3152
- return;
3153
- }
3154
- } else if (code === CODE_SINGLE_QUOTE || code === CODE_DOUBLE_QUOTE) {
3155
- currentPart.quoteCharCode = code;
3156
- } else if (code === CODE_PERCENT) {
3157
- if (parser.lookAtCharCodeAhead(1) === CODE_CLOSE_ANGLE_BRACKET) {
3158
- endScriptlet(parser.pos + 2 /* end pos */);
3159
- parser.skip(1); // Skip over the closing right angle bracket
3160
- return;
3161
- }
3162
- }
3163
-
3164
- currentPart.value += ch;
3165
- }
3166
- });
3167
-
3168
- var STATE_INLINE_SCRIPT = Parser.createState({
3169
- name: 'STATE_INLINE_SCRIPT',
3170
-
3171
- eol(str) {
3172
- if (currentPart.endMatch || currentPart.stringType === CODE_BACKTICK) {
3173
- currentPart.value += str;
3174
- } else {
3175
- parser.rewind(str.length);
3176
- endInlineScript(parser.pos);
3177
- }
3178
- },
3179
-
3180
- eof() {
3181
- if (currentPart.endMatch || currentPart.stringType) {
3182
- notifyError(currentPart.pos,
3183
- 'MALFORMED_SCRIPTLET',
3184
- 'EOF reached while parsing scriptet');
3185
- } else {
3186
- endInlineScript(parser.pos);
3187
- }
3188
- },
3189
-
3190
- comment(comment) {
3191
- currentPart.value += comment.rawValue;
3192
- },
3193
-
3194
- char(ch, code) {
3195
- if (code === CODE_BACK_SLASH) {
3196
- currentPart.value += ch + parser.lookAtCharAhead(1);
3197
- parser.skip(1);
3198
- return;
3199
- }
3200
-
3201
- if (currentPart.stringType) {
3202
- if (code === currentPart.stringType) {
3203
- currentPart.stringType = null;
3204
- }
3205
-
3206
- currentPart.value += ch;
3207
- return;
3208
- }
3209
-
3210
- if (code === CODE_FORWARD_SLASH) {
3211
- // Check next character to see if we are in a comment
3212
- var nextCode = parser.lookAtCharCodeAhead(1);
3213
- if (nextCode === CODE_FORWARD_SLASH) {
3214
- beginLineComment();
3215
- parser.skip(1);
3216
- return;
3217
- } else if (nextCode === CODE_ASTERISK) {
3218
- beginBlockComment();
3219
- parser.skip(1);
3220
- return;
3221
- }
3222
- }
3223
-
3224
- currentPart.value += ch;
3225
-
3226
- if (code === currentPart.endMatch) {
3227
- currentPart.endMatch = currentPart.endMatches.pop();
3228
- return;
3229
- }
3230
-
3231
- if (code === CODE_SINGLE_QUOTE || code === CODE_DOUBLE_QUOTE || code === CODE_BACKTICK) {
3232
- currentPart.stringType = code;
3233
- return;
3234
- }
3235
-
3236
- var nextMatch = null;
3237
-
3238
- if (code === CODE_OPEN_PAREN) {
3239
- nextMatch = CODE_CLOSE_PAREN;
3240
- } else if (code === CODE_OPEN_CURLY_BRACE) {
3241
- nextMatch = CODE_CLOSE_CURLY_BRACE;
3242
- } else if (code === CODE_OPEN_SQUARE_BRACKET) {
3243
- nextMatch = CODE_CLOSE_SQUARE_BRACKET;
3244
- }
3245
-
3246
- if (nextMatch) {
3247
- if (currentPart.endMatch) {
3248
- currentPart.endMatches.push(currentPart.endMatch);
3249
- }
3250
- currentPart.endMatch = nextMatch;
3251
- }
3252
- }
3253
- });
3254
-
3255
- parser.enterHtmlContentState = function() {
3256
- if (parser.state !== STATE_HTML_CONTENT) {
3257
- parser.enterState(STATE_HTML_CONTENT);
3258
- }
3259
- };
3260
-
3261
- parser.enterConciseHtmlContentState = function() {
3262
- if (parser.state !== STATE_CONCISE_HTML_CONTENT) {
3263
- parser.enterState(STATE_CONCISE_HTML_CONTENT);
3264
- }
3265
- };
3266
-
3267
- parser.enterParsedTextContentState = function() {
3268
- var last = blockStack.length && blockStack[blockStack.length - 1];
3269
-
3270
- if (!last || !last.tagName) {
3271
- throw new Error('The "parsed text content" parser state is only allowed within a tag');
3272
- }
3273
-
3274
- if (isConcise) {
3275
- // We will transition into the STATE_PARSED_TEXT_CONTENT state
3276
- // for each of the nested HTML blocks
3277
- last.body = BODY_PARSED_TEXT;
3278
- parser.enterState(STATE_CONCISE_HTML_CONTENT);
3279
- } else {
3280
- parser.enterState(STATE_PARSED_TEXT_CONTENT);
3281
- }
3282
- };
3283
-
3284
- parser.enterJsContentState = parser.enterParsedTextContentState;
3285
- parser.enterCssContentState = parser.enterParsedTextContentState;
3286
-
3287
- parser.enterStaticTextContentState = function() {
3288
- var last = blockStack.length && blockStack[blockStack.length - 1];
3289
-
3290
- if (!last || !last.tagName) {
3291
- throw new Error('The "static text content" parser state is only allowed within a tag');
3292
- }
3293
-
3294
- if (isConcise) {
3295
- // We will transition into the STATE_STATIC_TEXT_CONTENT state
3296
- // for each of the nested HTML blocks
3297
- last.body = BODY_STATIC_TEXT;
3298
- parser.enterState(STATE_CONCISE_HTML_CONTENT);
3299
- } else {
3300
- parser.enterState(STATE_STATIC_TEXT_CONTENT);
3301
- }
3302
- };
3303
-
3304
-
3305
- if (defaultMode === MODE_CONCISE) {
3306
- parser.setInitialState(STATE_CONCISE_HTML_CONTENT);
3307
- parser.enterDefaultState = function() {
3308
- parser.enterState(STATE_CONCISE_HTML_CONTENT);
3309
- };
3310
- } else {
3311
- parser.setInitialState(STATE_HTML_CONTENT);
3312
- parser.enterDefaultState = function() {
3313
- parser.enterState(STATE_HTML_CONTENT);
3314
- };
3315
- }
3316
- }
3317
-
3318
- parse(data, filename) {
3319
- super.parse(data, filename);
3320
- this.notifiers.notifyFinish();
3321
- }
3322
- }
3323
-
3324
- module.exports = Parser;