@tinta-lang/syntax 0.0.0-stage โ†’ 0.1.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/LICENSE +21 -0
  2. package/THIRD_PARTY_NOTICES.txt +13651 -0
  3. package/dist/directive.d.ts +40 -0
  4. package/dist/editing.d.ts +46 -0
  5. package/dist/enrichment.d.ts +5 -0
  6. package/dist/expression.d.ts +26 -0
  7. package/dist/image-destinations.d.ts +3 -0
  8. package/dist/index.d.ts +8 -0
  9. package/dist/index.js +10118 -0
  10. package/dist/parser.d.ts +40 -0
  11. package/dist/registry.d.ts +144 -0
  12. package/dist/source.d.ts +28 -0
  13. package/package.json +280 -3
  14. package/parser-provenance.json +1419 -0
  15. package/patches/README.md +5 -0
  16. package/patches/micromark.patch +84 -0
  17. package/vendor/@noble/hashes/LICENSE +21 -0
  18. package/vendor/@noble/hashes/_md.js +209 -0
  19. package/vendor/@noble/hashes/_u64.js +77 -0
  20. package/vendor/@noble/hashes/package.json +91 -0
  21. package/vendor/@noble/hashes/sha2.js +446 -0
  22. package/vendor/@noble/hashes/utils.js +687 -0
  23. package/vendor/character-entities/index.js +2132 -0
  24. package/vendor/character-entities/license +22 -0
  25. package/vendor/character-entities/package.json +78 -0
  26. package/vendor/decode-named-character-reference/index.js +19 -0
  27. package/vendor/decode-named-character-reference/license +22 -0
  28. package/vendor/decode-named-character-reference/package.json +90 -0
  29. package/vendor/devlop/lib/default.js +9 -0
  30. package/vendor/devlop/license +22 -0
  31. package/vendor/devlop/package.json +80 -0
  32. package/vendor/longest-streak/index.js +36 -0
  33. package/vendor/longest-streak/license +22 -0
  34. package/vendor/longest-streak/package.json +73 -0
  35. package/vendor/markdown-table/index.js +393 -0
  36. package/vendor/markdown-table/license +22 -0
  37. package/vendor/markdown-table/package.json +77 -0
  38. package/vendor/mdast-util-from-markdown/index.js +2 -0
  39. package/vendor/mdast-util-from-markdown/lib/index.js +1270 -0
  40. package/vendor/mdast-util-from-markdown/license +22 -0
  41. package/vendor/mdast-util-from-markdown/package.json +98 -0
  42. package/vendor/mdast-util-gfm-strikethrough/index.js +5 -0
  43. package/vendor/mdast-util-gfm-strikethrough/lib/index.js +133 -0
  44. package/vendor/mdast-util-gfm-strikethrough/license +22 -0
  45. package/vendor/mdast-util-gfm-strikethrough/package.json +84 -0
  46. package/vendor/mdast-util-gfm-table/index.js +2 -0
  47. package/vendor/mdast-util-gfm-table/lib/index.js +300 -0
  48. package/vendor/mdast-util-gfm-table/license +22 -0
  49. package/vendor/mdast-util-gfm-table/package.json +101 -0
  50. package/vendor/mdast-util-gfm-task-list-item/index.js +4 -0
  51. package/vendor/mdast-util-gfm-task-list-item/lib/index.js +141 -0
  52. package/vendor/mdast-util-gfm-task-list-item/license +22 -0
  53. package/vendor/mdast-util-gfm-task-list-item/package.json +90 -0
  54. package/vendor/mdast-util-phrasing/index.js +1 -0
  55. package/vendor/mdast-util-phrasing/lib/index.js +45 -0
  56. package/vendor/mdast-util-phrasing/license +23 -0
  57. package/vendor/mdast-util-phrasing/package.json +78 -0
  58. package/vendor/mdast-util-to-markdown/index.js +3 -0
  59. package/vendor/mdast-util-to-markdown/lib/configure.js +98 -0
  60. package/vendor/mdast-util-to-markdown/lib/handle/blockquote.js +40 -0
  61. package/vendor/mdast-util-to-markdown/lib/handle/break.js +41 -0
  62. package/vendor/mdast-util-to-markdown/lib/handle/code.js +86 -0
  63. package/vendor/mdast-util-to-markdown/lib/handle/definition.js +83 -0
  64. package/vendor/mdast-util-to-markdown/lib/handle/emphasis.js +67 -0
  65. package/vendor/mdast-util-to-markdown/lib/handle/heading.js +84 -0
  66. package/vendor/mdast-util-to-markdown/lib/handle/html.js +27 -0
  67. package/vendor/mdast-util-to-markdown/lib/handle/image-reference.js +78 -0
  68. package/vendor/mdast-util-to-markdown/lib/handle/image.js +92 -0
  69. package/vendor/mdast-util-to-markdown/lib/handle/index.js +45 -0
  70. package/vendor/mdast-util-to-markdown/lib/handle/inline-code.js +86 -0
  71. package/vendor/mdast-util-to-markdown/lib/handle/link-reference.js +78 -0
  72. package/vendor/mdast-util-to-markdown/lib/handle/link.js +129 -0
  73. package/vendor/mdast-util-to-markdown/lib/handle/list-item.js +73 -0
  74. package/vendor/mdast-util-to-markdown/lib/handle/list.js +107 -0
  75. package/vendor/mdast-util-to-markdown/lib/handle/paragraph.js +27 -0
  76. package/vendor/mdast-util-to-markdown/lib/handle/root.js +34 -0
  77. package/vendor/mdast-util-to-markdown/lib/handle/strong.js +67 -0
  78. package/vendor/mdast-util-to-markdown/lib/handle/text.js +30 -0
  79. package/vendor/mdast-util-to-markdown/lib/handle/thematic-break.js +27 -0
  80. package/vendor/mdast-util-to-markdown/lib/index.js +213 -0
  81. package/vendor/mdast-util-to-markdown/lib/join.js +56 -0
  82. package/vendor/mdast-util-to-markdown/lib/unsafe.js +160 -0
  83. package/vendor/mdast-util-to-markdown/lib/util/association.js +33 -0
  84. package/vendor/mdast-util-to-markdown/lib/util/character.js +32 -0
  85. package/vendor/mdast-util-to-markdown/lib/util/check-bullet-ordered.js +25 -0
  86. package/vendor/mdast-util-to-markdown/lib/util/check-bullet-other.js +42 -0
  87. package/vendor/mdast-util-to-markdown/lib/util/check-bullet.js +25 -0
  88. package/vendor/mdast-util-to-markdown/lib/util/check-emphasis.js +25 -0
  89. package/vendor/mdast-util-to-markdown/lib/util/check-fence.js +25 -0
  90. package/vendor/mdast-util-to-markdown/lib/util/check-list-item-indent.js +25 -0
  91. package/vendor/mdast-util-to-markdown/lib/util/check-quote.js +25 -0
  92. package/vendor/mdast-util-to-markdown/lib/util/check-rule-repetition.js +25 -0
  93. package/vendor/mdast-util-to-markdown/lib/util/check-rule.js +25 -0
  94. package/vendor/mdast-util-to-markdown/lib/util/check-strong.js +25 -0
  95. package/vendor/mdast-util-to-markdown/lib/util/compile-pattern.js +30 -0
  96. package/vendor/mdast-util-to-markdown/lib/util/container-flow.js +93 -0
  97. package/vendor/mdast-util-to-markdown/lib/util/container-phrasing.js +704 -0
  98. package/vendor/mdast-util-to-markdown/lib/util/encode-character-reference.js +11 -0
  99. package/vendor/mdast-util-to-markdown/lib/util/encode-info.js +82 -0
  100. package/vendor/mdast-util-to-markdown/lib/util/format-code-as-indented.js +27 -0
  101. package/vendor/mdast-util-to-markdown/lib/util/format-heading-as-setext.js +39 -0
  102. package/vendor/mdast-util-to-markdown/lib/util/format-link-as-autolink.js +39 -0
  103. package/vendor/mdast-util-to-markdown/lib/util/html-kind.js +63 -0
  104. package/vendor/mdast-util-to-markdown/lib/util/indent-lines.js +40 -0
  105. package/vendor/mdast-util-to-markdown/lib/util/pattern-in-scope.js +52 -0
  106. package/vendor/mdast-util-to-markdown/lib/util/safe.js +263 -0
  107. package/vendor/mdast-util-to-markdown/lib/util/track.js +55 -0
  108. package/vendor/mdast-util-to-markdown/license +22 -0
  109. package/vendor/mdast-util-to-markdown/package.json +88 -0
  110. package/vendor/mdast-util-to-string/index.js +5 -0
  111. package/vendor/mdast-util-to-string/lib/index.js +108 -0
  112. package/vendor/mdast-util-to-string/license +22 -0
  113. package/vendor/mdast-util-to-string/package.json +78 -0
  114. package/vendor/micromark/index.js +60 -0
  115. package/vendor/micromark/lib/compile.js +1068 -0
  116. package/vendor/micromark/lib/constructs.js +85 -0
  117. package/vendor/micromark/lib/create-tokenizer.js +615 -0
  118. package/vendor/micromark/lib/initialize/content.js +79 -0
  119. package/vendor/micromark/lib/initialize/document.js +370 -0
  120. package/vendor/micromark/lib/initialize/flow.js +58 -0
  121. package/vendor/micromark/lib/initialize/text.js +216 -0
  122. package/vendor/micromark/lib/parse.js +56 -0
  123. package/vendor/micromark/lib/postprocess.js +18 -0
  124. package/vendor/micromark/lib/preprocess.js +112 -0
  125. package/vendor/micromark/license +22 -0
  126. package/vendor/micromark/package.json +87 -0
  127. package/vendor/micromark-core-commonmark/index.js +22 -0
  128. package/vendor/micromark-core-commonmark/lib/attention.js +231 -0
  129. package/vendor/micromark-core-commonmark/lib/autolink.js +233 -0
  130. package/vendor/micromark-core-commonmark/lib/blank-line.js +61 -0
  131. package/vendor/micromark-core-commonmark/lib/block-quote.js +143 -0
  132. package/vendor/micromark-core-commonmark/lib/character-escape.js +64 -0
  133. package/vendor/micromark-core-commonmark/lib/character-reference.js +149 -0
  134. package/vendor/micromark-core-commonmark/lib/code-fenced.js +422 -0
  135. package/vendor/micromark-core-commonmark/lib/code-indented.js +159 -0
  136. package/vendor/micromark-core-commonmark/lib/code-text.js +225 -0
  137. package/vendor/micromark-core-commonmark/lib/content.js +163 -0
  138. package/vendor/micromark-core-commonmark/lib/definition.js +254 -0
  139. package/vendor/micromark-core-commonmark/lib/hard-break-escape.js +60 -0
  140. package/vendor/micromark-core-commonmark/lib/heading-atx.js +191 -0
  141. package/vendor/micromark-core-commonmark/lib/html-flow.js +827 -0
  142. package/vendor/micromark-core-commonmark/lib/html-text.js +678 -0
  143. package/vendor/micromark-core-commonmark/lib/label-end.js +561 -0
  144. package/vendor/micromark-core-commonmark/lib/label-start-image.js +110 -0
  145. package/vendor/micromark-core-commonmark/lib/label-start-link.js +63 -0
  146. package/vendor/micromark-core-commonmark/lib/line-ending.js +33 -0
  147. package/vendor/micromark-core-commonmark/lib/list.js +213 -0
  148. package/vendor/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
  149. package/vendor/micromark-core-commonmark/lib/setext-underline.js +187 -0
  150. package/vendor/micromark-core-commonmark/lib/thematic-break.js +102 -0
  151. package/vendor/micromark-core-commonmark/license +22 -0
  152. package/vendor/micromark-core-commonmark/package.json +62 -0
  153. package/vendor/micromark-extension-gfm-strikethrough/index.js +3 -0
  154. package/vendor/micromark-extension-gfm-strikethrough/lib/html.js +26 -0
  155. package/vendor/micromark-extension-gfm-strikethrough/lib/syntax.js +142 -0
  156. package/vendor/micromark-extension-gfm-strikethrough/license +22 -0
  157. package/vendor/micromark-extension-gfm-strikethrough/package.json +129 -0
  158. package/vendor/micromark-extension-gfm-table/index.js +2 -0
  159. package/vendor/micromark-extension-gfm-table/lib/edit-map.js +222 -0
  160. package/vendor/micromark-extension-gfm-table/lib/html.js +135 -0
  161. package/vendor/micromark-extension-gfm-table/lib/infer.js +52 -0
  162. package/vendor/micromark-extension-gfm-table/lib/syntax.js +846 -0
  163. package/vendor/micromark-extension-gfm-table/license +22 -0
  164. package/vendor/micromark-extension-gfm-table/package.json +86 -0
  165. package/vendor/micromark-extension-gfm-task-list-item/index.js +2 -0
  166. package/vendor/micromark-extension-gfm-task-list-item/lib/html.js +29 -0
  167. package/vendor/micromark-extension-gfm-task-list-item/lib/syntax.js +158 -0
  168. package/vendor/micromark-extension-gfm-task-list-item/license +22 -0
  169. package/vendor/micromark-extension-gfm-task-list-item/package.json +131 -0
  170. package/vendor/micromark-factory-destination/index.js +206 -0
  171. package/vendor/micromark-factory-destination/license +22 -0
  172. package/vendor/micromark-factory-destination/package.json +57 -0
  173. package/vendor/micromark-factory-label/index.js +148 -0
  174. package/vendor/micromark-factory-label/license +22 -0
  175. package/vendor/micromark-factory-label/package.json +60 -0
  176. package/vendor/micromark-factory-space/index.js +116 -0
  177. package/vendor/micromark-factory-space/license +22 -0
  178. package/vendor/micromark-factory-space/package.json +46 -0
  179. package/vendor/micromark-factory-title/index.js +158 -0
  180. package/vendor/micromark-factory-title/license +22 -0
  181. package/vendor/micromark-factory-title/package.json +58 -0
  182. package/vendor/micromark-factory-whitespace/index.js +44 -0
  183. package/vendor/micromark-factory-whitespace/license +22 -0
  184. package/vendor/micromark-factory-whitespace/package.json +57 -0
  185. package/vendor/micromark-util-character/index.js +246 -0
  186. package/vendor/micromark-util-character/license +22 -0
  187. package/vendor/micromark-util-character/package.json +57 -0
  188. package/vendor/micromark-util-chunked/index.js +81 -0
  189. package/vendor/micromark-util-chunked/license +22 -0
  190. package/vendor/micromark-util-chunked/package.json +57 -0
  191. package/vendor/micromark-util-classify-character/index.js +27 -0
  192. package/vendor/micromark-util-classify-character/license +22 -0
  193. package/vendor/micromark-util-classify-character/package.json +59 -0
  194. package/vendor/micromark-util-combine-extensions/index.js +143 -0
  195. package/vendor/micromark-util-combine-extensions/license +22 -0
  196. package/vendor/micromark-util-combine-extensions/package.json +52 -0
  197. package/vendor/micromark-util-decode-numeric-character-reference/index.js +32 -0
  198. package/vendor/micromark-util-decode-numeric-character-reference/license +22 -0
  199. package/vendor/micromark-util-decode-numeric-character-reference/package.json +59 -0
  200. package/vendor/micromark-util-decode-string/index.js +45 -0
  201. package/vendor/micromark-util-decode-string/license +22 -0
  202. package/vendor/micromark-util-decode-string/package.json +63 -0
  203. package/vendor/micromark-util-edit-map/index.js +225 -0
  204. package/vendor/micromark-util-edit-map/license +22 -0
  205. package/vendor/micromark-util-edit-map/package.json +48 -0
  206. package/vendor/micromark-util-encode/index.js +33 -0
  207. package/vendor/micromark-util-encode/license +22 -0
  208. package/vendor/micromark-util-encode/package.json +47 -0
  209. package/vendor/micromark-util-html-tag-name/index.js +93 -0
  210. package/vendor/micromark-util-html-tag-name/license +22 -0
  211. package/vendor/micromark-util-html-tag-name/package.json +47 -0
  212. package/vendor/micromark-util-normalize-identifier/index.js +33 -0
  213. package/vendor/micromark-util-normalize-identifier/license +22 -0
  214. package/vendor/micromark-util-normalize-identifier/package.json +58 -0
  215. package/vendor/micromark-util-resolve-all/index.js +32 -0
  216. package/vendor/micromark-util-resolve-all/license +22 -0
  217. package/vendor/micromark-util-resolve-all/package.json +48 -0
  218. package/vendor/micromark-util-sanitize-uri/index.js +107 -0
  219. package/vendor/micromark-util-sanitize-uri/license +22 -0
  220. package/vendor/micromark-util-sanitize-uri/package.json +59 -0
  221. package/vendor/micromark-util-subtokenize/index.js +228 -0
  222. package/vendor/micromark-util-subtokenize/lib/splice-buffer.js +251 -0
  223. package/vendor/micromark-util-subtokenize/license +22 -0
  224. package/vendor/micromark-util-subtokenize/package.json +60 -0
  225. package/vendor/unist-util-is/index.js +7 -0
  226. package/vendor/unist-util-is/lib/index.js +296 -0
  227. package/vendor/unist-util-is/license +22 -0
  228. package/vendor/unist-util-is/package.json +103 -0
  229. package/vendor/unist-util-stringify-position/index.js +1 -0
  230. package/vendor/unist-util-stringify-position/lib/index.js +84 -0
  231. package/vendor/unist-util-stringify-position/license +22 -0
  232. package/vendor/unist-util-stringify-position/package.json +80 -0
  233. package/vendor/unist-util-visit/index.js +2 -0
  234. package/vendor/unist-util-visit/lib/index.js +312 -0
  235. package/vendor/unist-util-visit/license +22 -0
  236. package/vendor/unist-util-visit/package.json +108 -0
  237. package/vendor/unist-util-visit-parents/index.js +2 -0
  238. package/vendor/unist-util-visit-parents/lib/color.js +7 -0
  239. package/vendor/unist-util-visit-parents/lib/index.js +399 -0
  240. package/vendor/unist-util-visit-parents/license +22 -0
  241. package/vendor/unist-util-visit-parents/package.json +106 -0
  242. package/vendor/zwitch/index.js +118 -0
  243. package/vendor/zwitch/license +22 -0
  244. package/vendor/zwitch/package.json +72 -0
  245. package/README.md +0 -3
@@ -0,0 +1,678 @@
1
+ /**
2
+ * @import {
3
+ * Code,
4
+ * Construct,
5
+ * State,
6
+ * TokenizeContext,
7
+ * Tokenizer
8
+ * } from 'micromark-util-types'
9
+ */
10
+
11
+ import { factorySpace } from 'micromark-factory-space';
12
+ import { asciiAlphanumeric, asciiAlpha, markdownLineEndingOrSpace, markdownLineEnding, markdownSpace } from 'micromark-util-character';
13
+ /** @type {Construct} */
14
+ export const htmlText = {
15
+ name: 'htmlText',
16
+ tokenize: tokenizeHtmlText
17
+ };
18
+
19
+ /**
20
+ * @this {TokenizeContext}
21
+ * Context.
22
+ * @type {Tokenizer}
23
+ */
24
+ function tokenizeHtmlText(effects, ok, nok) {
25
+ const self = this;
26
+ /** @type {NonNullable<Code> | undefined} */
27
+ let marker;
28
+ /** @type {number} */
29
+ let index;
30
+ /** @type {State} */
31
+ let returnState;
32
+ return start;
33
+
34
+ /**
35
+ * Start of HTML (text).
36
+ *
37
+ * ```markdown
38
+ * > | a <b> c
39
+ * ^
40
+ * ```
41
+ *
42
+ * @type {State}
43
+ */
44
+ function start(code) {
45
+ effects.enter("htmlText");
46
+ effects.enter("htmlTextData");
47
+ effects.consume(code);
48
+ return open;
49
+ }
50
+
51
+ /**
52
+ * After `<`, at tag name or other stuff.
53
+ *
54
+ * ```markdown
55
+ * > | a <b> c
56
+ * ^
57
+ * > | a <!doctype> c
58
+ * ^
59
+ * > | a <!--b--> c
60
+ * ^
61
+ * ```
62
+ *
63
+ * @type {State}
64
+ */
65
+ function open(code) {
66
+ if (code === 33) {
67
+ effects.consume(code);
68
+ return declarationOpen;
69
+ }
70
+ if (code === 47) {
71
+ effects.consume(code);
72
+ return tagCloseStart;
73
+ }
74
+ if (code === 63) {
75
+ effects.consume(code);
76
+ return instruction;
77
+ }
78
+
79
+ // ASCII alphabetical.
80
+ if (asciiAlpha(code)) {
81
+ effects.consume(code);
82
+ return tagOpen;
83
+ }
84
+ return nok(code);
85
+ }
86
+
87
+ /**
88
+ * After `<!`, at declaration, comment, or CDATA.
89
+ *
90
+ * ```markdown
91
+ * > | a <!doctype> c
92
+ * ^
93
+ * > | a <!--b--> c
94
+ * ^
95
+ * > | a <![CDATA[>&<]]> c
96
+ * ^
97
+ * ```
98
+ *
99
+ * @type {State}
100
+ */
101
+ function declarationOpen(code) {
102
+ if (code === 45) {
103
+ effects.consume(code);
104
+ return commentOpenInside;
105
+ }
106
+ if (code === 91) {
107
+ effects.consume(code);
108
+ index = 0;
109
+ return cdataOpenInside;
110
+ }
111
+ if (asciiAlpha(code)) {
112
+ effects.consume(code);
113
+ return declaration;
114
+ }
115
+ return nok(code);
116
+ }
117
+
118
+ /**
119
+ * In a comment, after `<!-`, at another `-`.
120
+ *
121
+ * ```markdown
122
+ * > | a <!--b--> c
123
+ * ^
124
+ * ```
125
+ *
126
+ * @type {State}
127
+ */
128
+ function commentOpenInside(code) {
129
+ if (code === 45) {
130
+ effects.consume(code);
131
+ return commentEnd;
132
+ }
133
+ return nok(code);
134
+ }
135
+
136
+ /**
137
+ * In comment.
138
+ *
139
+ * ```markdown
140
+ * > | a <!--b--> c
141
+ * ^
142
+ * ```
143
+ *
144
+ * @type {State}
145
+ */
146
+ function comment(code) {
147
+ if (code === null) {
148
+ return nok(code);
149
+ }
150
+ if (code === 45) {
151
+ effects.consume(code);
152
+ return commentClose;
153
+ }
154
+ if (markdownLineEnding(code)) {
155
+ returnState = comment;
156
+ return lineEndingBefore(code);
157
+ }
158
+ effects.consume(code);
159
+ return comment;
160
+ }
161
+
162
+ /**
163
+ * In comment, after `-`.
164
+ *
165
+ * ```markdown
166
+ * > | a <!--b--> c
167
+ * ^
168
+ * ```
169
+ *
170
+ * @type {State}
171
+ */
172
+ function commentClose(code) {
173
+ if (code === 45) {
174
+ effects.consume(code);
175
+ return commentEnd;
176
+ }
177
+ return comment(code);
178
+ }
179
+
180
+ /**
181
+ * In comment, after `--`.
182
+ *
183
+ * ```markdown
184
+ * > | a <!--b--> c
185
+ * ^
186
+ * ```
187
+ *
188
+ * @type {State}
189
+ */
190
+ function commentEnd(code) {
191
+ return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);
192
+ }
193
+
194
+ /**
195
+ * After `<![`, in CDATA, expecting `CDATA[`.
196
+ *
197
+ * ```markdown
198
+ * > | a <![CDATA[>&<]]> b
199
+ * ^^^^^^
200
+ * ```
201
+ *
202
+ * @type {State}
203
+ */
204
+ function cdataOpenInside(code) {
205
+ const value = "CDATA[";
206
+ if (code === value.charCodeAt(index++)) {
207
+ effects.consume(code);
208
+ return index === value.length ? cdata : cdataOpenInside;
209
+ }
210
+ return nok(code);
211
+ }
212
+
213
+ /**
214
+ * In CDATA.
215
+ *
216
+ * ```markdown
217
+ * > | a <![CDATA[>&<]]> b
218
+ * ^^^
219
+ * ```
220
+ *
221
+ * @type {State}
222
+ */
223
+ function cdata(code) {
224
+ if (code === null) {
225
+ return nok(code);
226
+ }
227
+ if (code === 93) {
228
+ effects.consume(code);
229
+ return cdataClose;
230
+ }
231
+ if (markdownLineEnding(code)) {
232
+ returnState = cdata;
233
+ return lineEndingBefore(code);
234
+ }
235
+ effects.consume(code);
236
+ return cdata;
237
+ }
238
+
239
+ /**
240
+ * In CDATA, after `]`, at another `]`.
241
+ *
242
+ * ```markdown
243
+ * > | a <![CDATA[>&<]]> b
244
+ * ^
245
+ * ```
246
+ *
247
+ * @type {State}
248
+ */
249
+ function cdataClose(code) {
250
+ if (code === 93) {
251
+ effects.consume(code);
252
+ return cdataEnd;
253
+ }
254
+ return cdata(code);
255
+ }
256
+
257
+ /**
258
+ * In CDATA, after `]]`, at `>`.
259
+ *
260
+ * ```markdown
261
+ * > | a <![CDATA[>&<]]> b
262
+ * ^
263
+ * ```
264
+ *
265
+ * @type {State}
266
+ */
267
+ function cdataEnd(code) {
268
+ if (code === 62) {
269
+ return end(code);
270
+ }
271
+ if (code === 93) {
272
+ effects.consume(code);
273
+ return cdataEnd;
274
+ }
275
+ return cdata(code);
276
+ }
277
+
278
+ /**
279
+ * In declaration.
280
+ *
281
+ * ```markdown
282
+ * > | a <!b> c
283
+ * ^
284
+ * ```
285
+ *
286
+ * @type {State}
287
+ */
288
+ function declaration(code) {
289
+ if (code === null || code === 62) {
290
+ return end(code);
291
+ }
292
+ if (markdownLineEnding(code)) {
293
+ returnState = declaration;
294
+ return lineEndingBefore(code);
295
+ }
296
+ effects.consume(code);
297
+ return declaration;
298
+ }
299
+
300
+ /**
301
+ * In instruction.
302
+ *
303
+ * ```markdown
304
+ * > | a <?b?> c
305
+ * ^
306
+ * ```
307
+ *
308
+ * @type {State}
309
+ */
310
+ function instruction(code) {
311
+ if (code === null) {
312
+ return nok(code);
313
+ }
314
+ if (code === 63) {
315
+ effects.consume(code);
316
+ return instructionClose;
317
+ }
318
+ if (markdownLineEnding(code)) {
319
+ returnState = instruction;
320
+ return lineEndingBefore(code);
321
+ }
322
+ effects.consume(code);
323
+ return instruction;
324
+ }
325
+
326
+ /**
327
+ * In instruction, after `?`, at `>`.
328
+ *
329
+ * ```markdown
330
+ * > | a <?b?> c
331
+ * ^
332
+ * ```
333
+ *
334
+ * @type {State}
335
+ */
336
+ function instructionClose(code) {
337
+ return code === 62 ? end(code) : instruction(code);
338
+ }
339
+
340
+ /**
341
+ * After `</`, in closing tag, at tag name.
342
+ *
343
+ * ```markdown
344
+ * > | a </b> c
345
+ * ^
346
+ * ```
347
+ *
348
+ * @type {State}
349
+ */
350
+ function tagCloseStart(code) {
351
+ // ASCII alphabetical.
352
+ if (asciiAlpha(code)) {
353
+ effects.consume(code);
354
+ return tagClose;
355
+ }
356
+ return nok(code);
357
+ }
358
+
359
+ /**
360
+ * After `</x`, in a tag name.
361
+ *
362
+ * ```markdown
363
+ * > | a </b> c
364
+ * ^
365
+ * ```
366
+ *
367
+ * @type {State}
368
+ */
369
+ function tagClose(code) {
370
+ // ASCII alphanumerical and `-`.
371
+ if (code === 45 || asciiAlphanumeric(code)) {
372
+ effects.consume(code);
373
+ return tagClose;
374
+ }
375
+ return tagCloseBetween(code);
376
+ }
377
+
378
+ /**
379
+ * In closing tag, after tag name.
380
+ *
381
+ * ```markdown
382
+ * > | a </b> c
383
+ * ^
384
+ * ```
385
+ *
386
+ * @type {State}
387
+ */
388
+ function tagCloseBetween(code) {
389
+ if (markdownLineEnding(code)) {
390
+ returnState = tagCloseBetween;
391
+ return lineEndingBefore(code);
392
+ }
393
+ if (markdownSpace(code)) {
394
+ effects.consume(code);
395
+ return tagCloseBetween;
396
+ }
397
+ return end(code);
398
+ }
399
+
400
+ /**
401
+ * After `<x`, in opening tag name.
402
+ *
403
+ * ```markdown
404
+ * > | a <b> c
405
+ * ^
406
+ * ```
407
+ *
408
+ * @type {State}
409
+ */
410
+ function tagOpen(code) {
411
+ // ASCII alphanumerical and `-`.
412
+ if (code === 45 || asciiAlphanumeric(code)) {
413
+ effects.consume(code);
414
+ return tagOpen;
415
+ }
416
+ if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
417
+ return tagOpenBetween(code);
418
+ }
419
+ return nok(code);
420
+ }
421
+
422
+ /**
423
+ * In opening tag, after tag name.
424
+ *
425
+ * ```markdown
426
+ * > | a <b> c
427
+ * ^
428
+ * ```
429
+ *
430
+ * @type {State}
431
+ */
432
+ function tagOpenBetween(code) {
433
+ if (code === 47) {
434
+ effects.consume(code);
435
+ return end;
436
+ }
437
+
438
+ // ASCII alphabetical and `:` and `_`.
439
+ if (code === 58 || code === 95 || asciiAlpha(code)) {
440
+ effects.consume(code);
441
+ return tagOpenAttributeName;
442
+ }
443
+ if (markdownLineEnding(code)) {
444
+ returnState = tagOpenBetween;
445
+ return lineEndingBefore(code);
446
+ }
447
+ if (markdownSpace(code)) {
448
+ effects.consume(code);
449
+ return tagOpenBetween;
450
+ }
451
+ return end(code);
452
+ }
453
+
454
+ /**
455
+ * In attribute name.
456
+ *
457
+ * ```markdown
458
+ * > | a <b c> d
459
+ * ^
460
+ * ```
461
+ *
462
+ * @type {State}
463
+ */
464
+ function tagOpenAttributeName(code) {
465
+ // ASCII alphabetical and `-`, `.`, `:`, and `_`.
466
+ if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
467
+ effects.consume(code);
468
+ return tagOpenAttributeName;
469
+ }
470
+ return tagOpenAttributeNameAfter(code);
471
+ }
472
+
473
+ /**
474
+ * After attribute name, before initializer, the end of the tag, or
475
+ * whitespace.
476
+ *
477
+ * ```markdown
478
+ * > | a <b c> d
479
+ * ^
480
+ * ```
481
+ *
482
+ * @type {State}
483
+ */
484
+ function tagOpenAttributeNameAfter(code) {
485
+ if (code === 61) {
486
+ effects.consume(code);
487
+ return tagOpenAttributeValueBefore;
488
+ }
489
+ if (markdownLineEnding(code)) {
490
+ returnState = tagOpenAttributeNameAfter;
491
+ return lineEndingBefore(code);
492
+ }
493
+ if (markdownSpace(code)) {
494
+ effects.consume(code);
495
+ return tagOpenAttributeNameAfter;
496
+ }
497
+ return tagOpenBetween(code);
498
+ }
499
+
500
+ /**
501
+ * Before unquoted, double quoted, or single quoted attribute value, allowing
502
+ * whitespace.
503
+ *
504
+ * ```markdown
505
+ * > | a <b c=d> e
506
+ * ^
507
+ * ```
508
+ *
509
+ * @type {State}
510
+ */
511
+ function tagOpenAttributeValueBefore(code) {
512
+ if (code === null || code === 60 || code === 61 || code === 62 || code === 96) {
513
+ return nok(code);
514
+ }
515
+ if (code === 34 || code === 39) {
516
+ effects.consume(code);
517
+ marker = code;
518
+ return tagOpenAttributeValueQuoted;
519
+ }
520
+ if (markdownLineEnding(code)) {
521
+ returnState = tagOpenAttributeValueBefore;
522
+ return lineEndingBefore(code);
523
+ }
524
+ if (markdownSpace(code)) {
525
+ effects.consume(code);
526
+ return tagOpenAttributeValueBefore;
527
+ }
528
+ effects.consume(code);
529
+ return tagOpenAttributeValueUnquoted;
530
+ }
531
+
532
+ /**
533
+ * In double or single quoted attribute value.
534
+ *
535
+ * ```markdown
536
+ * > | a <b c="d"> e
537
+ * ^
538
+ * ```
539
+ *
540
+ * @type {State}
541
+ */
542
+ function tagOpenAttributeValueQuoted(code) {
543
+ if (code === marker) {
544
+ effects.consume(code);
545
+ marker = undefined;
546
+ return tagOpenAttributeValueQuotedAfter;
547
+ }
548
+ if (code === null) {
549
+ return nok(code);
550
+ }
551
+ if (markdownLineEnding(code)) {
552
+ returnState = tagOpenAttributeValueQuoted;
553
+ return lineEndingBefore(code);
554
+ }
555
+ effects.consume(code);
556
+ return tagOpenAttributeValueQuoted;
557
+ }
558
+
559
+ /**
560
+ * In unquoted attribute value.
561
+ *
562
+ * ```markdown
563
+ * > | a <b c=d> e
564
+ * ^
565
+ * ```
566
+ *
567
+ * @type {State}
568
+ */
569
+ function tagOpenAttributeValueUnquoted(code) {
570
+ if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) {
571
+ return nok(code);
572
+ }
573
+ if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
574
+ return tagOpenBetween(code);
575
+ }
576
+ effects.consume(code);
577
+ return tagOpenAttributeValueUnquoted;
578
+ }
579
+
580
+ /**
581
+ * After double or single quoted attribute value, before whitespace or the end
582
+ * of the tag.
583
+ *
584
+ * ```markdown
585
+ * > | a <b c="d"> e
586
+ * ^
587
+ * ```
588
+ *
589
+ * @type {State}
590
+ */
591
+ function tagOpenAttributeValueQuotedAfter(code) {
592
+ if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
593
+ return tagOpenBetween(code);
594
+ }
595
+ return nok(code);
596
+ }
597
+
598
+ /**
599
+ * In certain circumstances of a tag where only an `>` is allowed.
600
+ *
601
+ * ```markdown
602
+ * > | a <b c="d"> e
603
+ * ^
604
+ * ```
605
+ *
606
+ * @type {State}
607
+ */
608
+ function end(code) {
609
+ if (code === 62) {
610
+ effects.consume(code);
611
+ effects.exit("htmlTextData");
612
+ effects.exit("htmlText");
613
+ return ok;
614
+ }
615
+ return nok(code);
616
+ }
617
+
618
+ /**
619
+ * At eol.
620
+ *
621
+ * > ๐Ÿ‘‰ **Note**: we canโ€™t have blank lines in text, so no need to worry about
622
+ * > empty tokens.
623
+ *
624
+ * ```markdown
625
+ * > | a <!--a
626
+ * ^
627
+ * | b-->
628
+ * ```
629
+ *
630
+ * @type {State}
631
+ */
632
+ function lineEndingBefore(code) {
633
+ effects.exit("htmlTextData");
634
+ effects.enter("lineEnding");
635
+ effects.consume(code);
636
+ effects.exit("lineEnding");
637
+ return lineEndingAfter;
638
+ }
639
+
640
+ /**
641
+ * After eol, at optional whitespace.
642
+ *
643
+ * > ๐Ÿ‘‰ **Note**: we canโ€™t have blank lines in text, so no need to worry about
644
+ * > empty tokens.
645
+ *
646
+ * ```markdown
647
+ * | a <!--a
648
+ * > | b-->
649
+ * ^
650
+ * ```
651
+ *
652
+ * @type {State}
653
+ */
654
+ function lineEndingAfter(code) {
655
+ // Always populated by defaults.
656
+
657
+ return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : lineEndingAfterPrefix(code);
658
+ }
659
+
660
+ /**
661
+ * After eol, after optional whitespace.
662
+ *
663
+ * > ๐Ÿ‘‰ **Note**: we canโ€™t have blank lines in text, so no need to worry about
664
+ * > empty tokens.
665
+ *
666
+ * ```markdown
667
+ * | a <!--a
668
+ * > | b-->
669
+ * ^
670
+ * ```
671
+ *
672
+ * @type {State}
673
+ */
674
+ function lineEndingAfterPrefix(code) {
675
+ effects.enter("htmlTextData");
676
+ return returnState(code);
677
+ }
678
+ }