@apify/docusaurus-plugin-typedoc-api 4.2.11-0 → 4.2.11-2

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 (349) hide show
  1. package/lib/components/AnchorLink.js.map +1 -0
  2. package/lib/components/ApiChangelog.js.map +1 -0
  3. package/lib/components/ApiDataContext.js.map +1 -0
  4. package/lib/components/ApiIndex.js.map +1 -0
  5. package/lib/{packages/plugin/src/components → components}/ApiItem.js +6 -1
  6. package/lib/components/ApiItem.js.map +1 -0
  7. package/lib/components/ApiItemLayout.js.map +1 -0
  8. package/lib/components/ApiOptionsLayout.js.map +1 -0
  9. package/lib/components/ApiPage.js.map +1 -0
  10. package/lib/components/Breadcrumb.js.map +1 -0
  11. package/lib/components/Comment.js.map +1 -0
  12. package/lib/components/CommentBadges.js.map +1 -0
  13. package/lib/components/DefaultValue.js.map +1 -0
  14. package/lib/components/Flags.js.map +1 -0
  15. package/lib/components/Footer.js.map +1 -0
  16. package/lib/components/Hierarchy.js.map +1 -0
  17. package/lib/components/Icon.js.map +1 -0
  18. package/lib/components/Index.js.map +1 -0
  19. package/lib/components/Markdown.js.map +1 -0
  20. package/lib/components/Member.js.map +1 -0
  21. package/lib/components/MemberDeclaration.js.map +1 -0
  22. package/lib/components/MemberGetterSetter.js.map +1 -0
  23. package/lib/components/MemberReference.js.map +1 -0
  24. package/lib/components/MemberSignatureBody.js.map +1 -0
  25. package/lib/components/MemberSignatureTitle.js.map +1 -0
  26. package/lib/components/MemberSignatures.js.map +1 -0
  27. package/lib/components/MemberSources.js.map +1 -0
  28. package/lib/components/Members.js.map +1 -0
  29. package/lib/components/MembersGroup.js.map +1 -0
  30. package/lib/components/Parameter.js.map +1 -0
  31. package/lib/components/Reflection.js.map +1 -0
  32. package/lib/components/SourceLink.js.map +1 -0
  33. package/lib/components/Type.js.map +1 -0
  34. package/lib/components/TypeAndParent.js.map +1 -0
  35. package/lib/components/TypeParameters.js.map +1 -0
  36. package/lib/components/TypeParametersGeneric.js.map +1 -0
  37. package/lib/components/VersionBanner.js.map +1 -0
  38. package/lib/hooks/useBreadcrumbs.js.map +1 -0
  39. package/lib/hooks/useGitRefName.js.map +1 -0
  40. package/lib/hooks/useMinimalLayout.js.map +1 -0
  41. package/lib/hooks/useReflection.js.map +1 -0
  42. package/lib/hooks/useReflectionMap.js.map +1 -0
  43. package/lib/index.js.map +1 -0
  44. package/lib/markdownLoader.js.map +1 -0
  45. package/lib/plugin/data.js.map +1 -0
  46. package/lib/plugin/python/consts.js.map +1 -0
  47. package/lib/{packages/plugin/src/plugin → plugin}/python/index.js +4 -1
  48. package/lib/plugin/python/index.js.map +1 -0
  49. package/lib/plugin/python/inheritance.js.map +1 -0
  50. package/lib/plugin/python/packageVersions.js.map +1 -0
  51. package/lib/plugin/python/transformation.js.map +1 -0
  52. package/lib/{packages/plugin/src/plugin → plugin}/python/type-parsing/index.js +1 -1
  53. package/lib/plugin/python/type-parsing/index.js.map +1 -0
  54. package/lib/plugin/python/utils.js.map +1 -0
  55. package/lib/plugin/sidebar.js.map +1 -0
  56. package/lib/plugin/structure/0.23.js.map +1 -0
  57. package/lib/plugin/url.js.map +1 -0
  58. package/lib/plugin/version.js.map +1 -0
  59. package/lib/utils/helpers.js.map +1 -0
  60. package/lib/utils/hierarchy.js.map +1 -0
  61. package/lib/utils/icons.js.map +1 -0
  62. package/lib/utils/links.js.map +1 -0
  63. package/lib/utils/markdown.js.map +1 -0
  64. package/lib/{packages/plugin/src/utils → utils}/reexports.js +8 -3
  65. package/lib/utils/reexports.js.map +1 -0
  66. package/lib/utils/visibility.js.map +1 -0
  67. package/package.json +4 -2
  68. package/src/components/ApiItem.tsx +25 -12
  69. package/src/plugin/python/index.ts +6 -2
  70. package/src/plugin/python/type-parsing/index.ts +1 -1
  71. package/src/utils/reexports.ts +7 -1
  72. package/lib/_virtual/_commonjsHelpers.js +0 -44
  73. package/lib/_virtual/_commonjsHelpers.js.map +0 -1
  74. package/lib/node_modules/boolbase/index.js +0 -18
  75. package/lib/node_modules/boolbase/index.js.map +0 -1
  76. package/lib/node_modules/cheerio/lib/esm/api/attributes.js +0 -568
  77. package/lib/node_modules/cheerio/lib/esm/api/attributes.js.map +0 -1
  78. package/lib/node_modules/cheerio/lib/esm/api/css.js +0 -113
  79. package/lib/node_modules/cheerio/lib/esm/api/css.js.map +0 -1
  80. package/lib/node_modules/cheerio/lib/esm/api/forms.js +0 -92
  81. package/lib/node_modules/cheerio/lib/esm/api/forms.js.map +0 -1
  82. package/lib/node_modules/cheerio/lib/esm/api/manipulation.js +0 -807
  83. package/lib/node_modules/cheerio/lib/esm/api/manipulation.js.map +0 -1
  84. package/lib/node_modules/cheerio/lib/esm/api/traversing.js +0 -842
  85. package/lib/node_modules/cheerio/lib/esm/api/traversing.js.map +0 -1
  86. package/lib/node_modules/cheerio/lib/esm/cheerio.js +0 -41
  87. package/lib/node_modules/cheerio/lib/esm/cheerio.js.map +0 -1
  88. package/lib/node_modules/cheerio/lib/esm/index.js +0 -112
  89. package/lib/node_modules/cheerio/lib/esm/index.js.map +0 -1
  90. package/lib/node_modules/cheerio/lib/esm/load.js +0 -110
  91. package/lib/node_modules/cheerio/lib/esm/load.js.map +0 -1
  92. package/lib/node_modules/cheerio/lib/esm/options.js +0 -32
  93. package/lib/node_modules/cheerio/lib/esm/options.js.map +0 -1
  94. package/lib/node_modules/cheerio/lib/esm/parse.js +0 -78
  95. package/lib/node_modules/cheerio/lib/esm/parse.js.map +0 -1
  96. package/lib/node_modules/cheerio/lib/esm/parsers/parse5-adapter.js +0 -57
  97. package/lib/node_modules/cheerio/lib/esm/parsers/parse5-adapter.js.map +0 -1
  98. package/lib/node_modules/cheerio/lib/esm/static.js +0 -191
  99. package/lib/node_modules/cheerio/lib/esm/static.js.map +0 -1
  100. package/lib/node_modules/cheerio/lib/esm/utils.js +0 -105
  101. package/lib/node_modules/cheerio/lib/esm/utils.js.map +0 -1
  102. package/lib/node_modules/cheerio/node_modules/htmlparser2/lib/esm/Parser.js +0 -381
  103. package/lib/node_modules/cheerio/node_modules/htmlparser2/lib/esm/Parser.js.map +0 -1
  104. package/lib/node_modules/cheerio/node_modules/htmlparser2/lib/esm/Tokenizer.js +0 -888
  105. package/lib/node_modules/cheerio/node_modules/htmlparser2/lib/esm/Tokenizer.js.map +0 -1
  106. package/lib/node_modules/cheerio/node_modules/htmlparser2/lib/esm/index.js +0 -69
  107. package/lib/node_modules/cheerio/node_modules/htmlparser2/lib/esm/index.js.map +0 -1
  108. package/lib/node_modules/cheerio-select/lib/esm/helpers.js +0 -22
  109. package/lib/node_modules/cheerio-select/lib/esm/helpers.js.map +0 -1
  110. package/lib/node_modules/cheerio-select/lib/esm/index.js +0 -252
  111. package/lib/node_modules/cheerio-select/lib/esm/index.js.map +0 -1
  112. package/lib/node_modules/cheerio-select/lib/esm/positionals.js +0 -37
  113. package/lib/node_modules/cheerio-select/lib/esm/positionals.js.map +0 -1
  114. package/lib/node_modules/css-select/lib/esm/attributes.js +0 -155
  115. package/lib/node_modules/css-select/lib/esm/attributes.js.map +0 -1
  116. package/lib/node_modules/css-select/lib/esm/compile.js +0 -118
  117. package/lib/node_modules/css-select/lib/esm/compile.js.map +0 -1
  118. package/lib/node_modules/css-select/lib/esm/general.js +0 -155
  119. package/lib/node_modules/css-select/lib/esm/general.js.map +0 -1
  120. package/lib/node_modules/css-select/lib/esm/index.js +0 -115
  121. package/lib/node_modules/css-select/lib/esm/index.js.map +0 -1
  122. package/lib/node_modules/css-select/lib/esm/pseudo-selectors/aliases.js +0 -38
  123. package/lib/node_modules/css-select/lib/esm/pseudo-selectors/aliases.js.map +0 -1
  124. package/lib/node_modules/css-select/lib/esm/pseudo-selectors/filters.js +0 -151
  125. package/lib/node_modules/css-select/lib/esm/pseudo-selectors/filters.js.map +0 -1
  126. package/lib/node_modules/css-select/lib/esm/pseudo-selectors/index.js +0 -47
  127. package/lib/node_modules/css-select/lib/esm/pseudo-selectors/index.js.map +0 -1
  128. package/lib/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.js +0 -88
  129. package/lib/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.js.map +0 -1
  130. package/lib/node_modules/css-select/lib/esm/pseudo-selectors/subselects.js +0 -85
  131. package/lib/node_modules/css-select/lib/esm/pseudo-selectors/subselects.js.map +0 -1
  132. package/lib/node_modules/css-select/lib/esm/sort.js +0 -70
  133. package/lib/node_modules/css-select/lib/esm/sort.js.map +0 -1
  134. package/lib/node_modules/css-what/lib/es/index.js +0 -18
  135. package/lib/node_modules/css-what/lib/es/index.js.map +0 -1
  136. package/lib/node_modules/css-what/lib/es/parse.js +0 -397
  137. package/lib/node_modules/css-what/lib/es/parse.js.map +0 -1
  138. package/lib/node_modules/css-what/lib/es/stringify.js +0 -95
  139. package/lib/node_modules/css-what/lib/es/stringify.js.map +0 -1
  140. package/lib/node_modules/css-what/lib/es/types.js +0 -43
  141. package/lib/node_modules/css-what/lib/es/types.js.map +0 -1
  142. package/lib/node_modules/dom-serializer/lib/esm/foreignNames.js +0 -7
  143. package/lib/node_modules/dom-serializer/lib/esm/foreignNames.js.map +0 -1
  144. package/lib/node_modules/dom-serializer/lib/esm/index.js +0 -146
  145. package/lib/node_modules/dom-serializer/lib/esm/index.js.map +0 -1
  146. package/lib/node_modules/domelementtype/lib/esm/index.js +0 -62
  147. package/lib/node_modules/domelementtype/lib/esm/index.js.map +0 -1
  148. package/lib/node_modules/domhandler/lib/esm/index.js +0 -166
  149. package/lib/node_modules/domhandler/lib/esm/index.js.map +0 -1
  150. package/lib/node_modules/domhandler/lib/esm/node.js +0 -352
  151. package/lib/node_modules/domhandler/lib/esm/node.js.map +0 -1
  152. package/lib/node_modules/domutils/lib/esm/feeds.js +0 -176
  153. package/lib/node_modules/domutils/lib/esm/feeds.js.map +0 -1
  154. package/lib/node_modules/domutils/lib/esm/helpers.js +0 -142
  155. package/lib/node_modules/domutils/lib/esm/helpers.js.map +0 -1
  156. package/lib/node_modules/domutils/lib/esm/index.js +0 -56
  157. package/lib/node_modules/domutils/lib/esm/index.js.map +0 -1
  158. package/lib/node_modules/domutils/lib/esm/legacy.js +0 -144
  159. package/lib/node_modules/domutils/lib/esm/legacy.js.map +0 -1
  160. package/lib/node_modules/domutils/lib/esm/manipulation.js +0 -137
  161. package/lib/node_modules/domutils/lib/esm/manipulation.js.map +0 -1
  162. package/lib/node_modules/domutils/lib/esm/querying.js +0 -149
  163. package/lib/node_modules/domutils/lib/esm/querying.js.map +0 -1
  164. package/lib/node_modules/domutils/lib/esm/stringify.js +0 -80
  165. package/lib/node_modules/domutils/lib/esm/stringify.js.map +0 -1
  166. package/lib/node_modules/domutils/lib/esm/traversal.js +0 -128
  167. package/lib/node_modules/domutils/lib/esm/traversal.js.map +0 -1
  168. package/lib/node_modules/entities/lib/esm/decode.js +0 -495
  169. package/lib/node_modules/entities/lib/esm/decode.js.map +0 -1
  170. package/lib/node_modules/entities/lib/esm/decode_codepoint.js +0 -52
  171. package/lib/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
  172. package/lib/node_modules/entities/lib/esm/encode.js +0 -68
  173. package/lib/node_modules/entities/lib/esm/encode.js.map +0 -1
  174. package/lib/node_modules/entities/lib/esm/escape.js +0 -103
  175. package/lib/node_modules/entities/lib/esm/escape.js.map +0 -1
  176. package/lib/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -8
  177. package/lib/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
  178. package/lib/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -8
  179. package/lib/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
  180. package/lib/node_modules/entities/lib/esm/generated/encode-html.js +0 -264
  181. package/lib/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
  182. package/lib/node_modules/entities/lib/esm/index.js +0 -122
  183. package/lib/node_modules/entities/lib/esm/index.js.map +0 -1
  184. package/lib/node_modules/nth-check/lib/esm/compile.js +0 -111
  185. package/lib/node_modules/nth-check/lib/esm/compile.js.map +0 -1
  186. package/lib/node_modules/nth-check/lib/esm/index.js +0 -73
  187. package/lib/node_modules/nth-check/lib/esm/index.js.map +0 -1
  188. package/lib/node_modules/nth-check/lib/esm/parse.js +0 -71
  189. package/lib/node_modules/nth-check/lib/esm/parse.js.map +0 -1
  190. package/lib/node_modules/parse5/dist/common/doctype.js +0 -49
  191. package/lib/node_modules/parse5/dist/common/doctype.js.map +0 -1
  192. package/lib/node_modules/parse5/dist/common/error-codes.js +0 -66
  193. package/lib/node_modules/parse5/dist/common/error-codes.js.map +0 -1
  194. package/lib/node_modules/parse5/dist/common/foreign-content.js +0 -134
  195. package/lib/node_modules/parse5/dist/common/foreign-content.js.map +0 -1
  196. package/lib/node_modules/parse5/dist/common/html.js +0 -316
  197. package/lib/node_modules/parse5/dist/common/html.js.map +0 -1
  198. package/lib/node_modules/parse5/dist/common/token.js +0 -24
  199. package/lib/node_modules/parse5/dist/common/token.js.map +0 -1
  200. package/lib/node_modules/parse5/dist/common/unicode.js +0 -72
  201. package/lib/node_modules/parse5/dist/common/unicode.js.map +0 -1
  202. package/lib/node_modules/parse5/dist/index.js +0 -58
  203. package/lib/node_modules/parse5/dist/index.js.map +0 -1
  204. package/lib/node_modules/parse5/dist/parser/formatting-element-list.js +0 -115
  205. package/lib/node_modules/parse5/dist/parser/formatting-element-list.js.map +0 -1
  206. package/lib/node_modules/parse5/dist/parser/index.js +0 -3387
  207. package/lib/node_modules/parse5/dist/parser/index.js.map +0 -1
  208. package/lib/node_modules/parse5/dist/parser/open-element-stack.js +0 -286
  209. package/lib/node_modules/parse5/dist/parser/open-element-stack.js.map +0 -1
  210. package/lib/node_modules/parse5/dist/serializer/index.js +0 -160
  211. package/lib/node_modules/parse5/dist/serializer/index.js.map +0 -1
  212. package/lib/node_modules/parse5/dist/tokenizer/index.js +0 -3142
  213. package/lib/node_modules/parse5/dist/tokenizer/index.js.map +0 -1
  214. package/lib/node_modules/parse5/dist/tokenizer/preprocessor.js +0 -195
  215. package/lib/node_modules/parse5/dist/tokenizer/preprocessor.js.map +0 -1
  216. package/lib/node_modules/parse5/dist/tree-adapters/default.js +0 -180
  217. package/lib/node_modules/parse5/dist/tree-adapters/default.js.map +0 -1
  218. package/lib/node_modules/parse5-htmlparser2-tree-adapter/dist/index.js +0 -218
  219. package/lib/node_modules/parse5-htmlparser2-tree-adapter/dist/index.js.map +0 -1
  220. package/lib/packages/plugin/src/components/AnchorLink.js.map +0 -1
  221. package/lib/packages/plugin/src/components/ApiChangelog.js.map +0 -1
  222. package/lib/packages/plugin/src/components/ApiDataContext.js.map +0 -1
  223. package/lib/packages/plugin/src/components/ApiIndex.js.map +0 -1
  224. package/lib/packages/plugin/src/components/ApiItem.js.map +0 -1
  225. package/lib/packages/plugin/src/components/ApiItemLayout.js.map +0 -1
  226. package/lib/packages/plugin/src/components/ApiOptionsLayout.js.map +0 -1
  227. package/lib/packages/plugin/src/components/ApiPage.js.map +0 -1
  228. package/lib/packages/plugin/src/components/Breadcrumb.js.map +0 -1
  229. package/lib/packages/plugin/src/components/Comment.js.map +0 -1
  230. package/lib/packages/plugin/src/components/CommentBadges.js.map +0 -1
  231. package/lib/packages/plugin/src/components/DefaultValue.js.map +0 -1
  232. package/lib/packages/plugin/src/components/Flags.js.map +0 -1
  233. package/lib/packages/plugin/src/components/Footer.js.map +0 -1
  234. package/lib/packages/plugin/src/components/Hierarchy.js.map +0 -1
  235. package/lib/packages/plugin/src/components/Icon.js.map +0 -1
  236. package/lib/packages/plugin/src/components/Index.js.map +0 -1
  237. package/lib/packages/plugin/src/components/Markdown.js.map +0 -1
  238. package/lib/packages/plugin/src/components/Member.js.map +0 -1
  239. package/lib/packages/plugin/src/components/MemberDeclaration.js.map +0 -1
  240. package/lib/packages/plugin/src/components/MemberGetterSetter.js.map +0 -1
  241. package/lib/packages/plugin/src/components/MemberReference.js.map +0 -1
  242. package/lib/packages/plugin/src/components/MemberSignatureBody.js.map +0 -1
  243. package/lib/packages/plugin/src/components/MemberSignatureTitle.js.map +0 -1
  244. package/lib/packages/plugin/src/components/MemberSignatures.js.map +0 -1
  245. package/lib/packages/plugin/src/components/MemberSources.js.map +0 -1
  246. package/lib/packages/plugin/src/components/Members.js.map +0 -1
  247. package/lib/packages/plugin/src/components/MembersGroup.js.map +0 -1
  248. package/lib/packages/plugin/src/components/Parameter.js.map +0 -1
  249. package/lib/packages/plugin/src/components/Reflection.js.map +0 -1
  250. package/lib/packages/plugin/src/components/SourceLink.js.map +0 -1
  251. package/lib/packages/plugin/src/components/Type.js.map +0 -1
  252. package/lib/packages/plugin/src/components/TypeAndParent.js.map +0 -1
  253. package/lib/packages/plugin/src/components/TypeParameters.js.map +0 -1
  254. package/lib/packages/plugin/src/components/TypeParametersGeneric.js.map +0 -1
  255. package/lib/packages/plugin/src/components/VersionBanner.js.map +0 -1
  256. package/lib/packages/plugin/src/hooks/useBreadcrumbs.js.map +0 -1
  257. package/lib/packages/plugin/src/hooks/useGitRefName.js.map +0 -1
  258. package/lib/packages/plugin/src/hooks/useMinimalLayout.js.map +0 -1
  259. package/lib/packages/plugin/src/hooks/useReflection.js.map +0 -1
  260. package/lib/packages/plugin/src/hooks/useReflectionMap.js.map +0 -1
  261. package/lib/packages/plugin/src/index.js.map +0 -1
  262. package/lib/packages/plugin/src/markdownLoader.js.map +0 -1
  263. package/lib/packages/plugin/src/plugin/data.js.map +0 -1
  264. package/lib/packages/plugin/src/plugin/python/consts.js.map +0 -1
  265. package/lib/packages/plugin/src/plugin/python/index.js.map +0 -1
  266. package/lib/packages/plugin/src/plugin/python/inheritance.js.map +0 -1
  267. package/lib/packages/plugin/src/plugin/python/packageVersions.js.map +0 -1
  268. package/lib/packages/plugin/src/plugin/python/transformation.js.map +0 -1
  269. package/lib/packages/plugin/src/plugin/python/type-parsing/index.js.map +0 -1
  270. package/lib/packages/plugin/src/plugin/python/utils.js.map +0 -1
  271. package/lib/packages/plugin/src/plugin/sidebar.js.map +0 -1
  272. package/lib/packages/plugin/src/plugin/structure/0.23.js.map +0 -1
  273. package/lib/packages/plugin/src/plugin/url.js.map +0 -1
  274. package/lib/packages/plugin/src/plugin/version.js.map +0 -1
  275. package/lib/packages/plugin/src/types.js +0 -2
  276. package/lib/packages/plugin/src/types.js.map +0 -1
  277. package/lib/packages/plugin/src/utils/helpers.js.map +0 -1
  278. package/lib/packages/plugin/src/utils/hierarchy.js.map +0 -1
  279. package/lib/packages/plugin/src/utils/icons.js.map +0 -1
  280. package/lib/packages/plugin/src/utils/links.js.map +0 -1
  281. package/lib/packages/plugin/src/utils/markdown.js.map +0 -1
  282. package/lib/packages/plugin/src/utils/reexports.js.map +0 -1
  283. package/lib/packages/plugin/src/utils/visibility.js.map +0 -1
  284. /package/lib/{packages/plugin/src/components → components}/AnchorLink.js +0 -0
  285. /package/lib/{packages/plugin/src/components → components}/ApiChangelog.js +0 -0
  286. /package/lib/{packages/plugin/src/components → components}/ApiDataContext.js +0 -0
  287. /package/lib/{packages/plugin/src/components → components}/ApiIndex.js +0 -0
  288. /package/lib/{packages/plugin/src/components → components}/ApiItemLayout.js +0 -0
  289. /package/lib/{packages/plugin/src/components → components}/ApiOptionsLayout.js +0 -0
  290. /package/lib/{packages/plugin/src/components → components}/ApiPage.js +0 -0
  291. /package/lib/{packages/plugin/src/components → components}/Breadcrumb.js +0 -0
  292. /package/lib/{packages/plugin/src/components → components}/Comment.js +0 -0
  293. /package/lib/{packages/plugin/src/components → components}/CommentBadges.js +0 -0
  294. /package/lib/{packages/plugin/src/components → components}/DefaultValue.js +0 -0
  295. /package/lib/{packages/plugin/src/components → components}/Flags.js +0 -0
  296. /package/lib/{packages/plugin/src/components → components}/Footer.js +0 -0
  297. /package/lib/{packages/plugin/src/components → components}/Hierarchy.js +0 -0
  298. /package/lib/{packages/plugin/src/components → components}/Icon.js +0 -0
  299. /package/lib/{packages/plugin/src/components → components}/Index.js +0 -0
  300. /package/lib/{packages/plugin/src/components → components}/Markdown.js +0 -0
  301. /package/lib/{packages/plugin/src/components → components}/Member.js +0 -0
  302. /package/lib/{packages/plugin/src/components → components}/MemberDeclaration.js +0 -0
  303. /package/lib/{packages/plugin/src/components → components}/MemberGetterSetter.js +0 -0
  304. /package/lib/{packages/plugin/src/components → components}/MemberReference.js +0 -0
  305. /package/lib/{packages/plugin/src/components → components}/MemberSignatureBody.js +0 -0
  306. /package/lib/{packages/plugin/src/components → components}/MemberSignatureTitle.js +0 -0
  307. /package/lib/{packages/plugin/src/components → components}/MemberSignatures.js +0 -0
  308. /package/lib/{packages/plugin/src/components → components}/MemberSources.js +0 -0
  309. /package/lib/{packages/plugin/src/components → components}/Members.js +0 -0
  310. /package/lib/{packages/plugin/src/components → components}/MembersGroup.js +0 -0
  311. /package/lib/{packages/plugin/src/components → components}/Parameter.js +0 -0
  312. /package/lib/{packages/plugin/src/components → components}/Reflection.js +0 -0
  313. /package/lib/{packages/plugin/src/components → components}/SourceLink.js +0 -0
  314. /package/lib/{packages/plugin/src/components → components}/Type.js +0 -0
  315. /package/lib/{packages/plugin/src/components → components}/TypeAndParent.js +0 -0
  316. /package/lib/{packages/plugin/src/components → components}/TypeParameters.js +0 -0
  317. /package/lib/{packages/plugin/src/components → components}/TypeParametersGeneric.js +0 -0
  318. /package/lib/{packages/plugin/src/components → components}/VersionBanner.js +0 -0
  319. /package/lib/{packages/plugin/src/hooks → hooks}/useBreadcrumbs.js +0 -0
  320. /package/lib/{packages/plugin/src/hooks → hooks}/useGitRefName.js +0 -0
  321. /package/lib/{packages/plugin/src/hooks → hooks}/useMinimalLayout.js +0 -0
  322. /package/lib/{packages/plugin/src/hooks → hooks}/useReflection.js +0 -0
  323. /package/lib/{packages/plugin/src/hooks → hooks}/useReflectionMap.js +0 -0
  324. /package/lib/{packages/plugin/src/index.js → index.js} +0 -0
  325. /package/lib/{packages/plugin/src/markdownLoader.js → markdownLoader.js} +0 -0
  326. /package/lib/{packages/plugin/src/plugin → plugin}/data.js +0 -0
  327. /package/lib/{packages/plugin/src/plugin → plugin}/python/consts.js +0 -0
  328. /package/lib/{packages/plugin/src/plugin → plugin}/python/inheritance.js +0 -0
  329. /package/lib/{packages/plugin/src/plugin → plugin}/python/packageVersions.js +0 -0
  330. /package/lib/{packages/plugin/src/plugin → plugin}/python/transformation.js +0 -0
  331. /package/lib/{node_modules/cheerio/lib/esm → plugin/python}/types.js +0 -0
  332. /package/lib/{node_modules/cheerio/lib/esm → plugin/python}/types.js.map +0 -0
  333. /package/lib/{packages/plugin/src/plugin → plugin}/python/utils.js +0 -0
  334. /package/lib/{packages/plugin/src/plugin → plugin}/sidebar.js +0 -0
  335. /package/lib/{packages/plugin/src/plugin → plugin}/structure/0.23.js +0 -0
  336. /package/lib/{packages/plugin/src/plugin → plugin}/url.js +0 -0
  337. /package/lib/{packages/plugin/src/plugin → plugin}/version.js +0 -0
  338. /package/lib/{packages/plugin/src/plugin/python/types.js → types.js} +0 -0
  339. /package/lib/{packages/plugin/src/plugin/python/types.js.map → types.js.map} +0 -0
  340. /package/lib/{packages/plugin/src/utils → utils}/helpers.js +0 -0
  341. /package/lib/{packages/plugin/src/utils → utils}/hierarchy.js +0 -0
  342. /package/lib/{packages/plugin/src/utils → utils}/icons.js +0 -0
  343. /package/lib/{packages/plugin/src/utils → utils}/links.js +0 -0
  344. /package/lib/{packages/plugin/src/utils → utils}/markdown.js +0 -0
  345. /package/lib/{packages/plugin/src/utils → utils}/visibility.js +0 -0
  346. /package/{src/plugin/python → python-scripts}/docspec-gen/__init__.py +0 -0
  347. /package/{src/plugin/python → python-scripts}/docspec-gen/generate_ast.py +0 -0
  348. /package/{src/plugin/python → python-scripts}/docspec-gen/google_docstring_processor.py +0 -0
  349. /package/{src/plugin/python → python-scripts}/type-parsing/parse_types.py +0 -0
@@ -1,3142 +0,0 @@
1
- 'use strict';
2
-
3
- const preprocessor = require('./preprocessor.js');
4
- const unicode = require('../common/unicode.js');
5
- const token = require('../common/token.js');
6
- const decode = require('../../../entities/lib/esm/decode.js');
7
- const errorCodes = require('../common/error-codes.js');
8
- const html = require('../common/html.js');
9
- const decodeDataHtml = require('../../../entities/lib/esm/generated/decode-data-html.js');
10
-
11
- //C1 Unicode control character reference replacements
12
- const C1_CONTROLS_REFERENCE_REPLACEMENTS = new Map([[0x80, 8364], [0x82, 8218], [0x83, 402], [0x84, 8222], [0x85, 8230], [0x86, 8224], [0x87, 8225], [0x88, 710], [0x89, 8240], [0x8a, 352], [0x8b, 8249], [0x8c, 338], [0x8e, 381], [0x91, 8216], [0x92, 8217], [0x93, 8220], [0x94, 8221], [0x95, 8226], [0x96, 8211], [0x97, 8212], [0x98, 732], [0x99, 8482], [0x9a, 353], [0x9b, 8250], [0x9c, 339], [0x9e, 382], [0x9f, 376]]);
13
- //States
14
- var State;
15
- (function (State) {
16
- State[State["DATA"] = 0] = "DATA";
17
- State[State["RCDATA"] = 1] = "RCDATA";
18
- State[State["RAWTEXT"] = 2] = "RAWTEXT";
19
- State[State["SCRIPT_DATA"] = 3] = "SCRIPT_DATA";
20
- State[State["PLAINTEXT"] = 4] = "PLAINTEXT";
21
- State[State["TAG_OPEN"] = 5] = "TAG_OPEN";
22
- State[State["END_TAG_OPEN"] = 6] = "END_TAG_OPEN";
23
- State[State["TAG_NAME"] = 7] = "TAG_NAME";
24
- State[State["RCDATA_LESS_THAN_SIGN"] = 8] = "RCDATA_LESS_THAN_SIGN";
25
- State[State["RCDATA_END_TAG_OPEN"] = 9] = "RCDATA_END_TAG_OPEN";
26
- State[State["RCDATA_END_TAG_NAME"] = 10] = "RCDATA_END_TAG_NAME";
27
- State[State["RAWTEXT_LESS_THAN_SIGN"] = 11] = "RAWTEXT_LESS_THAN_SIGN";
28
- State[State["RAWTEXT_END_TAG_OPEN"] = 12] = "RAWTEXT_END_TAG_OPEN";
29
- State[State["RAWTEXT_END_TAG_NAME"] = 13] = "RAWTEXT_END_TAG_NAME";
30
- State[State["SCRIPT_DATA_LESS_THAN_SIGN"] = 14] = "SCRIPT_DATA_LESS_THAN_SIGN";
31
- State[State["SCRIPT_DATA_END_TAG_OPEN"] = 15] = "SCRIPT_DATA_END_TAG_OPEN";
32
- State[State["SCRIPT_DATA_END_TAG_NAME"] = 16] = "SCRIPT_DATA_END_TAG_NAME";
33
- State[State["SCRIPT_DATA_ESCAPE_START"] = 17] = "SCRIPT_DATA_ESCAPE_START";
34
- State[State["SCRIPT_DATA_ESCAPE_START_DASH"] = 18] = "SCRIPT_DATA_ESCAPE_START_DASH";
35
- State[State["SCRIPT_DATA_ESCAPED"] = 19] = "SCRIPT_DATA_ESCAPED";
36
- State[State["SCRIPT_DATA_ESCAPED_DASH"] = 20] = "SCRIPT_DATA_ESCAPED_DASH";
37
- State[State["SCRIPT_DATA_ESCAPED_DASH_DASH"] = 21] = "SCRIPT_DATA_ESCAPED_DASH_DASH";
38
- State[State["SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN"] = 22] = "SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN";
39
- State[State["SCRIPT_DATA_ESCAPED_END_TAG_OPEN"] = 23] = "SCRIPT_DATA_ESCAPED_END_TAG_OPEN";
40
- State[State["SCRIPT_DATA_ESCAPED_END_TAG_NAME"] = 24] = "SCRIPT_DATA_ESCAPED_END_TAG_NAME";
41
- State[State["SCRIPT_DATA_DOUBLE_ESCAPE_START"] = 25] = "SCRIPT_DATA_DOUBLE_ESCAPE_START";
42
- State[State["SCRIPT_DATA_DOUBLE_ESCAPED"] = 26] = "SCRIPT_DATA_DOUBLE_ESCAPED";
43
- State[State["SCRIPT_DATA_DOUBLE_ESCAPED_DASH"] = 27] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH";
44
- State[State["SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH"] = 28] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH";
45
- State[State["SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN"] = 29] = "SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN";
46
- State[State["SCRIPT_DATA_DOUBLE_ESCAPE_END"] = 30] = "SCRIPT_DATA_DOUBLE_ESCAPE_END";
47
- State[State["BEFORE_ATTRIBUTE_NAME"] = 31] = "BEFORE_ATTRIBUTE_NAME";
48
- State[State["ATTRIBUTE_NAME"] = 32] = "ATTRIBUTE_NAME";
49
- State[State["AFTER_ATTRIBUTE_NAME"] = 33] = "AFTER_ATTRIBUTE_NAME";
50
- State[State["BEFORE_ATTRIBUTE_VALUE"] = 34] = "BEFORE_ATTRIBUTE_VALUE";
51
- State[State["ATTRIBUTE_VALUE_DOUBLE_QUOTED"] = 35] = "ATTRIBUTE_VALUE_DOUBLE_QUOTED";
52
- State[State["ATTRIBUTE_VALUE_SINGLE_QUOTED"] = 36] = "ATTRIBUTE_VALUE_SINGLE_QUOTED";
53
- State[State["ATTRIBUTE_VALUE_UNQUOTED"] = 37] = "ATTRIBUTE_VALUE_UNQUOTED";
54
- State[State["AFTER_ATTRIBUTE_VALUE_QUOTED"] = 38] = "AFTER_ATTRIBUTE_VALUE_QUOTED";
55
- State[State["SELF_CLOSING_START_TAG"] = 39] = "SELF_CLOSING_START_TAG";
56
- State[State["BOGUS_COMMENT"] = 40] = "BOGUS_COMMENT";
57
- State[State["MARKUP_DECLARATION_OPEN"] = 41] = "MARKUP_DECLARATION_OPEN";
58
- State[State["COMMENT_START"] = 42] = "COMMENT_START";
59
- State[State["COMMENT_START_DASH"] = 43] = "COMMENT_START_DASH";
60
- State[State["COMMENT"] = 44] = "COMMENT";
61
- State[State["COMMENT_LESS_THAN_SIGN"] = 45] = "COMMENT_LESS_THAN_SIGN";
62
- State[State["COMMENT_LESS_THAN_SIGN_BANG"] = 46] = "COMMENT_LESS_THAN_SIGN_BANG";
63
- State[State["COMMENT_LESS_THAN_SIGN_BANG_DASH"] = 47] = "COMMENT_LESS_THAN_SIGN_BANG_DASH";
64
- State[State["COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH"] = 48] = "COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH";
65
- State[State["COMMENT_END_DASH"] = 49] = "COMMENT_END_DASH";
66
- State[State["COMMENT_END"] = 50] = "COMMENT_END";
67
- State[State["COMMENT_END_BANG"] = 51] = "COMMENT_END_BANG";
68
- State[State["DOCTYPE"] = 52] = "DOCTYPE";
69
- State[State["BEFORE_DOCTYPE_NAME"] = 53] = "BEFORE_DOCTYPE_NAME";
70
- State[State["DOCTYPE_NAME"] = 54] = "DOCTYPE_NAME";
71
- State[State["AFTER_DOCTYPE_NAME"] = 55] = "AFTER_DOCTYPE_NAME";
72
- State[State["AFTER_DOCTYPE_PUBLIC_KEYWORD"] = 56] = "AFTER_DOCTYPE_PUBLIC_KEYWORD";
73
- State[State["BEFORE_DOCTYPE_PUBLIC_IDENTIFIER"] = 57] = "BEFORE_DOCTYPE_PUBLIC_IDENTIFIER";
74
- State[State["DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED"] = 58] = "DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED";
75
- State[State["DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED"] = 59] = "DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED";
76
- State[State["AFTER_DOCTYPE_PUBLIC_IDENTIFIER"] = 60] = "AFTER_DOCTYPE_PUBLIC_IDENTIFIER";
77
- State[State["BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS"] = 61] = "BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS";
78
- State[State["AFTER_DOCTYPE_SYSTEM_KEYWORD"] = 62] = "AFTER_DOCTYPE_SYSTEM_KEYWORD";
79
- State[State["BEFORE_DOCTYPE_SYSTEM_IDENTIFIER"] = 63] = "BEFORE_DOCTYPE_SYSTEM_IDENTIFIER";
80
- State[State["DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED"] = 64] = "DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED";
81
- State[State["DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED"] = 65] = "DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED";
82
- State[State["AFTER_DOCTYPE_SYSTEM_IDENTIFIER"] = 66] = "AFTER_DOCTYPE_SYSTEM_IDENTIFIER";
83
- State[State["BOGUS_DOCTYPE"] = 67] = "BOGUS_DOCTYPE";
84
- State[State["CDATA_SECTION"] = 68] = "CDATA_SECTION";
85
- State[State["CDATA_SECTION_BRACKET"] = 69] = "CDATA_SECTION_BRACKET";
86
- State[State["CDATA_SECTION_END"] = 70] = "CDATA_SECTION_END";
87
- State[State["CHARACTER_REFERENCE"] = 71] = "CHARACTER_REFERENCE";
88
- State[State["NAMED_CHARACTER_REFERENCE"] = 72] = "NAMED_CHARACTER_REFERENCE";
89
- State[State["AMBIGUOUS_AMPERSAND"] = 73] = "AMBIGUOUS_AMPERSAND";
90
- State[State["NUMERIC_CHARACTER_REFERENCE"] = 74] = "NUMERIC_CHARACTER_REFERENCE";
91
- State[State["HEXADEMICAL_CHARACTER_REFERENCE_START"] = 75] = "HEXADEMICAL_CHARACTER_REFERENCE_START";
92
- State[State["HEXADEMICAL_CHARACTER_REFERENCE"] = 76] = "HEXADEMICAL_CHARACTER_REFERENCE";
93
- State[State["DECIMAL_CHARACTER_REFERENCE"] = 77] = "DECIMAL_CHARACTER_REFERENCE";
94
- State[State["NUMERIC_CHARACTER_REFERENCE_END"] = 78] = "NUMERIC_CHARACTER_REFERENCE_END";
95
- })(State || (State = {}));
96
- //Tokenizer initial states for different modes
97
- const TokenizerMode = {
98
- DATA: State.DATA,
99
- RCDATA: State.RCDATA,
100
- RAWTEXT: State.RAWTEXT,
101
- SCRIPT_DATA: State.SCRIPT_DATA,
102
- PLAINTEXT: State.PLAINTEXT,
103
- CDATA_SECTION: State.CDATA_SECTION
104
- };
105
- //Utils
106
- //OPTIMIZATION: these utility functions should not be moved out of this module. V8 Crankshaft will not inline
107
- //this functions if they will be situated in another module due to context switch.
108
- //Always perform inlining check before modifying this functions ('node --trace-inlining').
109
- function isAsciiDigit(cp) {
110
- return cp >= unicode.CODE_POINTS.DIGIT_0 && cp <= unicode.CODE_POINTS.DIGIT_9;
111
- }
112
- function isAsciiUpper(cp) {
113
- return cp >= unicode.CODE_POINTS.LATIN_CAPITAL_A && cp <= unicode.CODE_POINTS.LATIN_CAPITAL_Z;
114
- }
115
- function isAsciiLower(cp) {
116
- return cp >= unicode.CODE_POINTS.LATIN_SMALL_A && cp <= unicode.CODE_POINTS.LATIN_SMALL_Z;
117
- }
118
- function isAsciiLetter(cp) {
119
- return isAsciiLower(cp) || isAsciiUpper(cp);
120
- }
121
- function isAsciiAlphaNumeric(cp) {
122
- return isAsciiLetter(cp) || isAsciiDigit(cp);
123
- }
124
- function isAsciiUpperHexDigit(cp) {
125
- return cp >= unicode.CODE_POINTS.LATIN_CAPITAL_A && cp <= unicode.CODE_POINTS.LATIN_CAPITAL_F;
126
- }
127
- function isAsciiLowerHexDigit(cp) {
128
- return cp >= unicode.CODE_POINTS.LATIN_SMALL_A && cp <= unicode.CODE_POINTS.LATIN_SMALL_F;
129
- }
130
- function isAsciiHexDigit(cp) {
131
- return isAsciiDigit(cp) || isAsciiUpperHexDigit(cp) || isAsciiLowerHexDigit(cp);
132
- }
133
- function toAsciiLower(cp) {
134
- return cp + 32;
135
- }
136
- function isWhitespace(cp) {
137
- return cp === unicode.CODE_POINTS.SPACE || cp === unicode.CODE_POINTS.LINE_FEED || cp === unicode.CODE_POINTS.TABULATION || cp === unicode.CODE_POINTS.FORM_FEED;
138
- }
139
- function isEntityInAttributeInvalidEnd(nextCp) {
140
- return nextCp === unicode.CODE_POINTS.EQUALS_SIGN || isAsciiAlphaNumeric(nextCp);
141
- }
142
- function isScriptDataDoubleEscapeSequenceEnd(cp) {
143
- return isWhitespace(cp) || cp === unicode.CODE_POINTS.SOLIDUS || cp === unicode.CODE_POINTS.GREATER_THAN_SIGN;
144
- }
145
- //Tokenizer
146
- class Tokenizer {
147
- constructor(options, handler) {
148
- this.options = options;
149
- this.handler = handler;
150
- this.paused = false;
151
- /** Ensures that the parsing loop isn't run multiple times at once. */
152
- this.inLoop = false;
153
- /**
154
- * Indicates that the current adjusted node exists, is not an element in the HTML namespace,
155
- * and that it is not an integration point for either MathML or HTML.
156
- *
157
- * @see {@link https://html.spec.whatwg.org/multipage/parsing.html#tree-construction}
158
- */
159
- this.inForeignNode = false;
160
- this.lastStartTagName = '';
161
- this.active = false;
162
- this.state = State.DATA;
163
- this.returnState = State.DATA;
164
- this.charRefCode = -1;
165
- this.consumedAfterSnapshot = -1;
166
- this.currentCharacterToken = null;
167
- this.currentToken = null;
168
- this.currentAttr = {
169
- name: '',
170
- value: ''
171
- };
172
- this.preprocessor = new preprocessor.Preprocessor(handler);
173
- this.currentLocation = this.getCurrentLocation(-1);
174
- }
175
- //Errors
176
- _err(code) {
177
- var _a, _b;
178
- (_b = (_a = this.handler).onParseError) === null || _b === void 0 ? void 0 : _b.call(_a, this.preprocessor.getError(code));
179
- }
180
- // NOTE: `offset` may never run across line boundaries.
181
- getCurrentLocation(offset) {
182
- if (!this.options.sourceCodeLocationInfo) {
183
- return null;
184
- }
185
- return {
186
- startLine: this.preprocessor.line,
187
- startCol: this.preprocessor.col - offset,
188
- startOffset: this.preprocessor.offset - offset,
189
- endLine: -1,
190
- endCol: -1,
191
- endOffset: -1
192
- };
193
- }
194
- _runParsingLoop() {
195
- if (this.inLoop) return;
196
- this.inLoop = true;
197
- while (this.active && !this.paused) {
198
- this.consumedAfterSnapshot = 0;
199
- const cp = this._consume();
200
- if (!this._ensureHibernation()) {
201
- this._callState(cp);
202
- }
203
- }
204
- this.inLoop = false;
205
- }
206
- //API
207
- pause() {
208
- this.paused = true;
209
- }
210
- resume(writeCallback) {
211
- if (!this.paused) {
212
- throw new Error('Parser was already resumed');
213
- }
214
- this.paused = false;
215
- // Necessary for synchronous resume.
216
- if (this.inLoop) return;
217
- this._runParsingLoop();
218
- if (!this.paused) {
219
- writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();
220
- }
221
- }
222
- write(chunk, isLastChunk, writeCallback) {
223
- this.active = true;
224
- this.preprocessor.write(chunk, isLastChunk);
225
- this._runParsingLoop();
226
- if (!this.paused) {
227
- writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();
228
- }
229
- }
230
- insertHtmlAtCurrentPos(chunk) {
231
- this.active = true;
232
- this.preprocessor.insertHtmlAtCurrentPos(chunk);
233
- this._runParsingLoop();
234
- }
235
- //Hibernation
236
- _ensureHibernation() {
237
- if (this.preprocessor.endOfChunkHit) {
238
- this._unconsume(this.consumedAfterSnapshot);
239
- this.active = false;
240
- return true;
241
- }
242
- return false;
243
- }
244
- //Consumption
245
- _consume() {
246
- this.consumedAfterSnapshot++;
247
- return this.preprocessor.advance();
248
- }
249
- _unconsume(count) {
250
- this.consumedAfterSnapshot -= count;
251
- this.preprocessor.retreat(count);
252
- }
253
- _reconsumeInState(state, cp) {
254
- this.state = state;
255
- this._callState(cp);
256
- }
257
- _advanceBy(count) {
258
- this.consumedAfterSnapshot += count;
259
- for (let i = 0; i < count; i++) {
260
- this.preprocessor.advance();
261
- }
262
- }
263
- _consumeSequenceIfMatch(pattern, caseSensitive) {
264
- if (this.preprocessor.startsWith(pattern, caseSensitive)) {
265
- // We will already have consumed one character before calling this method.
266
- this._advanceBy(pattern.length - 1);
267
- return true;
268
- }
269
- return false;
270
- }
271
- //Token creation
272
- _createStartTagToken() {
273
- this.currentToken = {
274
- type: token.TokenType.START_TAG,
275
- tagName: '',
276
- tagID: html.TAG_ID.UNKNOWN,
277
- selfClosing: false,
278
- ackSelfClosing: false,
279
- attrs: [],
280
- location: this.getCurrentLocation(1)
281
- };
282
- }
283
- _createEndTagToken() {
284
- this.currentToken = {
285
- type: token.TokenType.END_TAG,
286
- tagName: '',
287
- tagID: html.TAG_ID.UNKNOWN,
288
- selfClosing: false,
289
- ackSelfClosing: false,
290
- attrs: [],
291
- location: this.getCurrentLocation(2)
292
- };
293
- }
294
- _createCommentToken(offset) {
295
- this.currentToken = {
296
- type: token.TokenType.COMMENT,
297
- data: '',
298
- location: this.getCurrentLocation(offset)
299
- };
300
- }
301
- _createDoctypeToken(initialName) {
302
- this.currentToken = {
303
- type: token.TokenType.DOCTYPE,
304
- name: initialName,
305
- forceQuirks: false,
306
- publicId: null,
307
- systemId: null,
308
- location: this.currentLocation
309
- };
310
- }
311
- _createCharacterToken(type, chars) {
312
- this.currentCharacterToken = {
313
- type,
314
- chars,
315
- location: this.currentLocation
316
- };
317
- }
318
- //Tag attributes
319
- _createAttr(attrNameFirstCh) {
320
- this.currentAttr = {
321
- name: attrNameFirstCh,
322
- value: ''
323
- };
324
- this.currentLocation = this.getCurrentLocation(0);
325
- }
326
- _leaveAttrName() {
327
- var _a;
328
- var _b;
329
- const token$1 = this.currentToken;
330
- if (token.getTokenAttr(token$1, this.currentAttr.name) === null) {
331
- token$1.attrs.push(this.currentAttr);
332
- if (token$1.location && this.currentLocation) {
333
- const attrLocations = (_a = (_b = token$1.location).attrs) !== null && _a !== void 0 ? _a : _b.attrs = Object.create(null);
334
- attrLocations[this.currentAttr.name] = this.currentLocation;
335
- // Set end location
336
- this._leaveAttrValue();
337
- }
338
- } else {
339
- this._err(errorCodes.ERR.duplicateAttribute);
340
- }
341
- }
342
- _leaveAttrValue() {
343
- if (this.currentLocation) {
344
- this.currentLocation.endLine = this.preprocessor.line;
345
- this.currentLocation.endCol = this.preprocessor.col;
346
- this.currentLocation.endOffset = this.preprocessor.offset;
347
- }
348
- }
349
- //Token emission
350
- prepareToken(ct) {
351
- this._emitCurrentCharacterToken(ct.location);
352
- this.currentToken = null;
353
- if (ct.location) {
354
- ct.location.endLine = this.preprocessor.line;
355
- ct.location.endCol = this.preprocessor.col + 1;
356
- ct.location.endOffset = this.preprocessor.offset + 1;
357
- }
358
- this.currentLocation = this.getCurrentLocation(-1);
359
- }
360
- emitCurrentTagToken() {
361
- const ct = this.currentToken;
362
- this.prepareToken(ct);
363
- ct.tagID = html.getTagID(ct.tagName);
364
- if (ct.type === token.TokenType.START_TAG) {
365
- this.lastStartTagName = ct.tagName;
366
- this.handler.onStartTag(ct);
367
- } else {
368
- if (ct.attrs.length > 0) {
369
- this._err(errorCodes.ERR.endTagWithAttributes);
370
- }
371
- if (ct.selfClosing) {
372
- this._err(errorCodes.ERR.endTagWithTrailingSolidus);
373
- }
374
- this.handler.onEndTag(ct);
375
- }
376
- this.preprocessor.dropParsedChunk();
377
- }
378
- emitCurrentComment(ct) {
379
- this.prepareToken(ct);
380
- this.handler.onComment(ct);
381
- this.preprocessor.dropParsedChunk();
382
- }
383
- emitCurrentDoctype(ct) {
384
- this.prepareToken(ct);
385
- this.handler.onDoctype(ct);
386
- this.preprocessor.dropParsedChunk();
387
- }
388
- _emitCurrentCharacterToken(nextLocation) {
389
- if (this.currentCharacterToken) {
390
- //NOTE: if we have a pending character token, make it's end location equal to the
391
- //current token's start location.
392
- if (nextLocation && this.currentCharacterToken.location) {
393
- this.currentCharacterToken.location.endLine = nextLocation.startLine;
394
- this.currentCharacterToken.location.endCol = nextLocation.startCol;
395
- this.currentCharacterToken.location.endOffset = nextLocation.startOffset;
396
- }
397
- switch (this.currentCharacterToken.type) {
398
- case token.TokenType.CHARACTER:
399
- {
400
- this.handler.onCharacter(this.currentCharacterToken);
401
- break;
402
- }
403
- case token.TokenType.NULL_CHARACTER:
404
- {
405
- this.handler.onNullCharacter(this.currentCharacterToken);
406
- break;
407
- }
408
- case token.TokenType.WHITESPACE_CHARACTER:
409
- {
410
- this.handler.onWhitespaceCharacter(this.currentCharacterToken);
411
- break;
412
- }
413
- }
414
- this.currentCharacterToken = null;
415
- }
416
- }
417
- _emitEOFToken() {
418
- const location = this.getCurrentLocation(0);
419
- if (location) {
420
- location.endLine = location.startLine;
421
- location.endCol = location.startCol;
422
- location.endOffset = location.startOffset;
423
- }
424
- this._emitCurrentCharacterToken(location);
425
- this.handler.onEof({
426
- type: token.TokenType.EOF,
427
- location
428
- });
429
- this.active = false;
430
- }
431
- //Characters emission
432
- //OPTIMIZATION: specification uses only one type of character tokens (one token per character).
433
- //This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters.
434
- //If we have a sequence of characters that belong to the same group, the parser can process it
435
- //as a single solid character token.
436
- //So, there are 3 types of character tokens in parse5:
437
- //1)TokenType.NULL_CHARACTER - \u0000-character sequences (e.g. '\u0000\u0000\u0000')
438
- //2)TokenType.WHITESPACE_CHARACTER - any whitespace/new-line character sequences (e.g. '\n \r\t \f')
439
- //3)TokenType.CHARACTER - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^')
440
- _appendCharToCurrentCharacterToken(type, ch) {
441
- if (this.currentCharacterToken) {
442
- if (this.currentCharacterToken.type !== type) {
443
- this.currentLocation = this.getCurrentLocation(0);
444
- this._emitCurrentCharacterToken(this.currentLocation);
445
- this.preprocessor.dropParsedChunk();
446
- } else {
447
- this.currentCharacterToken.chars += ch;
448
- return;
449
- }
450
- }
451
- this._createCharacterToken(type, ch);
452
- }
453
- _emitCodePoint(cp) {
454
- const type = isWhitespace(cp) ? token.TokenType.WHITESPACE_CHARACTER : cp === unicode.CODE_POINTS.NULL ? token.TokenType.NULL_CHARACTER : token.TokenType.CHARACTER;
455
- this._appendCharToCurrentCharacterToken(type, String.fromCodePoint(cp));
456
- }
457
- //NOTE: used when we emit characters explicitly.
458
- //This is always for non-whitespace and non-null characters, which allows us to avoid additional checks.
459
- _emitChars(ch) {
460
- this._appendCharToCurrentCharacterToken(token.TokenType.CHARACTER, ch);
461
- }
462
- // Character reference helpers
463
- _matchNamedCharacterReference(cp) {
464
- let result = null;
465
- let excess = 0;
466
- let withoutSemicolon = false;
467
- for (let i = 0, current = decodeDataHtml[0]; i >= 0; cp = this._consume()) {
468
- i = decode.determineBranch(decodeDataHtml, current, i + 1, cp);
469
- if (i < 0) break;
470
- excess += 1;
471
- current = decodeDataHtml[i];
472
- const masked = current & decode.BinTrieFlags.VALUE_LENGTH;
473
- // If the branch is a value, store it and continue
474
- if (masked) {
475
- // The mask is the number of bytes of the value, including the current byte.
476
- const valueLength = (masked >> 14) - 1;
477
- // Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
478
- // See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
479
- if (cp !== unicode.CODE_POINTS.SEMICOLON && this._isCharacterReferenceInAttribute() && isEntityInAttributeInvalidEnd(this.preprocessor.peek(1))) {
480
- //NOTE: we don't flush all consumed code points here, and instead switch back to the original state after
481
- //emitting an ampersand. This is fine, as alphanumeric characters won't be parsed differently in attributes.
482
- result = [unicode.CODE_POINTS.AMPERSAND];
483
- // Skip over the value.
484
- i += valueLength;
485
- } else {
486
- // If this is a surrogate pair, consume the next two bytes.
487
- result = valueLength === 0 ? [decodeDataHtml[i] & ~decode.BinTrieFlags.VALUE_LENGTH] : valueLength === 1 ? [decodeDataHtml[++i]] : [decodeDataHtml[++i], decodeDataHtml[++i]];
488
- excess = 0;
489
- withoutSemicolon = cp !== unicode.CODE_POINTS.SEMICOLON;
490
- }
491
- if (valueLength === 0) {
492
- // If the value is zero-length, we're done.
493
- this._consume();
494
- break;
495
- }
496
- }
497
- }
498
- this._unconsume(excess);
499
- if (withoutSemicolon && !this.preprocessor.endOfChunkHit) {
500
- this._err(errorCodes.ERR.missingSemicolonAfterCharacterReference);
501
- }
502
- // We want to emit the error above on the code point after the entity.
503
- // We always consume one code point too many in the loop, and we wait to
504
- // unconsume it until after the error is emitted.
505
- this._unconsume(1);
506
- return result;
507
- }
508
- _isCharacterReferenceInAttribute() {
509
- return this.returnState === State.ATTRIBUTE_VALUE_DOUBLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_SINGLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_UNQUOTED;
510
- }
511
- _flushCodePointConsumedAsCharacterReference(cp) {
512
- if (this._isCharacterReferenceInAttribute()) {
513
- this.currentAttr.value += String.fromCodePoint(cp);
514
- } else {
515
- this._emitCodePoint(cp);
516
- }
517
- }
518
- // Calling states this way turns out to be much faster than any other approach.
519
- _callState(cp) {
520
- switch (this.state) {
521
- case State.DATA:
522
- {
523
- this._stateData(cp);
524
- break;
525
- }
526
- case State.RCDATA:
527
- {
528
- this._stateRcdata(cp);
529
- break;
530
- }
531
- case State.RAWTEXT:
532
- {
533
- this._stateRawtext(cp);
534
- break;
535
- }
536
- case State.SCRIPT_DATA:
537
- {
538
- this._stateScriptData(cp);
539
- break;
540
- }
541
- case State.PLAINTEXT:
542
- {
543
- this._statePlaintext(cp);
544
- break;
545
- }
546
- case State.TAG_OPEN:
547
- {
548
- this._stateTagOpen(cp);
549
- break;
550
- }
551
- case State.END_TAG_OPEN:
552
- {
553
- this._stateEndTagOpen(cp);
554
- break;
555
- }
556
- case State.TAG_NAME:
557
- {
558
- this._stateTagName(cp);
559
- break;
560
- }
561
- case State.RCDATA_LESS_THAN_SIGN:
562
- {
563
- this._stateRcdataLessThanSign(cp);
564
- break;
565
- }
566
- case State.RCDATA_END_TAG_OPEN:
567
- {
568
- this._stateRcdataEndTagOpen(cp);
569
- break;
570
- }
571
- case State.RCDATA_END_TAG_NAME:
572
- {
573
- this._stateRcdataEndTagName(cp);
574
- break;
575
- }
576
- case State.RAWTEXT_LESS_THAN_SIGN:
577
- {
578
- this._stateRawtextLessThanSign(cp);
579
- break;
580
- }
581
- case State.RAWTEXT_END_TAG_OPEN:
582
- {
583
- this._stateRawtextEndTagOpen(cp);
584
- break;
585
- }
586
- case State.RAWTEXT_END_TAG_NAME:
587
- {
588
- this._stateRawtextEndTagName(cp);
589
- break;
590
- }
591
- case State.SCRIPT_DATA_LESS_THAN_SIGN:
592
- {
593
- this._stateScriptDataLessThanSign(cp);
594
- break;
595
- }
596
- case State.SCRIPT_DATA_END_TAG_OPEN:
597
- {
598
- this._stateScriptDataEndTagOpen(cp);
599
- break;
600
- }
601
- case State.SCRIPT_DATA_END_TAG_NAME:
602
- {
603
- this._stateScriptDataEndTagName(cp);
604
- break;
605
- }
606
- case State.SCRIPT_DATA_ESCAPE_START:
607
- {
608
- this._stateScriptDataEscapeStart(cp);
609
- break;
610
- }
611
- case State.SCRIPT_DATA_ESCAPE_START_DASH:
612
- {
613
- this._stateScriptDataEscapeStartDash(cp);
614
- break;
615
- }
616
- case State.SCRIPT_DATA_ESCAPED:
617
- {
618
- this._stateScriptDataEscaped(cp);
619
- break;
620
- }
621
- case State.SCRIPT_DATA_ESCAPED_DASH:
622
- {
623
- this._stateScriptDataEscapedDash(cp);
624
- break;
625
- }
626
- case State.SCRIPT_DATA_ESCAPED_DASH_DASH:
627
- {
628
- this._stateScriptDataEscapedDashDash(cp);
629
- break;
630
- }
631
- case State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:
632
- {
633
- this._stateScriptDataEscapedLessThanSign(cp);
634
- break;
635
- }
636
- case State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:
637
- {
638
- this._stateScriptDataEscapedEndTagOpen(cp);
639
- break;
640
- }
641
- case State.SCRIPT_DATA_ESCAPED_END_TAG_NAME:
642
- {
643
- this._stateScriptDataEscapedEndTagName(cp);
644
- break;
645
- }
646
- case State.SCRIPT_DATA_DOUBLE_ESCAPE_START:
647
- {
648
- this._stateScriptDataDoubleEscapeStart(cp);
649
- break;
650
- }
651
- case State.SCRIPT_DATA_DOUBLE_ESCAPED:
652
- {
653
- this._stateScriptDataDoubleEscaped(cp);
654
- break;
655
- }
656
- case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:
657
- {
658
- this._stateScriptDataDoubleEscapedDash(cp);
659
- break;
660
- }
661
- case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:
662
- {
663
- this._stateScriptDataDoubleEscapedDashDash(cp);
664
- break;
665
- }
666
- case State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:
667
- {
668
- this._stateScriptDataDoubleEscapedLessThanSign(cp);
669
- break;
670
- }
671
- case State.SCRIPT_DATA_DOUBLE_ESCAPE_END:
672
- {
673
- this._stateScriptDataDoubleEscapeEnd(cp);
674
- break;
675
- }
676
- case State.BEFORE_ATTRIBUTE_NAME:
677
- {
678
- this._stateBeforeAttributeName(cp);
679
- break;
680
- }
681
- case State.ATTRIBUTE_NAME:
682
- {
683
- this._stateAttributeName(cp);
684
- break;
685
- }
686
- case State.AFTER_ATTRIBUTE_NAME:
687
- {
688
- this._stateAfterAttributeName(cp);
689
- break;
690
- }
691
- case State.BEFORE_ATTRIBUTE_VALUE:
692
- {
693
- this._stateBeforeAttributeValue(cp);
694
- break;
695
- }
696
- case State.ATTRIBUTE_VALUE_DOUBLE_QUOTED:
697
- {
698
- this._stateAttributeValueDoubleQuoted(cp);
699
- break;
700
- }
701
- case State.ATTRIBUTE_VALUE_SINGLE_QUOTED:
702
- {
703
- this._stateAttributeValueSingleQuoted(cp);
704
- break;
705
- }
706
- case State.ATTRIBUTE_VALUE_UNQUOTED:
707
- {
708
- this._stateAttributeValueUnquoted(cp);
709
- break;
710
- }
711
- case State.AFTER_ATTRIBUTE_VALUE_QUOTED:
712
- {
713
- this._stateAfterAttributeValueQuoted(cp);
714
- break;
715
- }
716
- case State.SELF_CLOSING_START_TAG:
717
- {
718
- this._stateSelfClosingStartTag(cp);
719
- break;
720
- }
721
- case State.BOGUS_COMMENT:
722
- {
723
- this._stateBogusComment(cp);
724
- break;
725
- }
726
- case State.MARKUP_DECLARATION_OPEN:
727
- {
728
- this._stateMarkupDeclarationOpen(cp);
729
- break;
730
- }
731
- case State.COMMENT_START:
732
- {
733
- this._stateCommentStart(cp);
734
- break;
735
- }
736
- case State.COMMENT_START_DASH:
737
- {
738
- this._stateCommentStartDash(cp);
739
- break;
740
- }
741
- case State.COMMENT:
742
- {
743
- this._stateComment(cp);
744
- break;
745
- }
746
- case State.COMMENT_LESS_THAN_SIGN:
747
- {
748
- this._stateCommentLessThanSign(cp);
749
- break;
750
- }
751
- case State.COMMENT_LESS_THAN_SIGN_BANG:
752
- {
753
- this._stateCommentLessThanSignBang(cp);
754
- break;
755
- }
756
- case State.COMMENT_LESS_THAN_SIGN_BANG_DASH:
757
- {
758
- this._stateCommentLessThanSignBangDash(cp);
759
- break;
760
- }
761
- case State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:
762
- {
763
- this._stateCommentLessThanSignBangDashDash(cp);
764
- break;
765
- }
766
- case State.COMMENT_END_DASH:
767
- {
768
- this._stateCommentEndDash(cp);
769
- break;
770
- }
771
- case State.COMMENT_END:
772
- {
773
- this._stateCommentEnd(cp);
774
- break;
775
- }
776
- case State.COMMENT_END_BANG:
777
- {
778
- this._stateCommentEndBang(cp);
779
- break;
780
- }
781
- case State.DOCTYPE:
782
- {
783
- this._stateDoctype(cp);
784
- break;
785
- }
786
- case State.BEFORE_DOCTYPE_NAME:
787
- {
788
- this._stateBeforeDoctypeName(cp);
789
- break;
790
- }
791
- case State.DOCTYPE_NAME:
792
- {
793
- this._stateDoctypeName(cp);
794
- break;
795
- }
796
- case State.AFTER_DOCTYPE_NAME:
797
- {
798
- this._stateAfterDoctypeName(cp);
799
- break;
800
- }
801
- case State.AFTER_DOCTYPE_PUBLIC_KEYWORD:
802
- {
803
- this._stateAfterDoctypePublicKeyword(cp);
804
- break;
805
- }
806
- case State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:
807
- {
808
- this._stateBeforeDoctypePublicIdentifier(cp);
809
- break;
810
- }
811
- case State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:
812
- {
813
- this._stateDoctypePublicIdentifierDoubleQuoted(cp);
814
- break;
815
- }
816
- case State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:
817
- {
818
- this._stateDoctypePublicIdentifierSingleQuoted(cp);
819
- break;
820
- }
821
- case State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:
822
- {
823
- this._stateAfterDoctypePublicIdentifier(cp);
824
- break;
825
- }
826
- case State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:
827
- {
828
- this._stateBetweenDoctypePublicAndSystemIdentifiers(cp);
829
- break;
830
- }
831
- case State.AFTER_DOCTYPE_SYSTEM_KEYWORD:
832
- {
833
- this._stateAfterDoctypeSystemKeyword(cp);
834
- break;
835
- }
836
- case State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:
837
- {
838
- this._stateBeforeDoctypeSystemIdentifier(cp);
839
- break;
840
- }
841
- case State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:
842
- {
843
- this._stateDoctypeSystemIdentifierDoubleQuoted(cp);
844
- break;
845
- }
846
- case State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:
847
- {
848
- this._stateDoctypeSystemIdentifierSingleQuoted(cp);
849
- break;
850
- }
851
- case State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:
852
- {
853
- this._stateAfterDoctypeSystemIdentifier(cp);
854
- break;
855
- }
856
- case State.BOGUS_DOCTYPE:
857
- {
858
- this._stateBogusDoctype(cp);
859
- break;
860
- }
861
- case State.CDATA_SECTION:
862
- {
863
- this._stateCdataSection(cp);
864
- break;
865
- }
866
- case State.CDATA_SECTION_BRACKET:
867
- {
868
- this._stateCdataSectionBracket(cp);
869
- break;
870
- }
871
- case State.CDATA_SECTION_END:
872
- {
873
- this._stateCdataSectionEnd(cp);
874
- break;
875
- }
876
- case State.CHARACTER_REFERENCE:
877
- {
878
- this._stateCharacterReference(cp);
879
- break;
880
- }
881
- case State.NAMED_CHARACTER_REFERENCE:
882
- {
883
- this._stateNamedCharacterReference(cp);
884
- break;
885
- }
886
- case State.AMBIGUOUS_AMPERSAND:
887
- {
888
- this._stateAmbiguousAmpersand(cp);
889
- break;
890
- }
891
- case State.NUMERIC_CHARACTER_REFERENCE:
892
- {
893
- this._stateNumericCharacterReference(cp);
894
- break;
895
- }
896
- case State.HEXADEMICAL_CHARACTER_REFERENCE_START:
897
- {
898
- this._stateHexademicalCharacterReferenceStart(cp);
899
- break;
900
- }
901
- case State.HEXADEMICAL_CHARACTER_REFERENCE:
902
- {
903
- this._stateHexademicalCharacterReference(cp);
904
- break;
905
- }
906
- case State.DECIMAL_CHARACTER_REFERENCE:
907
- {
908
- this._stateDecimalCharacterReference(cp);
909
- break;
910
- }
911
- case State.NUMERIC_CHARACTER_REFERENCE_END:
912
- {
913
- this._stateNumericCharacterReferenceEnd(cp);
914
- break;
915
- }
916
- default:
917
- {
918
- throw new Error('Unknown state');
919
- }
920
- }
921
- }
922
- // State machine
923
- // Data state
924
- //------------------------------------------------------------------
925
- _stateData(cp) {
926
- switch (cp) {
927
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
928
- {
929
- this.state = State.TAG_OPEN;
930
- break;
931
- }
932
- case unicode.CODE_POINTS.AMPERSAND:
933
- {
934
- this.returnState = State.DATA;
935
- this.state = State.CHARACTER_REFERENCE;
936
- break;
937
- }
938
- case unicode.CODE_POINTS.NULL:
939
- {
940
- this._err(errorCodes.ERR.unexpectedNullCharacter);
941
- this._emitCodePoint(cp);
942
- break;
943
- }
944
- case unicode.CODE_POINTS.EOF:
945
- {
946
- this._emitEOFToken();
947
- break;
948
- }
949
- default:
950
- {
951
- this._emitCodePoint(cp);
952
- }
953
- }
954
- }
955
- // RCDATA state
956
- //------------------------------------------------------------------
957
- _stateRcdata(cp) {
958
- switch (cp) {
959
- case unicode.CODE_POINTS.AMPERSAND:
960
- {
961
- this.returnState = State.RCDATA;
962
- this.state = State.CHARACTER_REFERENCE;
963
- break;
964
- }
965
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
966
- {
967
- this.state = State.RCDATA_LESS_THAN_SIGN;
968
- break;
969
- }
970
- case unicode.CODE_POINTS.NULL:
971
- {
972
- this._err(errorCodes.ERR.unexpectedNullCharacter);
973
- this._emitChars(unicode.REPLACEMENT_CHARACTER);
974
- break;
975
- }
976
- case unicode.CODE_POINTS.EOF:
977
- {
978
- this._emitEOFToken();
979
- break;
980
- }
981
- default:
982
- {
983
- this._emitCodePoint(cp);
984
- }
985
- }
986
- }
987
- // RAWTEXT state
988
- //------------------------------------------------------------------
989
- _stateRawtext(cp) {
990
- switch (cp) {
991
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
992
- {
993
- this.state = State.RAWTEXT_LESS_THAN_SIGN;
994
- break;
995
- }
996
- case unicode.CODE_POINTS.NULL:
997
- {
998
- this._err(errorCodes.ERR.unexpectedNullCharacter);
999
- this._emitChars(unicode.REPLACEMENT_CHARACTER);
1000
- break;
1001
- }
1002
- case unicode.CODE_POINTS.EOF:
1003
- {
1004
- this._emitEOFToken();
1005
- break;
1006
- }
1007
- default:
1008
- {
1009
- this._emitCodePoint(cp);
1010
- }
1011
- }
1012
- }
1013
- // Script data state
1014
- //------------------------------------------------------------------
1015
- _stateScriptData(cp) {
1016
- switch (cp) {
1017
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
1018
- {
1019
- this.state = State.SCRIPT_DATA_LESS_THAN_SIGN;
1020
- break;
1021
- }
1022
- case unicode.CODE_POINTS.NULL:
1023
- {
1024
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1025
- this._emitChars(unicode.REPLACEMENT_CHARACTER);
1026
- break;
1027
- }
1028
- case unicode.CODE_POINTS.EOF:
1029
- {
1030
- this._emitEOFToken();
1031
- break;
1032
- }
1033
- default:
1034
- {
1035
- this._emitCodePoint(cp);
1036
- }
1037
- }
1038
- }
1039
- // PLAINTEXT state
1040
- //------------------------------------------------------------------
1041
- _statePlaintext(cp) {
1042
- switch (cp) {
1043
- case unicode.CODE_POINTS.NULL:
1044
- {
1045
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1046
- this._emitChars(unicode.REPLACEMENT_CHARACTER);
1047
- break;
1048
- }
1049
- case unicode.CODE_POINTS.EOF:
1050
- {
1051
- this._emitEOFToken();
1052
- break;
1053
- }
1054
- default:
1055
- {
1056
- this._emitCodePoint(cp);
1057
- }
1058
- }
1059
- }
1060
- // Tag open state
1061
- //------------------------------------------------------------------
1062
- _stateTagOpen(cp) {
1063
- if (isAsciiLetter(cp)) {
1064
- this._createStartTagToken();
1065
- this.state = State.TAG_NAME;
1066
- this._stateTagName(cp);
1067
- } else switch (cp) {
1068
- case unicode.CODE_POINTS.EXCLAMATION_MARK:
1069
- {
1070
- this.state = State.MARKUP_DECLARATION_OPEN;
1071
- break;
1072
- }
1073
- case unicode.CODE_POINTS.SOLIDUS:
1074
- {
1075
- this.state = State.END_TAG_OPEN;
1076
- break;
1077
- }
1078
- case unicode.CODE_POINTS.QUESTION_MARK:
1079
- {
1080
- this._err(errorCodes.ERR.unexpectedQuestionMarkInsteadOfTagName);
1081
- this._createCommentToken(1);
1082
- this.state = State.BOGUS_COMMENT;
1083
- this._stateBogusComment(cp);
1084
- break;
1085
- }
1086
- case unicode.CODE_POINTS.EOF:
1087
- {
1088
- this._err(errorCodes.ERR.eofBeforeTagName);
1089
- this._emitChars('<');
1090
- this._emitEOFToken();
1091
- break;
1092
- }
1093
- default:
1094
- {
1095
- this._err(errorCodes.ERR.invalidFirstCharacterOfTagName);
1096
- this._emitChars('<');
1097
- this.state = State.DATA;
1098
- this._stateData(cp);
1099
- }
1100
- }
1101
- }
1102
- // End tag open state
1103
- //------------------------------------------------------------------
1104
- _stateEndTagOpen(cp) {
1105
- if (isAsciiLetter(cp)) {
1106
- this._createEndTagToken();
1107
- this.state = State.TAG_NAME;
1108
- this._stateTagName(cp);
1109
- } else switch (cp) {
1110
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1111
- {
1112
- this._err(errorCodes.ERR.missingEndTagName);
1113
- this.state = State.DATA;
1114
- break;
1115
- }
1116
- case unicode.CODE_POINTS.EOF:
1117
- {
1118
- this._err(errorCodes.ERR.eofBeforeTagName);
1119
- this._emitChars('</');
1120
- this._emitEOFToken();
1121
- break;
1122
- }
1123
- default:
1124
- {
1125
- this._err(errorCodes.ERR.invalidFirstCharacterOfTagName);
1126
- this._createCommentToken(2);
1127
- this.state = State.BOGUS_COMMENT;
1128
- this._stateBogusComment(cp);
1129
- }
1130
- }
1131
- }
1132
- // Tag name state
1133
- //------------------------------------------------------------------
1134
- _stateTagName(cp) {
1135
- const token = this.currentToken;
1136
- switch (cp) {
1137
- case unicode.CODE_POINTS.SPACE:
1138
- case unicode.CODE_POINTS.LINE_FEED:
1139
- case unicode.CODE_POINTS.TABULATION:
1140
- case unicode.CODE_POINTS.FORM_FEED:
1141
- {
1142
- this.state = State.BEFORE_ATTRIBUTE_NAME;
1143
- break;
1144
- }
1145
- case unicode.CODE_POINTS.SOLIDUS:
1146
- {
1147
- this.state = State.SELF_CLOSING_START_TAG;
1148
- break;
1149
- }
1150
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1151
- {
1152
- this.state = State.DATA;
1153
- this.emitCurrentTagToken();
1154
- break;
1155
- }
1156
- case unicode.CODE_POINTS.NULL:
1157
- {
1158
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1159
- token.tagName += unicode.REPLACEMENT_CHARACTER;
1160
- break;
1161
- }
1162
- case unicode.CODE_POINTS.EOF:
1163
- {
1164
- this._err(errorCodes.ERR.eofInTag);
1165
- this._emitEOFToken();
1166
- break;
1167
- }
1168
- default:
1169
- {
1170
- token.tagName += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
1171
- }
1172
- }
1173
- }
1174
- // RCDATA less-than sign state
1175
- //------------------------------------------------------------------
1176
- _stateRcdataLessThanSign(cp) {
1177
- if (cp === unicode.CODE_POINTS.SOLIDUS) {
1178
- this.state = State.RCDATA_END_TAG_OPEN;
1179
- } else {
1180
- this._emitChars('<');
1181
- this.state = State.RCDATA;
1182
- this._stateRcdata(cp);
1183
- }
1184
- }
1185
- // RCDATA end tag open state
1186
- //------------------------------------------------------------------
1187
- _stateRcdataEndTagOpen(cp) {
1188
- if (isAsciiLetter(cp)) {
1189
- this.state = State.RCDATA_END_TAG_NAME;
1190
- this._stateRcdataEndTagName(cp);
1191
- } else {
1192
- this._emitChars('</');
1193
- this.state = State.RCDATA;
1194
- this._stateRcdata(cp);
1195
- }
1196
- }
1197
- handleSpecialEndTag(_cp) {
1198
- if (!this.preprocessor.startsWith(this.lastStartTagName, false)) {
1199
- return !this._ensureHibernation();
1200
- }
1201
- this._createEndTagToken();
1202
- const token = this.currentToken;
1203
- token.tagName = this.lastStartTagName;
1204
- const cp = this.preprocessor.peek(this.lastStartTagName.length);
1205
- switch (cp) {
1206
- case unicode.CODE_POINTS.SPACE:
1207
- case unicode.CODE_POINTS.LINE_FEED:
1208
- case unicode.CODE_POINTS.TABULATION:
1209
- case unicode.CODE_POINTS.FORM_FEED:
1210
- {
1211
- this._advanceBy(this.lastStartTagName.length);
1212
- this.state = State.BEFORE_ATTRIBUTE_NAME;
1213
- return false;
1214
- }
1215
- case unicode.CODE_POINTS.SOLIDUS:
1216
- {
1217
- this._advanceBy(this.lastStartTagName.length);
1218
- this.state = State.SELF_CLOSING_START_TAG;
1219
- return false;
1220
- }
1221
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1222
- {
1223
- this._advanceBy(this.lastStartTagName.length);
1224
- this.emitCurrentTagToken();
1225
- this.state = State.DATA;
1226
- return false;
1227
- }
1228
- default:
1229
- {
1230
- return !this._ensureHibernation();
1231
- }
1232
- }
1233
- }
1234
- // RCDATA end tag name state
1235
- //------------------------------------------------------------------
1236
- _stateRcdataEndTagName(cp) {
1237
- if (this.handleSpecialEndTag(cp)) {
1238
- this._emitChars('</');
1239
- this.state = State.RCDATA;
1240
- this._stateRcdata(cp);
1241
- }
1242
- }
1243
- // RAWTEXT less-than sign state
1244
- //------------------------------------------------------------------
1245
- _stateRawtextLessThanSign(cp) {
1246
- if (cp === unicode.CODE_POINTS.SOLIDUS) {
1247
- this.state = State.RAWTEXT_END_TAG_OPEN;
1248
- } else {
1249
- this._emitChars('<');
1250
- this.state = State.RAWTEXT;
1251
- this._stateRawtext(cp);
1252
- }
1253
- }
1254
- // RAWTEXT end tag open state
1255
- //------------------------------------------------------------------
1256
- _stateRawtextEndTagOpen(cp) {
1257
- if (isAsciiLetter(cp)) {
1258
- this.state = State.RAWTEXT_END_TAG_NAME;
1259
- this._stateRawtextEndTagName(cp);
1260
- } else {
1261
- this._emitChars('</');
1262
- this.state = State.RAWTEXT;
1263
- this._stateRawtext(cp);
1264
- }
1265
- }
1266
- // RAWTEXT end tag name state
1267
- //------------------------------------------------------------------
1268
- _stateRawtextEndTagName(cp) {
1269
- if (this.handleSpecialEndTag(cp)) {
1270
- this._emitChars('</');
1271
- this.state = State.RAWTEXT;
1272
- this._stateRawtext(cp);
1273
- }
1274
- }
1275
- // Script data less-than sign state
1276
- //------------------------------------------------------------------
1277
- _stateScriptDataLessThanSign(cp) {
1278
- switch (cp) {
1279
- case unicode.CODE_POINTS.SOLIDUS:
1280
- {
1281
- this.state = State.SCRIPT_DATA_END_TAG_OPEN;
1282
- break;
1283
- }
1284
- case unicode.CODE_POINTS.EXCLAMATION_MARK:
1285
- {
1286
- this.state = State.SCRIPT_DATA_ESCAPE_START;
1287
- this._emitChars('<!');
1288
- break;
1289
- }
1290
- default:
1291
- {
1292
- this._emitChars('<');
1293
- this.state = State.SCRIPT_DATA;
1294
- this._stateScriptData(cp);
1295
- }
1296
- }
1297
- }
1298
- // Script data end tag open state
1299
- //------------------------------------------------------------------
1300
- _stateScriptDataEndTagOpen(cp) {
1301
- if (isAsciiLetter(cp)) {
1302
- this.state = State.SCRIPT_DATA_END_TAG_NAME;
1303
- this._stateScriptDataEndTagName(cp);
1304
- } else {
1305
- this._emitChars('</');
1306
- this.state = State.SCRIPT_DATA;
1307
- this._stateScriptData(cp);
1308
- }
1309
- }
1310
- // Script data end tag name state
1311
- //------------------------------------------------------------------
1312
- _stateScriptDataEndTagName(cp) {
1313
- if (this.handleSpecialEndTag(cp)) {
1314
- this._emitChars('</');
1315
- this.state = State.SCRIPT_DATA;
1316
- this._stateScriptData(cp);
1317
- }
1318
- }
1319
- // Script data escape start state
1320
- //------------------------------------------------------------------
1321
- _stateScriptDataEscapeStart(cp) {
1322
- if (cp === unicode.CODE_POINTS.HYPHEN_MINUS) {
1323
- this.state = State.SCRIPT_DATA_ESCAPE_START_DASH;
1324
- this._emitChars('-');
1325
- } else {
1326
- this.state = State.SCRIPT_DATA;
1327
- this._stateScriptData(cp);
1328
- }
1329
- }
1330
- // Script data escape start dash state
1331
- //------------------------------------------------------------------
1332
- _stateScriptDataEscapeStartDash(cp) {
1333
- if (cp === unicode.CODE_POINTS.HYPHEN_MINUS) {
1334
- this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
1335
- this._emitChars('-');
1336
- } else {
1337
- this.state = State.SCRIPT_DATA;
1338
- this._stateScriptData(cp);
1339
- }
1340
- }
1341
- // Script data escaped state
1342
- //------------------------------------------------------------------
1343
- _stateScriptDataEscaped(cp) {
1344
- switch (cp) {
1345
- case unicode.CODE_POINTS.HYPHEN_MINUS:
1346
- {
1347
- this.state = State.SCRIPT_DATA_ESCAPED_DASH;
1348
- this._emitChars('-');
1349
- break;
1350
- }
1351
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
1352
- {
1353
- this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
1354
- break;
1355
- }
1356
- case unicode.CODE_POINTS.NULL:
1357
- {
1358
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1359
- this._emitChars(unicode.REPLACEMENT_CHARACTER);
1360
- break;
1361
- }
1362
- case unicode.CODE_POINTS.EOF:
1363
- {
1364
- this._err(errorCodes.ERR.eofInScriptHtmlCommentLikeText);
1365
- this._emitEOFToken();
1366
- break;
1367
- }
1368
- default:
1369
- {
1370
- this._emitCodePoint(cp);
1371
- }
1372
- }
1373
- }
1374
- // Script data escaped dash state
1375
- //------------------------------------------------------------------
1376
- _stateScriptDataEscapedDash(cp) {
1377
- switch (cp) {
1378
- case unicode.CODE_POINTS.HYPHEN_MINUS:
1379
- {
1380
- this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
1381
- this._emitChars('-');
1382
- break;
1383
- }
1384
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
1385
- {
1386
- this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
1387
- break;
1388
- }
1389
- case unicode.CODE_POINTS.NULL:
1390
- {
1391
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1392
- this.state = State.SCRIPT_DATA_ESCAPED;
1393
- this._emitChars(unicode.REPLACEMENT_CHARACTER);
1394
- break;
1395
- }
1396
- case unicode.CODE_POINTS.EOF:
1397
- {
1398
- this._err(errorCodes.ERR.eofInScriptHtmlCommentLikeText);
1399
- this._emitEOFToken();
1400
- break;
1401
- }
1402
- default:
1403
- {
1404
- this.state = State.SCRIPT_DATA_ESCAPED;
1405
- this._emitCodePoint(cp);
1406
- }
1407
- }
1408
- }
1409
- // Script data escaped dash dash state
1410
- //------------------------------------------------------------------
1411
- _stateScriptDataEscapedDashDash(cp) {
1412
- switch (cp) {
1413
- case unicode.CODE_POINTS.HYPHEN_MINUS:
1414
- {
1415
- this._emitChars('-');
1416
- break;
1417
- }
1418
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
1419
- {
1420
- this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
1421
- break;
1422
- }
1423
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1424
- {
1425
- this.state = State.SCRIPT_DATA;
1426
- this._emitChars('>');
1427
- break;
1428
- }
1429
- case unicode.CODE_POINTS.NULL:
1430
- {
1431
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1432
- this.state = State.SCRIPT_DATA_ESCAPED;
1433
- this._emitChars(unicode.REPLACEMENT_CHARACTER);
1434
- break;
1435
- }
1436
- case unicode.CODE_POINTS.EOF:
1437
- {
1438
- this._err(errorCodes.ERR.eofInScriptHtmlCommentLikeText);
1439
- this._emitEOFToken();
1440
- break;
1441
- }
1442
- default:
1443
- {
1444
- this.state = State.SCRIPT_DATA_ESCAPED;
1445
- this._emitCodePoint(cp);
1446
- }
1447
- }
1448
- }
1449
- // Script data escaped less-than sign state
1450
- //------------------------------------------------------------------
1451
- _stateScriptDataEscapedLessThanSign(cp) {
1452
- if (cp === unicode.CODE_POINTS.SOLIDUS) {
1453
- this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN;
1454
- } else if (isAsciiLetter(cp)) {
1455
- this._emitChars('<');
1456
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_START;
1457
- this._stateScriptDataDoubleEscapeStart(cp);
1458
- } else {
1459
- this._emitChars('<');
1460
- this.state = State.SCRIPT_DATA_ESCAPED;
1461
- this._stateScriptDataEscaped(cp);
1462
- }
1463
- }
1464
- // Script data escaped end tag open state
1465
- //------------------------------------------------------------------
1466
- _stateScriptDataEscapedEndTagOpen(cp) {
1467
- if (isAsciiLetter(cp)) {
1468
- this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_NAME;
1469
- this._stateScriptDataEscapedEndTagName(cp);
1470
- } else {
1471
- this._emitChars('</');
1472
- this.state = State.SCRIPT_DATA_ESCAPED;
1473
- this._stateScriptDataEscaped(cp);
1474
- }
1475
- }
1476
- // Script data escaped end tag name state
1477
- //------------------------------------------------------------------
1478
- _stateScriptDataEscapedEndTagName(cp) {
1479
- if (this.handleSpecialEndTag(cp)) {
1480
- this._emitChars('</');
1481
- this.state = State.SCRIPT_DATA_ESCAPED;
1482
- this._stateScriptDataEscaped(cp);
1483
- }
1484
- }
1485
- // Script data double escape start state
1486
- //------------------------------------------------------------------
1487
- _stateScriptDataDoubleEscapeStart(cp) {
1488
- if (this.preprocessor.startsWith(unicode.SEQUENCES.SCRIPT, false) && isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek(unicode.SEQUENCES.SCRIPT.length))) {
1489
- this._emitCodePoint(cp);
1490
- for (let i = 0; i < unicode.SEQUENCES.SCRIPT.length; i++) {
1491
- this._emitCodePoint(this._consume());
1492
- }
1493
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
1494
- } else if (!this._ensureHibernation()) {
1495
- this.state = State.SCRIPT_DATA_ESCAPED;
1496
- this._stateScriptDataEscaped(cp);
1497
- }
1498
- }
1499
- // Script data double escaped state
1500
- //------------------------------------------------------------------
1501
- _stateScriptDataDoubleEscaped(cp) {
1502
- switch (cp) {
1503
- case unicode.CODE_POINTS.HYPHEN_MINUS:
1504
- {
1505
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH;
1506
- this._emitChars('-');
1507
- break;
1508
- }
1509
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
1510
- {
1511
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
1512
- this._emitChars('<');
1513
- break;
1514
- }
1515
- case unicode.CODE_POINTS.NULL:
1516
- {
1517
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1518
- this._emitChars(unicode.REPLACEMENT_CHARACTER);
1519
- break;
1520
- }
1521
- case unicode.CODE_POINTS.EOF:
1522
- {
1523
- this._err(errorCodes.ERR.eofInScriptHtmlCommentLikeText);
1524
- this._emitEOFToken();
1525
- break;
1526
- }
1527
- default:
1528
- {
1529
- this._emitCodePoint(cp);
1530
- }
1531
- }
1532
- }
1533
- // Script data double escaped dash state
1534
- //------------------------------------------------------------------
1535
- _stateScriptDataDoubleEscapedDash(cp) {
1536
- switch (cp) {
1537
- case unicode.CODE_POINTS.HYPHEN_MINUS:
1538
- {
1539
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH;
1540
- this._emitChars('-');
1541
- break;
1542
- }
1543
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
1544
- {
1545
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
1546
- this._emitChars('<');
1547
- break;
1548
- }
1549
- case unicode.CODE_POINTS.NULL:
1550
- {
1551
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1552
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
1553
- this._emitChars(unicode.REPLACEMENT_CHARACTER);
1554
- break;
1555
- }
1556
- case unicode.CODE_POINTS.EOF:
1557
- {
1558
- this._err(errorCodes.ERR.eofInScriptHtmlCommentLikeText);
1559
- this._emitEOFToken();
1560
- break;
1561
- }
1562
- default:
1563
- {
1564
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
1565
- this._emitCodePoint(cp);
1566
- }
1567
- }
1568
- }
1569
- // Script data double escaped dash dash state
1570
- //------------------------------------------------------------------
1571
- _stateScriptDataDoubleEscapedDashDash(cp) {
1572
- switch (cp) {
1573
- case unicode.CODE_POINTS.HYPHEN_MINUS:
1574
- {
1575
- this._emitChars('-');
1576
- break;
1577
- }
1578
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
1579
- {
1580
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
1581
- this._emitChars('<');
1582
- break;
1583
- }
1584
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1585
- {
1586
- this.state = State.SCRIPT_DATA;
1587
- this._emitChars('>');
1588
- break;
1589
- }
1590
- case unicode.CODE_POINTS.NULL:
1591
- {
1592
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1593
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
1594
- this._emitChars(unicode.REPLACEMENT_CHARACTER);
1595
- break;
1596
- }
1597
- case unicode.CODE_POINTS.EOF:
1598
- {
1599
- this._err(errorCodes.ERR.eofInScriptHtmlCommentLikeText);
1600
- this._emitEOFToken();
1601
- break;
1602
- }
1603
- default:
1604
- {
1605
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
1606
- this._emitCodePoint(cp);
1607
- }
1608
- }
1609
- }
1610
- // Script data double escaped less-than sign state
1611
- //------------------------------------------------------------------
1612
- _stateScriptDataDoubleEscapedLessThanSign(cp) {
1613
- if (cp === unicode.CODE_POINTS.SOLIDUS) {
1614
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_END;
1615
- this._emitChars('/');
1616
- } else {
1617
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
1618
- this._stateScriptDataDoubleEscaped(cp);
1619
- }
1620
- }
1621
- // Script data double escape end state
1622
- //------------------------------------------------------------------
1623
- _stateScriptDataDoubleEscapeEnd(cp) {
1624
- if (this.preprocessor.startsWith(unicode.SEQUENCES.SCRIPT, false) && isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek(unicode.SEQUENCES.SCRIPT.length))) {
1625
- this._emitCodePoint(cp);
1626
- for (let i = 0; i < unicode.SEQUENCES.SCRIPT.length; i++) {
1627
- this._emitCodePoint(this._consume());
1628
- }
1629
- this.state = State.SCRIPT_DATA_ESCAPED;
1630
- } else if (!this._ensureHibernation()) {
1631
- this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
1632
- this._stateScriptDataDoubleEscaped(cp);
1633
- }
1634
- }
1635
- // Before attribute name state
1636
- //------------------------------------------------------------------
1637
- _stateBeforeAttributeName(cp) {
1638
- switch (cp) {
1639
- case unicode.CODE_POINTS.SPACE:
1640
- case unicode.CODE_POINTS.LINE_FEED:
1641
- case unicode.CODE_POINTS.TABULATION:
1642
- case unicode.CODE_POINTS.FORM_FEED:
1643
- {
1644
- // Ignore whitespace
1645
- break;
1646
- }
1647
- case unicode.CODE_POINTS.SOLIDUS:
1648
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1649
- case unicode.CODE_POINTS.EOF:
1650
- {
1651
- this.state = State.AFTER_ATTRIBUTE_NAME;
1652
- this._stateAfterAttributeName(cp);
1653
- break;
1654
- }
1655
- case unicode.CODE_POINTS.EQUALS_SIGN:
1656
- {
1657
- this._err(errorCodes.ERR.unexpectedEqualsSignBeforeAttributeName);
1658
- this._createAttr('=');
1659
- this.state = State.ATTRIBUTE_NAME;
1660
- break;
1661
- }
1662
- default:
1663
- {
1664
- this._createAttr('');
1665
- this.state = State.ATTRIBUTE_NAME;
1666
- this._stateAttributeName(cp);
1667
- }
1668
- }
1669
- }
1670
- // Attribute name state
1671
- //------------------------------------------------------------------
1672
- _stateAttributeName(cp) {
1673
- switch (cp) {
1674
- case unicode.CODE_POINTS.SPACE:
1675
- case unicode.CODE_POINTS.LINE_FEED:
1676
- case unicode.CODE_POINTS.TABULATION:
1677
- case unicode.CODE_POINTS.FORM_FEED:
1678
- case unicode.CODE_POINTS.SOLIDUS:
1679
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1680
- case unicode.CODE_POINTS.EOF:
1681
- {
1682
- this._leaveAttrName();
1683
- this.state = State.AFTER_ATTRIBUTE_NAME;
1684
- this._stateAfterAttributeName(cp);
1685
- break;
1686
- }
1687
- case unicode.CODE_POINTS.EQUALS_SIGN:
1688
- {
1689
- this._leaveAttrName();
1690
- this.state = State.BEFORE_ATTRIBUTE_VALUE;
1691
- break;
1692
- }
1693
- case unicode.CODE_POINTS.QUOTATION_MARK:
1694
- case unicode.CODE_POINTS.APOSTROPHE:
1695
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
1696
- {
1697
- this._err(errorCodes.ERR.unexpectedCharacterInAttributeName);
1698
- this.currentAttr.name += String.fromCodePoint(cp);
1699
- break;
1700
- }
1701
- case unicode.CODE_POINTS.NULL:
1702
- {
1703
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1704
- this.currentAttr.name += unicode.REPLACEMENT_CHARACTER;
1705
- break;
1706
- }
1707
- default:
1708
- {
1709
- this.currentAttr.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
1710
- }
1711
- }
1712
- }
1713
- // After attribute name state
1714
- //------------------------------------------------------------------
1715
- _stateAfterAttributeName(cp) {
1716
- switch (cp) {
1717
- case unicode.CODE_POINTS.SPACE:
1718
- case unicode.CODE_POINTS.LINE_FEED:
1719
- case unicode.CODE_POINTS.TABULATION:
1720
- case unicode.CODE_POINTS.FORM_FEED:
1721
- {
1722
- // Ignore whitespace
1723
- break;
1724
- }
1725
- case unicode.CODE_POINTS.SOLIDUS:
1726
- {
1727
- this.state = State.SELF_CLOSING_START_TAG;
1728
- break;
1729
- }
1730
- case unicode.CODE_POINTS.EQUALS_SIGN:
1731
- {
1732
- this.state = State.BEFORE_ATTRIBUTE_VALUE;
1733
- break;
1734
- }
1735
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1736
- {
1737
- this.state = State.DATA;
1738
- this.emitCurrentTagToken();
1739
- break;
1740
- }
1741
- case unicode.CODE_POINTS.EOF:
1742
- {
1743
- this._err(errorCodes.ERR.eofInTag);
1744
- this._emitEOFToken();
1745
- break;
1746
- }
1747
- default:
1748
- {
1749
- this._createAttr('');
1750
- this.state = State.ATTRIBUTE_NAME;
1751
- this._stateAttributeName(cp);
1752
- }
1753
- }
1754
- }
1755
- // Before attribute value state
1756
- //------------------------------------------------------------------
1757
- _stateBeforeAttributeValue(cp) {
1758
- switch (cp) {
1759
- case unicode.CODE_POINTS.SPACE:
1760
- case unicode.CODE_POINTS.LINE_FEED:
1761
- case unicode.CODE_POINTS.TABULATION:
1762
- case unicode.CODE_POINTS.FORM_FEED:
1763
- {
1764
- // Ignore whitespace
1765
- break;
1766
- }
1767
- case unicode.CODE_POINTS.QUOTATION_MARK:
1768
- {
1769
- this.state = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;
1770
- break;
1771
- }
1772
- case unicode.CODE_POINTS.APOSTROPHE:
1773
- {
1774
- this.state = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;
1775
- break;
1776
- }
1777
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1778
- {
1779
- this._err(errorCodes.ERR.missingAttributeValue);
1780
- this.state = State.DATA;
1781
- this.emitCurrentTagToken();
1782
- break;
1783
- }
1784
- default:
1785
- {
1786
- this.state = State.ATTRIBUTE_VALUE_UNQUOTED;
1787
- this._stateAttributeValueUnquoted(cp);
1788
- }
1789
- }
1790
- }
1791
- // Attribute value (double-quoted) state
1792
- //------------------------------------------------------------------
1793
- _stateAttributeValueDoubleQuoted(cp) {
1794
- switch (cp) {
1795
- case unicode.CODE_POINTS.QUOTATION_MARK:
1796
- {
1797
- this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
1798
- break;
1799
- }
1800
- case unicode.CODE_POINTS.AMPERSAND:
1801
- {
1802
- this.returnState = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;
1803
- this.state = State.CHARACTER_REFERENCE;
1804
- break;
1805
- }
1806
- case unicode.CODE_POINTS.NULL:
1807
- {
1808
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1809
- this.currentAttr.value += unicode.REPLACEMENT_CHARACTER;
1810
- break;
1811
- }
1812
- case unicode.CODE_POINTS.EOF:
1813
- {
1814
- this._err(errorCodes.ERR.eofInTag);
1815
- this._emitEOFToken();
1816
- break;
1817
- }
1818
- default:
1819
- {
1820
- this.currentAttr.value += String.fromCodePoint(cp);
1821
- }
1822
- }
1823
- }
1824
- // Attribute value (single-quoted) state
1825
- //------------------------------------------------------------------
1826
- _stateAttributeValueSingleQuoted(cp) {
1827
- switch (cp) {
1828
- case unicode.CODE_POINTS.APOSTROPHE:
1829
- {
1830
- this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
1831
- break;
1832
- }
1833
- case unicode.CODE_POINTS.AMPERSAND:
1834
- {
1835
- this.returnState = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;
1836
- this.state = State.CHARACTER_REFERENCE;
1837
- break;
1838
- }
1839
- case unicode.CODE_POINTS.NULL:
1840
- {
1841
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1842
- this.currentAttr.value += unicode.REPLACEMENT_CHARACTER;
1843
- break;
1844
- }
1845
- case unicode.CODE_POINTS.EOF:
1846
- {
1847
- this._err(errorCodes.ERR.eofInTag);
1848
- this._emitEOFToken();
1849
- break;
1850
- }
1851
- default:
1852
- {
1853
- this.currentAttr.value += String.fromCodePoint(cp);
1854
- }
1855
- }
1856
- }
1857
- // Attribute value (unquoted) state
1858
- //------------------------------------------------------------------
1859
- _stateAttributeValueUnquoted(cp) {
1860
- switch (cp) {
1861
- case unicode.CODE_POINTS.SPACE:
1862
- case unicode.CODE_POINTS.LINE_FEED:
1863
- case unicode.CODE_POINTS.TABULATION:
1864
- case unicode.CODE_POINTS.FORM_FEED:
1865
- {
1866
- this._leaveAttrValue();
1867
- this.state = State.BEFORE_ATTRIBUTE_NAME;
1868
- break;
1869
- }
1870
- case unicode.CODE_POINTS.AMPERSAND:
1871
- {
1872
- this.returnState = State.ATTRIBUTE_VALUE_UNQUOTED;
1873
- this.state = State.CHARACTER_REFERENCE;
1874
- break;
1875
- }
1876
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1877
- {
1878
- this._leaveAttrValue();
1879
- this.state = State.DATA;
1880
- this.emitCurrentTagToken();
1881
- break;
1882
- }
1883
- case unicode.CODE_POINTS.NULL:
1884
- {
1885
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1886
- this.currentAttr.value += unicode.REPLACEMENT_CHARACTER;
1887
- break;
1888
- }
1889
- case unicode.CODE_POINTS.QUOTATION_MARK:
1890
- case unicode.CODE_POINTS.APOSTROPHE:
1891
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
1892
- case unicode.CODE_POINTS.EQUALS_SIGN:
1893
- case unicode.CODE_POINTS.GRAVE_ACCENT:
1894
- {
1895
- this._err(errorCodes.ERR.unexpectedCharacterInUnquotedAttributeValue);
1896
- this.currentAttr.value += String.fromCodePoint(cp);
1897
- break;
1898
- }
1899
- case unicode.CODE_POINTS.EOF:
1900
- {
1901
- this._err(errorCodes.ERR.eofInTag);
1902
- this._emitEOFToken();
1903
- break;
1904
- }
1905
- default:
1906
- {
1907
- this.currentAttr.value += String.fromCodePoint(cp);
1908
- }
1909
- }
1910
- }
1911
- // After attribute value (quoted) state
1912
- //------------------------------------------------------------------
1913
- _stateAfterAttributeValueQuoted(cp) {
1914
- switch (cp) {
1915
- case unicode.CODE_POINTS.SPACE:
1916
- case unicode.CODE_POINTS.LINE_FEED:
1917
- case unicode.CODE_POINTS.TABULATION:
1918
- case unicode.CODE_POINTS.FORM_FEED:
1919
- {
1920
- this._leaveAttrValue();
1921
- this.state = State.BEFORE_ATTRIBUTE_NAME;
1922
- break;
1923
- }
1924
- case unicode.CODE_POINTS.SOLIDUS:
1925
- {
1926
- this._leaveAttrValue();
1927
- this.state = State.SELF_CLOSING_START_TAG;
1928
- break;
1929
- }
1930
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1931
- {
1932
- this._leaveAttrValue();
1933
- this.state = State.DATA;
1934
- this.emitCurrentTagToken();
1935
- break;
1936
- }
1937
- case unicode.CODE_POINTS.EOF:
1938
- {
1939
- this._err(errorCodes.ERR.eofInTag);
1940
- this._emitEOFToken();
1941
- break;
1942
- }
1943
- default:
1944
- {
1945
- this._err(errorCodes.ERR.missingWhitespaceBetweenAttributes);
1946
- this.state = State.BEFORE_ATTRIBUTE_NAME;
1947
- this._stateBeforeAttributeName(cp);
1948
- }
1949
- }
1950
- }
1951
- // Self-closing start tag state
1952
- //------------------------------------------------------------------
1953
- _stateSelfClosingStartTag(cp) {
1954
- switch (cp) {
1955
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1956
- {
1957
- const token = this.currentToken;
1958
- token.selfClosing = true;
1959
- this.state = State.DATA;
1960
- this.emitCurrentTagToken();
1961
- break;
1962
- }
1963
- case unicode.CODE_POINTS.EOF:
1964
- {
1965
- this._err(errorCodes.ERR.eofInTag);
1966
- this._emitEOFToken();
1967
- break;
1968
- }
1969
- default:
1970
- {
1971
- this._err(errorCodes.ERR.unexpectedSolidusInTag);
1972
- this.state = State.BEFORE_ATTRIBUTE_NAME;
1973
- this._stateBeforeAttributeName(cp);
1974
- }
1975
- }
1976
- }
1977
- // Bogus comment state
1978
- //------------------------------------------------------------------
1979
- _stateBogusComment(cp) {
1980
- const token = this.currentToken;
1981
- switch (cp) {
1982
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
1983
- {
1984
- this.state = State.DATA;
1985
- this.emitCurrentComment(token);
1986
- break;
1987
- }
1988
- case unicode.CODE_POINTS.EOF:
1989
- {
1990
- this.emitCurrentComment(token);
1991
- this._emitEOFToken();
1992
- break;
1993
- }
1994
- case unicode.CODE_POINTS.NULL:
1995
- {
1996
- this._err(errorCodes.ERR.unexpectedNullCharacter);
1997
- token.data += unicode.REPLACEMENT_CHARACTER;
1998
- break;
1999
- }
2000
- default:
2001
- {
2002
- token.data += String.fromCodePoint(cp);
2003
- }
2004
- }
2005
- }
2006
- // Markup declaration open state
2007
- //------------------------------------------------------------------
2008
- _stateMarkupDeclarationOpen(cp) {
2009
- if (this._consumeSequenceIfMatch(unicode.SEQUENCES.DASH_DASH, true)) {
2010
- this._createCommentToken(unicode.SEQUENCES.DASH_DASH.length + 1);
2011
- this.state = State.COMMENT_START;
2012
- } else if (this._consumeSequenceIfMatch(unicode.SEQUENCES.DOCTYPE, false)) {
2013
- // NOTE: Doctypes tokens are created without fixed offsets. We keep track of the moment a doctype *might* start here.
2014
- this.currentLocation = this.getCurrentLocation(unicode.SEQUENCES.DOCTYPE.length + 1);
2015
- this.state = State.DOCTYPE;
2016
- } else if (this._consumeSequenceIfMatch(unicode.SEQUENCES.CDATA_START, true)) {
2017
- if (this.inForeignNode) {
2018
- this.state = State.CDATA_SECTION;
2019
- } else {
2020
- this._err(errorCodes.ERR.cdataInHtmlContent);
2021
- this._createCommentToken(unicode.SEQUENCES.CDATA_START.length + 1);
2022
- this.currentToken.data = '[CDATA[';
2023
- this.state = State.BOGUS_COMMENT;
2024
- }
2025
- }
2026
- //NOTE: Sequence lookups can be abrupted by hibernation. In that case, lookup
2027
- //results are no longer valid and we will need to start over.
2028
- else if (!this._ensureHibernation()) {
2029
- this._err(errorCodes.ERR.incorrectlyOpenedComment);
2030
- this._createCommentToken(2);
2031
- this.state = State.BOGUS_COMMENT;
2032
- this._stateBogusComment(cp);
2033
- }
2034
- }
2035
- // Comment start state
2036
- //------------------------------------------------------------------
2037
- _stateCommentStart(cp) {
2038
- switch (cp) {
2039
- case unicode.CODE_POINTS.HYPHEN_MINUS:
2040
- {
2041
- this.state = State.COMMENT_START_DASH;
2042
- break;
2043
- }
2044
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2045
- {
2046
- this._err(errorCodes.ERR.abruptClosingOfEmptyComment);
2047
- this.state = State.DATA;
2048
- const token = this.currentToken;
2049
- this.emitCurrentComment(token);
2050
- break;
2051
- }
2052
- default:
2053
- {
2054
- this.state = State.COMMENT;
2055
- this._stateComment(cp);
2056
- }
2057
- }
2058
- }
2059
- // Comment start dash state
2060
- //------------------------------------------------------------------
2061
- _stateCommentStartDash(cp) {
2062
- const token = this.currentToken;
2063
- switch (cp) {
2064
- case unicode.CODE_POINTS.HYPHEN_MINUS:
2065
- {
2066
- this.state = State.COMMENT_END;
2067
- break;
2068
- }
2069
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2070
- {
2071
- this._err(errorCodes.ERR.abruptClosingOfEmptyComment);
2072
- this.state = State.DATA;
2073
- this.emitCurrentComment(token);
2074
- break;
2075
- }
2076
- case unicode.CODE_POINTS.EOF:
2077
- {
2078
- this._err(errorCodes.ERR.eofInComment);
2079
- this.emitCurrentComment(token);
2080
- this._emitEOFToken();
2081
- break;
2082
- }
2083
- default:
2084
- {
2085
- token.data += '-';
2086
- this.state = State.COMMENT;
2087
- this._stateComment(cp);
2088
- }
2089
- }
2090
- }
2091
- // Comment state
2092
- //------------------------------------------------------------------
2093
- _stateComment(cp) {
2094
- const token = this.currentToken;
2095
- switch (cp) {
2096
- case unicode.CODE_POINTS.HYPHEN_MINUS:
2097
- {
2098
- this.state = State.COMMENT_END_DASH;
2099
- break;
2100
- }
2101
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
2102
- {
2103
- token.data += '<';
2104
- this.state = State.COMMENT_LESS_THAN_SIGN;
2105
- break;
2106
- }
2107
- case unicode.CODE_POINTS.NULL:
2108
- {
2109
- this._err(errorCodes.ERR.unexpectedNullCharacter);
2110
- token.data += unicode.REPLACEMENT_CHARACTER;
2111
- break;
2112
- }
2113
- case unicode.CODE_POINTS.EOF:
2114
- {
2115
- this._err(errorCodes.ERR.eofInComment);
2116
- this.emitCurrentComment(token);
2117
- this._emitEOFToken();
2118
- break;
2119
- }
2120
- default:
2121
- {
2122
- token.data += String.fromCodePoint(cp);
2123
- }
2124
- }
2125
- }
2126
- // Comment less-than sign state
2127
- //------------------------------------------------------------------
2128
- _stateCommentLessThanSign(cp) {
2129
- const token = this.currentToken;
2130
- switch (cp) {
2131
- case unicode.CODE_POINTS.EXCLAMATION_MARK:
2132
- {
2133
- token.data += '!';
2134
- this.state = State.COMMENT_LESS_THAN_SIGN_BANG;
2135
- break;
2136
- }
2137
- case unicode.CODE_POINTS.LESS_THAN_SIGN:
2138
- {
2139
- token.data += '<';
2140
- break;
2141
- }
2142
- default:
2143
- {
2144
- this.state = State.COMMENT;
2145
- this._stateComment(cp);
2146
- }
2147
- }
2148
- }
2149
- // Comment less-than sign bang state
2150
- //------------------------------------------------------------------
2151
- _stateCommentLessThanSignBang(cp) {
2152
- if (cp === unicode.CODE_POINTS.HYPHEN_MINUS) {
2153
- this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH;
2154
- } else {
2155
- this.state = State.COMMENT;
2156
- this._stateComment(cp);
2157
- }
2158
- }
2159
- // Comment less-than sign bang dash state
2160
- //------------------------------------------------------------------
2161
- _stateCommentLessThanSignBangDash(cp) {
2162
- if (cp === unicode.CODE_POINTS.HYPHEN_MINUS) {
2163
- this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH;
2164
- } else {
2165
- this.state = State.COMMENT_END_DASH;
2166
- this._stateCommentEndDash(cp);
2167
- }
2168
- }
2169
- // Comment less-than sign bang dash dash state
2170
- //------------------------------------------------------------------
2171
- _stateCommentLessThanSignBangDashDash(cp) {
2172
- if (cp !== unicode.CODE_POINTS.GREATER_THAN_SIGN && cp !== unicode.CODE_POINTS.EOF) {
2173
- this._err(errorCodes.ERR.nestedComment);
2174
- }
2175
- this.state = State.COMMENT_END;
2176
- this._stateCommentEnd(cp);
2177
- }
2178
- // Comment end dash state
2179
- //------------------------------------------------------------------
2180
- _stateCommentEndDash(cp) {
2181
- const token = this.currentToken;
2182
- switch (cp) {
2183
- case unicode.CODE_POINTS.HYPHEN_MINUS:
2184
- {
2185
- this.state = State.COMMENT_END;
2186
- break;
2187
- }
2188
- case unicode.CODE_POINTS.EOF:
2189
- {
2190
- this._err(errorCodes.ERR.eofInComment);
2191
- this.emitCurrentComment(token);
2192
- this._emitEOFToken();
2193
- break;
2194
- }
2195
- default:
2196
- {
2197
- token.data += '-';
2198
- this.state = State.COMMENT;
2199
- this._stateComment(cp);
2200
- }
2201
- }
2202
- }
2203
- // Comment end state
2204
- //------------------------------------------------------------------
2205
- _stateCommentEnd(cp) {
2206
- const token = this.currentToken;
2207
- switch (cp) {
2208
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2209
- {
2210
- this.state = State.DATA;
2211
- this.emitCurrentComment(token);
2212
- break;
2213
- }
2214
- case unicode.CODE_POINTS.EXCLAMATION_MARK:
2215
- {
2216
- this.state = State.COMMENT_END_BANG;
2217
- break;
2218
- }
2219
- case unicode.CODE_POINTS.HYPHEN_MINUS:
2220
- {
2221
- token.data += '-';
2222
- break;
2223
- }
2224
- case unicode.CODE_POINTS.EOF:
2225
- {
2226
- this._err(errorCodes.ERR.eofInComment);
2227
- this.emitCurrentComment(token);
2228
- this._emitEOFToken();
2229
- break;
2230
- }
2231
- default:
2232
- {
2233
- token.data += '--';
2234
- this.state = State.COMMENT;
2235
- this._stateComment(cp);
2236
- }
2237
- }
2238
- }
2239
- // Comment end bang state
2240
- //------------------------------------------------------------------
2241
- _stateCommentEndBang(cp) {
2242
- const token = this.currentToken;
2243
- switch (cp) {
2244
- case unicode.CODE_POINTS.HYPHEN_MINUS:
2245
- {
2246
- token.data += '--!';
2247
- this.state = State.COMMENT_END_DASH;
2248
- break;
2249
- }
2250
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2251
- {
2252
- this._err(errorCodes.ERR.incorrectlyClosedComment);
2253
- this.state = State.DATA;
2254
- this.emitCurrentComment(token);
2255
- break;
2256
- }
2257
- case unicode.CODE_POINTS.EOF:
2258
- {
2259
- this._err(errorCodes.ERR.eofInComment);
2260
- this.emitCurrentComment(token);
2261
- this._emitEOFToken();
2262
- break;
2263
- }
2264
- default:
2265
- {
2266
- token.data += '--!';
2267
- this.state = State.COMMENT;
2268
- this._stateComment(cp);
2269
- }
2270
- }
2271
- }
2272
- // DOCTYPE state
2273
- //------------------------------------------------------------------
2274
- _stateDoctype(cp) {
2275
- switch (cp) {
2276
- case unicode.CODE_POINTS.SPACE:
2277
- case unicode.CODE_POINTS.LINE_FEED:
2278
- case unicode.CODE_POINTS.TABULATION:
2279
- case unicode.CODE_POINTS.FORM_FEED:
2280
- {
2281
- this.state = State.BEFORE_DOCTYPE_NAME;
2282
- break;
2283
- }
2284
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2285
- {
2286
- this.state = State.BEFORE_DOCTYPE_NAME;
2287
- this._stateBeforeDoctypeName(cp);
2288
- break;
2289
- }
2290
- case unicode.CODE_POINTS.EOF:
2291
- {
2292
- this._err(errorCodes.ERR.eofInDoctype);
2293
- this._createDoctypeToken(null);
2294
- const token = this.currentToken;
2295
- token.forceQuirks = true;
2296
- this.emitCurrentDoctype(token);
2297
- this._emitEOFToken();
2298
- break;
2299
- }
2300
- default:
2301
- {
2302
- this._err(errorCodes.ERR.missingWhitespaceBeforeDoctypeName);
2303
- this.state = State.BEFORE_DOCTYPE_NAME;
2304
- this._stateBeforeDoctypeName(cp);
2305
- }
2306
- }
2307
- }
2308
- // Before DOCTYPE name state
2309
- //------------------------------------------------------------------
2310
- _stateBeforeDoctypeName(cp) {
2311
- if (isAsciiUpper(cp)) {
2312
- this._createDoctypeToken(String.fromCharCode(toAsciiLower(cp)));
2313
- this.state = State.DOCTYPE_NAME;
2314
- } else switch (cp) {
2315
- case unicode.CODE_POINTS.SPACE:
2316
- case unicode.CODE_POINTS.LINE_FEED:
2317
- case unicode.CODE_POINTS.TABULATION:
2318
- case unicode.CODE_POINTS.FORM_FEED:
2319
- {
2320
- // Ignore whitespace
2321
- break;
2322
- }
2323
- case unicode.CODE_POINTS.NULL:
2324
- {
2325
- this._err(errorCodes.ERR.unexpectedNullCharacter);
2326
- this._createDoctypeToken(unicode.REPLACEMENT_CHARACTER);
2327
- this.state = State.DOCTYPE_NAME;
2328
- break;
2329
- }
2330
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2331
- {
2332
- this._err(errorCodes.ERR.missingDoctypeName);
2333
- this._createDoctypeToken(null);
2334
- const token = this.currentToken;
2335
- token.forceQuirks = true;
2336
- this.emitCurrentDoctype(token);
2337
- this.state = State.DATA;
2338
- break;
2339
- }
2340
- case unicode.CODE_POINTS.EOF:
2341
- {
2342
- this._err(errorCodes.ERR.eofInDoctype);
2343
- this._createDoctypeToken(null);
2344
- const token = this.currentToken;
2345
- token.forceQuirks = true;
2346
- this.emitCurrentDoctype(token);
2347
- this._emitEOFToken();
2348
- break;
2349
- }
2350
- default:
2351
- {
2352
- this._createDoctypeToken(String.fromCodePoint(cp));
2353
- this.state = State.DOCTYPE_NAME;
2354
- }
2355
- }
2356
- }
2357
- // DOCTYPE name state
2358
- //------------------------------------------------------------------
2359
- _stateDoctypeName(cp) {
2360
- const token = this.currentToken;
2361
- switch (cp) {
2362
- case unicode.CODE_POINTS.SPACE:
2363
- case unicode.CODE_POINTS.LINE_FEED:
2364
- case unicode.CODE_POINTS.TABULATION:
2365
- case unicode.CODE_POINTS.FORM_FEED:
2366
- {
2367
- this.state = State.AFTER_DOCTYPE_NAME;
2368
- break;
2369
- }
2370
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2371
- {
2372
- this.state = State.DATA;
2373
- this.emitCurrentDoctype(token);
2374
- break;
2375
- }
2376
- case unicode.CODE_POINTS.NULL:
2377
- {
2378
- this._err(errorCodes.ERR.unexpectedNullCharacter);
2379
- token.name += unicode.REPLACEMENT_CHARACTER;
2380
- break;
2381
- }
2382
- case unicode.CODE_POINTS.EOF:
2383
- {
2384
- this._err(errorCodes.ERR.eofInDoctype);
2385
- token.forceQuirks = true;
2386
- this.emitCurrentDoctype(token);
2387
- this._emitEOFToken();
2388
- break;
2389
- }
2390
- default:
2391
- {
2392
- token.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
2393
- }
2394
- }
2395
- }
2396
- // After DOCTYPE name state
2397
- //------------------------------------------------------------------
2398
- _stateAfterDoctypeName(cp) {
2399
- const token = this.currentToken;
2400
- switch (cp) {
2401
- case unicode.CODE_POINTS.SPACE:
2402
- case unicode.CODE_POINTS.LINE_FEED:
2403
- case unicode.CODE_POINTS.TABULATION:
2404
- case unicode.CODE_POINTS.FORM_FEED:
2405
- {
2406
- // Ignore whitespace
2407
- break;
2408
- }
2409
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2410
- {
2411
- this.state = State.DATA;
2412
- this.emitCurrentDoctype(token);
2413
- break;
2414
- }
2415
- case unicode.CODE_POINTS.EOF:
2416
- {
2417
- this._err(errorCodes.ERR.eofInDoctype);
2418
- token.forceQuirks = true;
2419
- this.emitCurrentDoctype(token);
2420
- this._emitEOFToken();
2421
- break;
2422
- }
2423
- default:
2424
- {
2425
- if (this._consumeSequenceIfMatch(unicode.SEQUENCES.PUBLIC, false)) {
2426
- this.state = State.AFTER_DOCTYPE_PUBLIC_KEYWORD;
2427
- } else if (this._consumeSequenceIfMatch(unicode.SEQUENCES.SYSTEM, false)) {
2428
- this.state = State.AFTER_DOCTYPE_SYSTEM_KEYWORD;
2429
- }
2430
- //NOTE: sequence lookup can be abrupted by hibernation. In that case lookup
2431
- //results are no longer valid and we will need to start over.
2432
- else if (!this._ensureHibernation()) {
2433
- this._err(errorCodes.ERR.invalidCharacterSequenceAfterDoctypeName);
2434
- token.forceQuirks = true;
2435
- this.state = State.BOGUS_DOCTYPE;
2436
- this._stateBogusDoctype(cp);
2437
- }
2438
- }
2439
- }
2440
- }
2441
- // After DOCTYPE public keyword state
2442
- //------------------------------------------------------------------
2443
- _stateAfterDoctypePublicKeyword(cp) {
2444
- const token = this.currentToken;
2445
- switch (cp) {
2446
- case unicode.CODE_POINTS.SPACE:
2447
- case unicode.CODE_POINTS.LINE_FEED:
2448
- case unicode.CODE_POINTS.TABULATION:
2449
- case unicode.CODE_POINTS.FORM_FEED:
2450
- {
2451
- this.state = State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;
2452
- break;
2453
- }
2454
- case unicode.CODE_POINTS.QUOTATION_MARK:
2455
- {
2456
- this._err(errorCodes.ERR.missingWhitespaceAfterDoctypePublicKeyword);
2457
- token.publicId = '';
2458
- this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
2459
- break;
2460
- }
2461
- case unicode.CODE_POINTS.APOSTROPHE:
2462
- {
2463
- this._err(errorCodes.ERR.missingWhitespaceAfterDoctypePublicKeyword);
2464
- token.publicId = '';
2465
- this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
2466
- break;
2467
- }
2468
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2469
- {
2470
- this._err(errorCodes.ERR.missingDoctypePublicIdentifier);
2471
- token.forceQuirks = true;
2472
- this.state = State.DATA;
2473
- this.emitCurrentDoctype(token);
2474
- break;
2475
- }
2476
- case unicode.CODE_POINTS.EOF:
2477
- {
2478
- this._err(errorCodes.ERR.eofInDoctype);
2479
- token.forceQuirks = true;
2480
- this.emitCurrentDoctype(token);
2481
- this._emitEOFToken();
2482
- break;
2483
- }
2484
- default:
2485
- {
2486
- this._err(errorCodes.ERR.missingQuoteBeforeDoctypePublicIdentifier);
2487
- token.forceQuirks = true;
2488
- this.state = State.BOGUS_DOCTYPE;
2489
- this._stateBogusDoctype(cp);
2490
- }
2491
- }
2492
- }
2493
- // Before DOCTYPE public identifier state
2494
- //------------------------------------------------------------------
2495
- _stateBeforeDoctypePublicIdentifier(cp) {
2496
- const token = this.currentToken;
2497
- switch (cp) {
2498
- case unicode.CODE_POINTS.SPACE:
2499
- case unicode.CODE_POINTS.LINE_FEED:
2500
- case unicode.CODE_POINTS.TABULATION:
2501
- case unicode.CODE_POINTS.FORM_FEED:
2502
- {
2503
- // Ignore whitespace
2504
- break;
2505
- }
2506
- case unicode.CODE_POINTS.QUOTATION_MARK:
2507
- {
2508
- token.publicId = '';
2509
- this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
2510
- break;
2511
- }
2512
- case unicode.CODE_POINTS.APOSTROPHE:
2513
- {
2514
- token.publicId = '';
2515
- this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
2516
- break;
2517
- }
2518
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2519
- {
2520
- this._err(errorCodes.ERR.missingDoctypePublicIdentifier);
2521
- token.forceQuirks = true;
2522
- this.state = State.DATA;
2523
- this.emitCurrentDoctype(token);
2524
- break;
2525
- }
2526
- case unicode.CODE_POINTS.EOF:
2527
- {
2528
- this._err(errorCodes.ERR.eofInDoctype);
2529
- token.forceQuirks = true;
2530
- this.emitCurrentDoctype(token);
2531
- this._emitEOFToken();
2532
- break;
2533
- }
2534
- default:
2535
- {
2536
- this._err(errorCodes.ERR.missingQuoteBeforeDoctypePublicIdentifier);
2537
- token.forceQuirks = true;
2538
- this.state = State.BOGUS_DOCTYPE;
2539
- this._stateBogusDoctype(cp);
2540
- }
2541
- }
2542
- }
2543
- // DOCTYPE public identifier (double-quoted) state
2544
- //------------------------------------------------------------------
2545
- _stateDoctypePublicIdentifierDoubleQuoted(cp) {
2546
- const token = this.currentToken;
2547
- switch (cp) {
2548
- case unicode.CODE_POINTS.QUOTATION_MARK:
2549
- {
2550
- this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
2551
- break;
2552
- }
2553
- case unicode.CODE_POINTS.NULL:
2554
- {
2555
- this._err(errorCodes.ERR.unexpectedNullCharacter);
2556
- token.publicId += unicode.REPLACEMENT_CHARACTER;
2557
- break;
2558
- }
2559
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2560
- {
2561
- this._err(errorCodes.ERR.abruptDoctypePublicIdentifier);
2562
- token.forceQuirks = true;
2563
- this.emitCurrentDoctype(token);
2564
- this.state = State.DATA;
2565
- break;
2566
- }
2567
- case unicode.CODE_POINTS.EOF:
2568
- {
2569
- this._err(errorCodes.ERR.eofInDoctype);
2570
- token.forceQuirks = true;
2571
- this.emitCurrentDoctype(token);
2572
- this._emitEOFToken();
2573
- break;
2574
- }
2575
- default:
2576
- {
2577
- token.publicId += String.fromCodePoint(cp);
2578
- }
2579
- }
2580
- }
2581
- // DOCTYPE public identifier (single-quoted) state
2582
- //------------------------------------------------------------------
2583
- _stateDoctypePublicIdentifierSingleQuoted(cp) {
2584
- const token = this.currentToken;
2585
- switch (cp) {
2586
- case unicode.CODE_POINTS.APOSTROPHE:
2587
- {
2588
- this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
2589
- break;
2590
- }
2591
- case unicode.CODE_POINTS.NULL:
2592
- {
2593
- this._err(errorCodes.ERR.unexpectedNullCharacter);
2594
- token.publicId += unicode.REPLACEMENT_CHARACTER;
2595
- break;
2596
- }
2597
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2598
- {
2599
- this._err(errorCodes.ERR.abruptDoctypePublicIdentifier);
2600
- token.forceQuirks = true;
2601
- this.emitCurrentDoctype(token);
2602
- this.state = State.DATA;
2603
- break;
2604
- }
2605
- case unicode.CODE_POINTS.EOF:
2606
- {
2607
- this._err(errorCodes.ERR.eofInDoctype);
2608
- token.forceQuirks = true;
2609
- this.emitCurrentDoctype(token);
2610
- this._emitEOFToken();
2611
- break;
2612
- }
2613
- default:
2614
- {
2615
- token.publicId += String.fromCodePoint(cp);
2616
- }
2617
- }
2618
- }
2619
- // After DOCTYPE public identifier state
2620
- //------------------------------------------------------------------
2621
- _stateAfterDoctypePublicIdentifier(cp) {
2622
- const token = this.currentToken;
2623
- switch (cp) {
2624
- case unicode.CODE_POINTS.SPACE:
2625
- case unicode.CODE_POINTS.LINE_FEED:
2626
- case unicode.CODE_POINTS.TABULATION:
2627
- case unicode.CODE_POINTS.FORM_FEED:
2628
- {
2629
- this.state = State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;
2630
- break;
2631
- }
2632
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2633
- {
2634
- this.state = State.DATA;
2635
- this.emitCurrentDoctype(token);
2636
- break;
2637
- }
2638
- case unicode.CODE_POINTS.QUOTATION_MARK:
2639
- {
2640
- this._err(errorCodes.ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);
2641
- token.systemId = '';
2642
- this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
2643
- break;
2644
- }
2645
- case unicode.CODE_POINTS.APOSTROPHE:
2646
- {
2647
- this._err(errorCodes.ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);
2648
- token.systemId = '';
2649
- this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
2650
- break;
2651
- }
2652
- case unicode.CODE_POINTS.EOF:
2653
- {
2654
- this._err(errorCodes.ERR.eofInDoctype);
2655
- token.forceQuirks = true;
2656
- this.emitCurrentDoctype(token);
2657
- this._emitEOFToken();
2658
- break;
2659
- }
2660
- default:
2661
- {
2662
- this._err(errorCodes.ERR.missingQuoteBeforeDoctypeSystemIdentifier);
2663
- token.forceQuirks = true;
2664
- this.state = State.BOGUS_DOCTYPE;
2665
- this._stateBogusDoctype(cp);
2666
- }
2667
- }
2668
- }
2669
- // Between DOCTYPE public and system identifiers state
2670
- //------------------------------------------------------------------
2671
- _stateBetweenDoctypePublicAndSystemIdentifiers(cp) {
2672
- const token = this.currentToken;
2673
- switch (cp) {
2674
- case unicode.CODE_POINTS.SPACE:
2675
- case unicode.CODE_POINTS.LINE_FEED:
2676
- case unicode.CODE_POINTS.TABULATION:
2677
- case unicode.CODE_POINTS.FORM_FEED:
2678
- {
2679
- // Ignore whitespace
2680
- break;
2681
- }
2682
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2683
- {
2684
- this.emitCurrentDoctype(token);
2685
- this.state = State.DATA;
2686
- break;
2687
- }
2688
- case unicode.CODE_POINTS.QUOTATION_MARK:
2689
- {
2690
- token.systemId = '';
2691
- this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
2692
- break;
2693
- }
2694
- case unicode.CODE_POINTS.APOSTROPHE:
2695
- {
2696
- token.systemId = '';
2697
- this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
2698
- break;
2699
- }
2700
- case unicode.CODE_POINTS.EOF:
2701
- {
2702
- this._err(errorCodes.ERR.eofInDoctype);
2703
- token.forceQuirks = true;
2704
- this.emitCurrentDoctype(token);
2705
- this._emitEOFToken();
2706
- break;
2707
- }
2708
- default:
2709
- {
2710
- this._err(errorCodes.ERR.missingQuoteBeforeDoctypeSystemIdentifier);
2711
- token.forceQuirks = true;
2712
- this.state = State.BOGUS_DOCTYPE;
2713
- this._stateBogusDoctype(cp);
2714
- }
2715
- }
2716
- }
2717
- // After DOCTYPE system keyword state
2718
- //------------------------------------------------------------------
2719
- _stateAfterDoctypeSystemKeyword(cp) {
2720
- const token = this.currentToken;
2721
- switch (cp) {
2722
- case unicode.CODE_POINTS.SPACE:
2723
- case unicode.CODE_POINTS.LINE_FEED:
2724
- case unicode.CODE_POINTS.TABULATION:
2725
- case unicode.CODE_POINTS.FORM_FEED:
2726
- {
2727
- this.state = State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;
2728
- break;
2729
- }
2730
- case unicode.CODE_POINTS.QUOTATION_MARK:
2731
- {
2732
- this._err(errorCodes.ERR.missingWhitespaceAfterDoctypeSystemKeyword);
2733
- token.systemId = '';
2734
- this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
2735
- break;
2736
- }
2737
- case unicode.CODE_POINTS.APOSTROPHE:
2738
- {
2739
- this._err(errorCodes.ERR.missingWhitespaceAfterDoctypeSystemKeyword);
2740
- token.systemId = '';
2741
- this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
2742
- break;
2743
- }
2744
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2745
- {
2746
- this._err(errorCodes.ERR.missingDoctypeSystemIdentifier);
2747
- token.forceQuirks = true;
2748
- this.state = State.DATA;
2749
- this.emitCurrentDoctype(token);
2750
- break;
2751
- }
2752
- case unicode.CODE_POINTS.EOF:
2753
- {
2754
- this._err(errorCodes.ERR.eofInDoctype);
2755
- token.forceQuirks = true;
2756
- this.emitCurrentDoctype(token);
2757
- this._emitEOFToken();
2758
- break;
2759
- }
2760
- default:
2761
- {
2762
- this._err(errorCodes.ERR.missingQuoteBeforeDoctypeSystemIdentifier);
2763
- token.forceQuirks = true;
2764
- this.state = State.BOGUS_DOCTYPE;
2765
- this._stateBogusDoctype(cp);
2766
- }
2767
- }
2768
- }
2769
- // Before DOCTYPE system identifier state
2770
- //------------------------------------------------------------------
2771
- _stateBeforeDoctypeSystemIdentifier(cp) {
2772
- const token = this.currentToken;
2773
- switch (cp) {
2774
- case unicode.CODE_POINTS.SPACE:
2775
- case unicode.CODE_POINTS.LINE_FEED:
2776
- case unicode.CODE_POINTS.TABULATION:
2777
- case unicode.CODE_POINTS.FORM_FEED:
2778
- {
2779
- // Ignore whitespace
2780
- break;
2781
- }
2782
- case unicode.CODE_POINTS.QUOTATION_MARK:
2783
- {
2784
- token.systemId = '';
2785
- this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
2786
- break;
2787
- }
2788
- case unicode.CODE_POINTS.APOSTROPHE:
2789
- {
2790
- token.systemId = '';
2791
- this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
2792
- break;
2793
- }
2794
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2795
- {
2796
- this._err(errorCodes.ERR.missingDoctypeSystemIdentifier);
2797
- token.forceQuirks = true;
2798
- this.state = State.DATA;
2799
- this.emitCurrentDoctype(token);
2800
- break;
2801
- }
2802
- case unicode.CODE_POINTS.EOF:
2803
- {
2804
- this._err(errorCodes.ERR.eofInDoctype);
2805
- token.forceQuirks = true;
2806
- this.emitCurrentDoctype(token);
2807
- this._emitEOFToken();
2808
- break;
2809
- }
2810
- default:
2811
- {
2812
- this._err(errorCodes.ERR.missingQuoteBeforeDoctypeSystemIdentifier);
2813
- token.forceQuirks = true;
2814
- this.state = State.BOGUS_DOCTYPE;
2815
- this._stateBogusDoctype(cp);
2816
- }
2817
- }
2818
- }
2819
- // DOCTYPE system identifier (double-quoted) state
2820
- //------------------------------------------------------------------
2821
- _stateDoctypeSystemIdentifierDoubleQuoted(cp) {
2822
- const token = this.currentToken;
2823
- switch (cp) {
2824
- case unicode.CODE_POINTS.QUOTATION_MARK:
2825
- {
2826
- this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
2827
- break;
2828
- }
2829
- case unicode.CODE_POINTS.NULL:
2830
- {
2831
- this._err(errorCodes.ERR.unexpectedNullCharacter);
2832
- token.systemId += unicode.REPLACEMENT_CHARACTER;
2833
- break;
2834
- }
2835
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2836
- {
2837
- this._err(errorCodes.ERR.abruptDoctypeSystemIdentifier);
2838
- token.forceQuirks = true;
2839
- this.emitCurrentDoctype(token);
2840
- this.state = State.DATA;
2841
- break;
2842
- }
2843
- case unicode.CODE_POINTS.EOF:
2844
- {
2845
- this._err(errorCodes.ERR.eofInDoctype);
2846
- token.forceQuirks = true;
2847
- this.emitCurrentDoctype(token);
2848
- this._emitEOFToken();
2849
- break;
2850
- }
2851
- default:
2852
- {
2853
- token.systemId += String.fromCodePoint(cp);
2854
- }
2855
- }
2856
- }
2857
- // DOCTYPE system identifier (single-quoted) state
2858
- //------------------------------------------------------------------
2859
- _stateDoctypeSystemIdentifierSingleQuoted(cp) {
2860
- const token = this.currentToken;
2861
- switch (cp) {
2862
- case unicode.CODE_POINTS.APOSTROPHE:
2863
- {
2864
- this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
2865
- break;
2866
- }
2867
- case unicode.CODE_POINTS.NULL:
2868
- {
2869
- this._err(errorCodes.ERR.unexpectedNullCharacter);
2870
- token.systemId += unicode.REPLACEMENT_CHARACTER;
2871
- break;
2872
- }
2873
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2874
- {
2875
- this._err(errorCodes.ERR.abruptDoctypeSystemIdentifier);
2876
- token.forceQuirks = true;
2877
- this.emitCurrentDoctype(token);
2878
- this.state = State.DATA;
2879
- break;
2880
- }
2881
- case unicode.CODE_POINTS.EOF:
2882
- {
2883
- this._err(errorCodes.ERR.eofInDoctype);
2884
- token.forceQuirks = true;
2885
- this.emitCurrentDoctype(token);
2886
- this._emitEOFToken();
2887
- break;
2888
- }
2889
- default:
2890
- {
2891
- token.systemId += String.fromCodePoint(cp);
2892
- }
2893
- }
2894
- }
2895
- // After DOCTYPE system identifier state
2896
- //------------------------------------------------------------------
2897
- _stateAfterDoctypeSystemIdentifier(cp) {
2898
- const token = this.currentToken;
2899
- switch (cp) {
2900
- case unicode.CODE_POINTS.SPACE:
2901
- case unicode.CODE_POINTS.LINE_FEED:
2902
- case unicode.CODE_POINTS.TABULATION:
2903
- case unicode.CODE_POINTS.FORM_FEED:
2904
- {
2905
- // Ignore whitespace
2906
- break;
2907
- }
2908
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2909
- {
2910
- this.emitCurrentDoctype(token);
2911
- this.state = State.DATA;
2912
- break;
2913
- }
2914
- case unicode.CODE_POINTS.EOF:
2915
- {
2916
- this._err(errorCodes.ERR.eofInDoctype);
2917
- token.forceQuirks = true;
2918
- this.emitCurrentDoctype(token);
2919
- this._emitEOFToken();
2920
- break;
2921
- }
2922
- default:
2923
- {
2924
- this._err(errorCodes.ERR.unexpectedCharacterAfterDoctypeSystemIdentifier);
2925
- this.state = State.BOGUS_DOCTYPE;
2926
- this._stateBogusDoctype(cp);
2927
- }
2928
- }
2929
- }
2930
- // Bogus DOCTYPE state
2931
- //------------------------------------------------------------------
2932
- _stateBogusDoctype(cp) {
2933
- const token = this.currentToken;
2934
- switch (cp) {
2935
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2936
- {
2937
- this.emitCurrentDoctype(token);
2938
- this.state = State.DATA;
2939
- break;
2940
- }
2941
- case unicode.CODE_POINTS.NULL:
2942
- {
2943
- this._err(errorCodes.ERR.unexpectedNullCharacter);
2944
- break;
2945
- }
2946
- case unicode.CODE_POINTS.EOF:
2947
- {
2948
- this.emitCurrentDoctype(token);
2949
- this._emitEOFToken();
2950
- break;
2951
- }
2952
- default:
2953
- // Do nothing
2954
- }
2955
- }
2956
- // CDATA section state
2957
- //------------------------------------------------------------------
2958
- _stateCdataSection(cp) {
2959
- switch (cp) {
2960
- case unicode.CODE_POINTS.RIGHT_SQUARE_BRACKET:
2961
- {
2962
- this.state = State.CDATA_SECTION_BRACKET;
2963
- break;
2964
- }
2965
- case unicode.CODE_POINTS.EOF:
2966
- {
2967
- this._err(errorCodes.ERR.eofInCdata);
2968
- this._emitEOFToken();
2969
- break;
2970
- }
2971
- default:
2972
- {
2973
- this._emitCodePoint(cp);
2974
- }
2975
- }
2976
- }
2977
- // CDATA section bracket state
2978
- //------------------------------------------------------------------
2979
- _stateCdataSectionBracket(cp) {
2980
- if (cp === unicode.CODE_POINTS.RIGHT_SQUARE_BRACKET) {
2981
- this.state = State.CDATA_SECTION_END;
2982
- } else {
2983
- this._emitChars(']');
2984
- this.state = State.CDATA_SECTION;
2985
- this._stateCdataSection(cp);
2986
- }
2987
- }
2988
- // CDATA section end state
2989
- //------------------------------------------------------------------
2990
- _stateCdataSectionEnd(cp) {
2991
- switch (cp) {
2992
- case unicode.CODE_POINTS.GREATER_THAN_SIGN:
2993
- {
2994
- this.state = State.DATA;
2995
- break;
2996
- }
2997
- case unicode.CODE_POINTS.RIGHT_SQUARE_BRACKET:
2998
- {
2999
- this._emitChars(']');
3000
- break;
3001
- }
3002
- default:
3003
- {
3004
- this._emitChars(']]');
3005
- this.state = State.CDATA_SECTION;
3006
- this._stateCdataSection(cp);
3007
- }
3008
- }
3009
- }
3010
- // Character reference state
3011
- //------------------------------------------------------------------
3012
- _stateCharacterReference(cp) {
3013
- if (cp === unicode.CODE_POINTS.NUMBER_SIGN) {
3014
- this.state = State.NUMERIC_CHARACTER_REFERENCE;
3015
- } else if (isAsciiAlphaNumeric(cp)) {
3016
- this.state = State.NAMED_CHARACTER_REFERENCE;
3017
- this._stateNamedCharacterReference(cp);
3018
- } else {
3019
- this._flushCodePointConsumedAsCharacterReference(unicode.CODE_POINTS.AMPERSAND);
3020
- this._reconsumeInState(this.returnState, cp);
3021
- }
3022
- }
3023
- // Named character reference state
3024
- //------------------------------------------------------------------
3025
- _stateNamedCharacterReference(cp) {
3026
- const matchResult = this._matchNamedCharacterReference(cp);
3027
- //NOTE: Matching can be abrupted by hibernation. In that case, match
3028
- //results are no longer valid and we will need to start over.
3029
- if (this._ensureHibernation()) {
3030
- // Stay in the state, try again.
3031
- } else if (matchResult) {
3032
- for (let i = 0; i < matchResult.length; i++) {
3033
- this._flushCodePointConsumedAsCharacterReference(matchResult[i]);
3034
- }
3035
- this.state = this.returnState;
3036
- } else {
3037
- this._flushCodePointConsumedAsCharacterReference(unicode.CODE_POINTS.AMPERSAND);
3038
- this.state = State.AMBIGUOUS_AMPERSAND;
3039
- }
3040
- }
3041
- // Ambiguos ampersand state
3042
- //------------------------------------------------------------------
3043
- _stateAmbiguousAmpersand(cp) {
3044
- if (isAsciiAlphaNumeric(cp)) {
3045
- this._flushCodePointConsumedAsCharacterReference(cp);
3046
- } else {
3047
- if (cp === unicode.CODE_POINTS.SEMICOLON) {
3048
- this._err(errorCodes.ERR.unknownNamedCharacterReference);
3049
- }
3050
- this._reconsumeInState(this.returnState, cp);
3051
- }
3052
- }
3053
- // Numeric character reference state
3054
- //------------------------------------------------------------------
3055
- _stateNumericCharacterReference(cp) {
3056
- this.charRefCode = 0;
3057
- if (cp === unicode.CODE_POINTS.LATIN_SMALL_X || cp === unicode.CODE_POINTS.LATIN_CAPITAL_X) {
3058
- this.state = State.HEXADEMICAL_CHARACTER_REFERENCE_START;
3059
- }
3060
- // Inlined decimal character reference start state
3061
- else if (isAsciiDigit(cp)) {
3062
- this.state = State.DECIMAL_CHARACTER_REFERENCE;
3063
- this._stateDecimalCharacterReference(cp);
3064
- } else {
3065
- this._err(errorCodes.ERR.absenceOfDigitsInNumericCharacterReference);
3066
- this._flushCodePointConsumedAsCharacterReference(unicode.CODE_POINTS.AMPERSAND);
3067
- this._flushCodePointConsumedAsCharacterReference(unicode.CODE_POINTS.NUMBER_SIGN);
3068
- this._reconsumeInState(this.returnState, cp);
3069
- }
3070
- }
3071
- // Hexademical character reference start state
3072
- //------------------------------------------------------------------
3073
- _stateHexademicalCharacterReferenceStart(cp) {
3074
- if (isAsciiHexDigit(cp)) {
3075
- this.state = State.HEXADEMICAL_CHARACTER_REFERENCE;
3076
- this._stateHexademicalCharacterReference(cp);
3077
- } else {
3078
- this._err(errorCodes.ERR.absenceOfDigitsInNumericCharacterReference);
3079
- this._flushCodePointConsumedAsCharacterReference(unicode.CODE_POINTS.AMPERSAND);
3080
- this._flushCodePointConsumedAsCharacterReference(unicode.CODE_POINTS.NUMBER_SIGN);
3081
- this._unconsume(2);
3082
- this.state = this.returnState;
3083
- }
3084
- }
3085
- // Hexademical character reference state
3086
- //------------------------------------------------------------------
3087
- _stateHexademicalCharacterReference(cp) {
3088
- if (isAsciiUpperHexDigit(cp)) {
3089
- this.charRefCode = this.charRefCode * 16 + cp - 0x37;
3090
- } else if (isAsciiLowerHexDigit(cp)) {
3091
- this.charRefCode = this.charRefCode * 16 + cp - 0x57;
3092
- } else if (isAsciiDigit(cp)) {
3093
- this.charRefCode = this.charRefCode * 16 + cp - 0x30;
3094
- } else if (cp === unicode.CODE_POINTS.SEMICOLON) {
3095
- this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
3096
- } else {
3097
- this._err(errorCodes.ERR.missingSemicolonAfterCharacterReference);
3098
- this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
3099
- this._stateNumericCharacterReferenceEnd(cp);
3100
- }
3101
- }
3102
- // Decimal character reference state
3103
- //------------------------------------------------------------------
3104
- _stateDecimalCharacterReference(cp) {
3105
- if (isAsciiDigit(cp)) {
3106
- this.charRefCode = this.charRefCode * 10 + cp - 0x30;
3107
- } else if (cp === unicode.CODE_POINTS.SEMICOLON) {
3108
- this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
3109
- } else {
3110
- this._err(errorCodes.ERR.missingSemicolonAfterCharacterReference);
3111
- this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
3112
- this._stateNumericCharacterReferenceEnd(cp);
3113
- }
3114
- }
3115
- // Numeric character reference end state
3116
- //------------------------------------------------------------------
3117
- _stateNumericCharacterReferenceEnd(cp) {
3118
- if (this.charRefCode === unicode.CODE_POINTS.NULL) {
3119
- this._err(errorCodes.ERR.nullCharacterReference);
3120
- this.charRefCode = unicode.CODE_POINTS.REPLACEMENT_CHARACTER;
3121
- } else if (this.charRefCode > 1114111) {
3122
- this._err(errorCodes.ERR.characterReferenceOutsideUnicodeRange);
3123
- this.charRefCode = unicode.CODE_POINTS.REPLACEMENT_CHARACTER;
3124
- } else if (unicode.isSurrogate(this.charRefCode)) {
3125
- this._err(errorCodes.ERR.surrogateCharacterReference);
3126
- this.charRefCode = unicode.CODE_POINTS.REPLACEMENT_CHARACTER;
3127
- } else if (unicode.isUndefinedCodePoint(this.charRefCode)) {
3128
- this._err(errorCodes.ERR.noncharacterCharacterReference);
3129
- } else if (unicode.isControlCodePoint(this.charRefCode) || this.charRefCode === unicode.CODE_POINTS.CARRIAGE_RETURN) {
3130
- this._err(errorCodes.ERR.controlCharacterReference);
3131
- const replacement = C1_CONTROLS_REFERENCE_REPLACEMENTS.get(this.charRefCode);
3132
- if (replacement !== undefined) {
3133
- this.charRefCode = replacement;
3134
- }
3135
- }
3136
- this._flushCodePointConsumedAsCharacterReference(this.charRefCode);
3137
- this._reconsumeInState(this.returnState, cp);
3138
- }
3139
- }
3140
- exports.Tokenizer = Tokenizer;
3141
- exports.TokenizerMode = TokenizerMode;
3142
- //# sourceMappingURL=index.js.map