hermium 0.1.9 → 0.2.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 (209) hide show
  1. package/README.md +56 -0
  2. package/bin/hermium.mjs +185 -164
  3. package/dist/api.mjs +3513 -0
  4. package/dist/public/assets/css/index-Dfs9RUU9.css +1 -0
  5. package/dist/public/assets/css/styles-B8p6jk5Z.css +1 -0
  6. package/dist/public/assets/js/ChatInputBlock-Bw7AL70H.js +1 -0
  7. package/dist/public/assets/js/MarkdownMessage-8d7Y6VL-.js +1 -0
  8. package/dist/public/assets/js/base-ui-BvQbAt_1.js +1 -0
  9. package/dist/public/assets/js/chat._sessionId-BG6lVraH.js +1 -0
  10. package/dist/public/assets/js/chat.index-D2zdMPTT.js +1 -0
  11. package/dist/public/assets/js/index-C0AK45FU.js +60 -0
  12. package/dist/public/assets/js/index-Cx5En4FK.js +1 -0
  13. package/dist/public/assets/js/memory-CeSRdTkW.js +3 -0
  14. package/dist/public/assets/js/router-8uDKazL-.js +1 -0
  15. package/dist/public/assets/js/settings-Bc3Y5zXO.js +1 -0
  16. package/dist/public/assets/js/skills-DZv7sA_5.js +1 -0
  17. package/dist/public/assets/js/theme-CPkdkpaj.js +1 -0
  18. package/dist/public/assets/js/usage-DXQsT9_b.js +1 -0
  19. package/dist/public/assets/woff2/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  20. package/dist/public/assets/woff2/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  21. package/dist/public/assets/woff2/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  22. package/dist/public/assets/woff2/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  23. package/dist/public/assets/woff2/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  24. package/dist/public/favicon.ico +0 -0
  25. package/dist/public/logo.png +0 -0
  26. package/package.json +1 -1
  27. package/dist/public/assets/IconAlertCircle-BHkmI3j7.js +0 -1
  28. package/dist/public/assets/IconAlertTriangle-wCJudlVg.js +0 -1
  29. package/dist/public/assets/IconCheck-CFuEh_p7.js +0 -1
  30. package/dist/public/assets/IconLoader2-BIx3OuF9.js +0 -1
  31. package/dist/public/assets/IconRefresh-Dgm93w3T.js +0 -1
  32. package/dist/public/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
  33. package/dist/public/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
  34. package/dist/public/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
  35. package/dist/public/assets/index-Bbz3abmO.js +0 -14
  36. package/dist/public/assets/index-CWUaRwcE.js +0 -1
  37. package/dist/public/assets/index-CinLq3cd.js +0 -1
  38. package/dist/public/assets/index-CrQs9n6q.js +0 -29
  39. package/dist/public/assets/index-CtacpN3I.js +0 -1
  40. package/dist/public/assets/index-DY7aE-9s.js +0 -2
  41. package/dist/public/assets/index-DkYGodJj.js +0 -94
  42. package/dist/public/assets/index-DvDLadUx.js +0 -1
  43. package/dist/public/assets/index-U6RcWedt.js +0 -1
  44. package/dist/public/assets/index-_6iFZ0fh.js +0 -1
  45. package/dist/public/assets/index-enFS26SU.js +0 -1
  46. package/dist/public/assets/input-eNcwlDHp.js +0 -1
  47. package/dist/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  48. package/dist/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  49. package/dist/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  50. package/dist/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  51. package/dist/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  52. package/dist/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  53. package/dist/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  54. package/dist/public/assets/queries-iHRgZzw2.js +0 -1
  55. package/dist/public/assets/styles-KcflDlA_.css +0 -1
  56. package/dist/public/assets/switch-B1DcZLwL.js +0 -1
  57. package/dist/public/assets/syntax-highlighter-DWPF-A_h.js +0 -6
  58. package/dist/public/assets/textarea-Di_syYTS.js +0 -1
  59. package/dist/public/favicon.png +0 -0
  60. package/dist/public/nous-logo.png +0 -0
  61. package/dist/server/index.mjs +0 -244
  62. package/dist/web-server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +0 -6
  63. package/dist/web-server/_chunks/ssr-renderer.mjs +0 -22
  64. package/dist/web-server/_libs/babel__runtime.mjs +0 -237
  65. package/dist/web-server/_libs/bail.mjs +0 -8
  66. package/dist/web-server/_libs/base-ui__react.mjs +0 -9554
  67. package/dist/web-server/_libs/base-ui__utils.mjs +0 -1101
  68. package/dist/web-server/_libs/ccount.mjs +0 -16
  69. package/dist/web-server/_libs/character-entities-legacy.mjs +0 -111
  70. package/dist/web-server/_libs/character-entities.mjs +0 -2130
  71. package/dist/web-server/_libs/character-reference-invalid.mjs +0 -33
  72. package/dist/web-server/_libs/class-variance-authority.mjs +0 -44
  73. package/dist/web-server/_libs/clsx.mjs +0 -16
  74. package/dist/web-server/_libs/comma-separated-tokens.mjs +0 -31
  75. package/dist/web-server/_libs/cookie-es.mjs +0 -44
  76. package/dist/web-server/_libs/croner.mjs +0 -1
  77. package/dist/web-server/_libs/crossws.mjs +0 -1
  78. package/dist/web-server/_libs/decode-named-character-reference+[...].mjs +0 -8
  79. package/dist/web-server/_libs/devlop.mjs +0 -8
  80. package/dist/web-server/_libs/escape-string-regexp.mjs +0 -9
  81. package/dist/web-server/_libs/estree-util-is-identifier-name.mjs +0 -11
  82. package/dist/web-server/_libs/extend.mjs +0 -97
  83. package/dist/web-server/_libs/fault.mjs +0 -1
  84. package/dist/web-server/_libs/floating-ui__core.mjs +0 -663
  85. package/dist/web-server/_libs/floating-ui__dom.mjs +0 -624
  86. package/dist/web-server/_libs/floating-ui__react-dom.mjs +0 -279
  87. package/dist/web-server/_libs/floating-ui__utils.mjs +0 -322
  88. package/dist/web-server/_libs/format.mjs +0 -1
  89. package/dist/web-server/_libs/h3.mjs +0 -408
  90. package/dist/web-server/_libs/hast-util-parse-selector.mjs +0 -39
  91. package/dist/web-server/_libs/hast-util-to-jsx-runtime.mjs +0 -388
  92. package/dist/web-server/_libs/hast-util-whitespace.mjs +0 -10
  93. package/dist/web-server/_libs/hastscript.mjs +0 -200
  94. package/dist/web-server/_libs/highlight.js.mjs +0 -1
  95. package/dist/web-server/_libs/hookable.mjs +0 -1
  96. package/dist/web-server/_libs/html-url-attributes.mjs +0 -26
  97. package/dist/web-server/_libs/inline-style-parser.mjs +0 -142
  98. package/dist/web-server/_libs/is-alphabetical.mjs +0 -7
  99. package/dist/web-server/_libs/is-alphanumerical.mjs +0 -8
  100. package/dist/web-server/_libs/is-decimal.mjs +0 -7
  101. package/dist/web-server/_libs/is-hexadecimal.mjs +0 -7
  102. package/dist/web-server/_libs/is-plain-obj.mjs +0 -10
  103. package/dist/web-server/_libs/isbot.mjs +0 -21
  104. package/dist/web-server/_libs/longest-streak.mjs +0 -25
  105. package/dist/web-server/_libs/lowlight.mjs +0 -1
  106. package/dist/web-server/_libs/markdown-table.mjs +0 -142
  107. package/dist/web-server/_libs/mdast-util-find-and-replace.mjs +0 -109
  108. package/dist/web-server/_libs/mdast-util-from-markdown.mjs +0 -717
  109. package/dist/web-server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +0 -156
  110. package/dist/web-server/_libs/mdast-util-gfm-footnote.mjs +0 -117
  111. package/dist/web-server/_libs/mdast-util-gfm-strikethrough.mjs +0 -54
  112. package/dist/web-server/_libs/mdast-util-gfm-table.mjs +0 -157
  113. package/dist/web-server/_libs/mdast-util-gfm-task-list-item.mjs +0 -77
  114. package/dist/web-server/_libs/mdast-util-gfm.mjs +0 -29
  115. package/dist/web-server/_libs/mdast-util-phrasing.mjs +0 -30
  116. package/dist/web-server/_libs/mdast-util-to-hast.mjs +0 -710
  117. package/dist/web-server/_libs/mdast-util-to-markdown.mjs +0 -798
  118. package/dist/web-server/_libs/mdast-util-to-string.mjs +0 -38
  119. package/dist/web-server/_libs/micromark-core-commonmark.mjs +0 -2259
  120. package/dist/web-server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +0 -344
  121. package/dist/web-server/_libs/micromark-extension-gfm-footnote+[...].mjs +0 -279
  122. package/dist/web-server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +0 -98
  123. package/dist/web-server/_libs/micromark-extension-gfm-table.mjs +0 -491
  124. package/dist/web-server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +0 -1
  125. package/dist/web-server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +0 -77
  126. package/dist/web-server/_libs/micromark-extension-gfm.mjs +0 -18
  127. package/dist/web-server/_libs/micromark-factory-destination.mjs +0 -94
  128. package/dist/web-server/_libs/micromark-factory-label.mjs +0 -63
  129. package/dist/web-server/_libs/micromark-factory-space.mjs +0 -24
  130. package/dist/web-server/_libs/micromark-factory-title.mjs +0 -65
  131. package/dist/web-server/_libs/micromark-factory-whitespace.mjs +0 -22
  132. package/dist/web-server/_libs/micromark-util-character.mjs +0 -44
  133. package/dist/web-server/_libs/micromark-util-chunked.mjs +0 -36
  134. package/dist/web-server/_libs/micromark-util-classify-character+[...].mjs +0 -12
  135. package/dist/web-server/_libs/micromark-util-combine-extensions+[...].mjs +0 -41
  136. package/dist/web-server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +0 -19
  137. package/dist/web-server/_libs/micromark-util-decode-string.mjs +0 -21
  138. package/dist/web-server/_libs/micromark-util-encode.mjs +0 -1
  139. package/dist/web-server/_libs/micromark-util-html-tag-name.mjs +0 -69
  140. package/dist/web-server/_libs/micromark-util-normalize-identifier+[...].mjs +0 -6
  141. package/dist/web-server/_libs/micromark-util-resolve-all.mjs +0 -15
  142. package/dist/web-server/_libs/micromark-util-sanitize-uri.mjs +0 -41
  143. package/dist/web-server/_libs/micromark-util-subtokenize.mjs +0 -346
  144. package/dist/web-server/_libs/micromark.mjs +0 -906
  145. package/dist/web-server/_libs/ocache.mjs +0 -1
  146. package/dist/web-server/_libs/ohash.mjs +0 -1
  147. package/dist/web-server/_libs/parse-entities.mjs +0 -245
  148. package/dist/web-server/_libs/property-information.mjs +0 -1210
  149. package/dist/web-server/_libs/react-dom.mjs +0 -10779
  150. package/dist/web-server/_libs/react-markdown.mjs +0 -147
  151. package/dist/web-server/_libs/react-syntax-highlighter.mjs +0 -941
  152. package/dist/web-server/_libs/react.mjs +0 -513
  153. package/dist/web-server/_libs/refractor.mjs +0 -2425
  154. package/dist/web-server/_libs/remark-gfm.mjs +0 -20
  155. package/dist/web-server/_libs/remark-parse.mjs +0 -19
  156. package/dist/web-server/_libs/remark-rehype.mjs +0 -21
  157. package/dist/web-server/_libs/reselect.mjs +0 -1
  158. package/dist/web-server/_libs/rou3.mjs +0 -8
  159. package/dist/web-server/_libs/seroval-plugins.mjs +0 -58
  160. package/dist/web-server/_libs/seroval.mjs +0 -1775
  161. package/dist/web-server/_libs/space-separated-tokens.mjs +0 -11
  162. package/dist/web-server/_libs/srvx.mjs +0 -781
  163. package/dist/web-server/_libs/style-to-js.mjs +0 -72
  164. package/dist/web-server/_libs/style-to-object.mjs +0 -38
  165. package/dist/web-server/_libs/tabler__icons-react.mjs +0 -230
  166. package/dist/web-server/_libs/tanstack__history.mjs +0 -204
  167. package/dist/web-server/_libs/tanstack__query-core.mjs +0 -2552
  168. package/dist/web-server/_libs/tanstack__react-query.mjs +0 -190
  169. package/dist/web-server/_libs/tanstack__react-router.mjs +0 -1120
  170. package/dist/web-server/_libs/tanstack__react-store.mjs +0 -2
  171. package/dist/web-server/_libs/tanstack__router-core.mjs +0 -4288
  172. package/dist/web-server/_libs/tanstack__store.mjs +0 -1
  173. package/dist/web-server/_libs/trim-lines.mjs +0 -41
  174. package/dist/web-server/_libs/trough.mjs +0 -85
  175. package/dist/web-server/_libs/ufo.mjs +0 -54
  176. package/dist/web-server/_libs/unctx.mjs +0 -1
  177. package/dist/web-server/_libs/ungap__structured-clone.mjs +0 -224
  178. package/dist/web-server/_libs/unified.mjs +0 -661
  179. package/dist/web-server/_libs/unist-util-is.mjs +0 -100
  180. package/dist/web-server/_libs/unist-util-position.mjs +0 -27
  181. package/dist/web-server/_libs/unist-util-stringify-position.mjs +0 -27
  182. package/dist/web-server/_libs/unist-util-visit-parents.mjs +0 -83
  183. package/dist/web-server/_libs/unist-util-visit.mjs +0 -24
  184. package/dist/web-server/_libs/unstorage.mjs +0 -1
  185. package/dist/web-server/_libs/use-sync-external-store.mjs +0 -139
  186. package/dist/web-server/_libs/vfile-message.mjs +0 -138
  187. package/dist/web-server/_libs/vfile.mjs +0 -467
  188. package/dist/web-server/_libs/zod.mjs +0 -3915
  189. package/dist/web-server/_libs/zustand.mjs +0 -343
  190. package/dist/web-server/_libs/zwitch.mjs +0 -1
  191. package/dist/web-server/_ssr/index-0n2Z3BPQ.mjs +0 -369
  192. package/dist/web-server/_ssr/index-6itDALOw.mjs +0 -339
  193. package/dist/web-server/_ssr/index-BIRTrOmp.mjs +0 -449
  194. package/dist/web-server/_ssr/index-BPzfADac.mjs +0 -66
  195. package/dist/web-server/_ssr/index-BQE3bF14.mjs +0 -1870
  196. package/dist/web-server/_ssr/index-C5HpvlUP.mjs +0 -190
  197. package/dist/web-server/_ssr/index-C_ZxnypN.mjs +0 -213
  198. package/dist/web-server/_ssr/index-Ca8JFH8f.mjs +0 -612
  199. package/dist/web-server/_ssr/index-DNVESZiA.mjs +0 -513
  200. package/dist/web-server/_ssr/index.mjs +0 -1558
  201. package/dist/web-server/_ssr/input-CqXjTRQg.mjs +0 -20
  202. package/dist/web-server/_ssr/queries-3H_19mUt.mjs +0 -16
  203. package/dist/web-server/_ssr/router-sbsNus0Y.mjs +0 -2093
  204. package/dist/web-server/_ssr/start-HYkvq4Ni.mjs +0 -4
  205. package/dist/web-server/_ssr/switch-usf2F1UM.mjs +0 -33
  206. package/dist/web-server/_ssr/syntax-highlighter-5vezNTce.mjs +0 -62
  207. package/dist/web-server/_ssr/textarea-DfRheWY0.mjs +0 -18
  208. package/dist/web-server/_tanstack-start-manifest_v-DqW-pKEH.mjs +0 -4
  209. package/dist/web-server/index.mjs +0 -597
@@ -1,2259 +0,0 @@
1
- import { p as push, s as splice } from "./micromark-util-chunked.mjs";
2
- import { c as classifyCharacter } from "./micromark-util-classify-character+[...].mjs";
3
- import { r as resolveAll } from "./micromark-util-resolve-all.mjs";
4
- import { e as asciiAlpha, a as asciiAlphanumeric, f as asciiControl, g as asciiAtext, b as markdownSpace, m as markdownLineEnding, h as asciiPunctuation, i as asciiHexDigit, j as asciiDigit, c as markdownLineEndingOrSpace } from "./micromark-util-character.mjs";
5
- import { f as factorySpace } from "./micromark-factory-space.mjs";
6
- import { d as decodeNamedCharacterReference } from "./decode-named-character-reference+[...].mjs";
7
- import { s as subtokenize } from "./micromark-util-subtokenize.mjs";
8
- import { f as factoryDestination } from "./micromark-factory-destination.mjs";
9
- import { f as factoryLabel } from "./micromark-factory-label.mjs";
10
- import { f as factoryTitle } from "./micromark-factory-title.mjs";
11
- import { f as factoryWhitespace } from "./micromark-factory-whitespace.mjs";
12
- import { n as normalizeIdentifier } from "./micromark-util-normalize-identifier+[...].mjs";
13
- import { h as htmlRawNames, a as htmlBlockNames } from "./micromark-util-html-tag-name.mjs";
14
- const attention = {
15
- name: "attention",
16
- resolveAll: resolveAllAttention,
17
- tokenize: tokenizeAttention
18
- };
19
- function resolveAllAttention(events, context) {
20
- let index = -1;
21
- let open;
22
- let group;
23
- let text;
24
- let openingSequence;
25
- let closingSequence;
26
- let use;
27
- let nextEvents;
28
- let offset;
29
- while (++index < events.length) {
30
- if (events[index][0] === "enter" && events[index][1].type === "attentionSequence" && events[index][1]._close) {
31
- open = index;
32
- while (open--) {
33
- if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open && // If the markers are the same:
34
- context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index][1]).charCodeAt(0)) {
35
- if ((events[open][1]._close || events[index][1]._open) && (events[index][1].end.offset - events[index][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index][1].end.offset - events[index][1].start.offset) % 3)) {
36
- continue;
37
- }
38
- use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1;
39
- const start = {
40
- ...events[open][1].end
41
- };
42
- const end = {
43
- ...events[index][1].start
44
- };
45
- movePoint(start, -use);
46
- movePoint(end, use);
47
- openingSequence = {
48
- type: use > 1 ? "strongSequence" : "emphasisSequence",
49
- start,
50
- end: {
51
- ...events[open][1].end
52
- }
53
- };
54
- closingSequence = {
55
- type: use > 1 ? "strongSequence" : "emphasisSequence",
56
- start: {
57
- ...events[index][1].start
58
- },
59
- end
60
- };
61
- text = {
62
- type: use > 1 ? "strongText" : "emphasisText",
63
- start: {
64
- ...events[open][1].end
65
- },
66
- end: {
67
- ...events[index][1].start
68
- }
69
- };
70
- group = {
71
- type: use > 1 ? "strong" : "emphasis",
72
- start: {
73
- ...openingSequence.start
74
- },
75
- end: {
76
- ...closingSequence.end
77
- }
78
- };
79
- events[open][1].end = {
80
- ...openingSequence.start
81
- };
82
- events[index][1].start = {
83
- ...closingSequence.end
84
- };
85
- nextEvents = [];
86
- if (events[open][1].end.offset - events[open][1].start.offset) {
87
- nextEvents = push(nextEvents, [["enter", events[open][1], context], ["exit", events[open][1], context]]);
88
- }
89
- nextEvents = push(nextEvents, [["enter", group, context], ["enter", openingSequence, context], ["exit", openingSequence, context], ["enter", text, context]]);
90
- nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context));
91
- nextEvents = push(nextEvents, [["exit", text, context], ["enter", closingSequence, context], ["exit", closingSequence, context], ["exit", group, context]]);
92
- if (events[index][1].end.offset - events[index][1].start.offset) {
93
- offset = 2;
94
- nextEvents = push(nextEvents, [["enter", events[index][1], context], ["exit", events[index][1], context]]);
95
- } else {
96
- offset = 0;
97
- }
98
- splice(events, open - 1, index - open + 3, nextEvents);
99
- index = open + nextEvents.length - offset - 2;
100
- break;
101
- }
102
- }
103
- }
104
- }
105
- index = -1;
106
- while (++index < events.length) {
107
- if (events[index][1].type === "attentionSequence") {
108
- events[index][1].type = "data";
109
- }
110
- }
111
- return events;
112
- }
113
- function tokenizeAttention(effects, ok) {
114
- const attentionMarkers = this.parser.constructs.attentionMarkers.null;
115
- const previous2 = this.previous;
116
- const before = classifyCharacter(previous2);
117
- let marker;
118
- return start;
119
- function start(code) {
120
- marker = code;
121
- effects.enter("attentionSequence");
122
- return inside(code);
123
- }
124
- function inside(code) {
125
- if (code === marker) {
126
- effects.consume(code);
127
- return inside;
128
- }
129
- const token = effects.exit("attentionSequence");
130
- const after = classifyCharacter(code);
131
- const open = !after || after === 2 && before || attentionMarkers.includes(code);
132
- const close = !before || before === 2 && after || attentionMarkers.includes(previous2);
133
- token._open = Boolean(marker === 42 ? open : open && (before || !close));
134
- token._close = Boolean(marker === 42 ? close : close && (after || !open));
135
- return ok(code);
136
- }
137
- }
138
- function movePoint(point, offset) {
139
- point.column += offset;
140
- point.offset += offset;
141
- point._bufferIndex += offset;
142
- }
143
- const autolink = {
144
- name: "autolink",
145
- tokenize: tokenizeAutolink
146
- };
147
- function tokenizeAutolink(effects, ok, nok) {
148
- let size = 0;
149
- return start;
150
- function start(code) {
151
- effects.enter("autolink");
152
- effects.enter("autolinkMarker");
153
- effects.consume(code);
154
- effects.exit("autolinkMarker");
155
- effects.enter("autolinkProtocol");
156
- return open;
157
- }
158
- function open(code) {
159
- if (asciiAlpha(code)) {
160
- effects.consume(code);
161
- return schemeOrEmailAtext;
162
- }
163
- if (code === 64) {
164
- return nok(code);
165
- }
166
- return emailAtext(code);
167
- }
168
- function schemeOrEmailAtext(code) {
169
- if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {
170
- size = 1;
171
- return schemeInsideOrEmailAtext(code);
172
- }
173
- return emailAtext(code);
174
- }
175
- function schemeInsideOrEmailAtext(code) {
176
- if (code === 58) {
177
- effects.consume(code);
178
- size = 0;
179
- return urlInside;
180
- }
181
- if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) {
182
- effects.consume(code);
183
- return schemeInsideOrEmailAtext;
184
- }
185
- size = 0;
186
- return emailAtext(code);
187
- }
188
- function urlInside(code) {
189
- if (code === 62) {
190
- effects.exit("autolinkProtocol");
191
- effects.enter("autolinkMarker");
192
- effects.consume(code);
193
- effects.exit("autolinkMarker");
194
- effects.exit("autolink");
195
- return ok;
196
- }
197
- if (code === null || code === 32 || code === 60 || asciiControl(code)) {
198
- return nok(code);
199
- }
200
- effects.consume(code);
201
- return urlInside;
202
- }
203
- function emailAtext(code) {
204
- if (code === 64) {
205
- effects.consume(code);
206
- return emailAtSignOrDot;
207
- }
208
- if (asciiAtext(code)) {
209
- effects.consume(code);
210
- return emailAtext;
211
- }
212
- return nok(code);
213
- }
214
- function emailAtSignOrDot(code) {
215
- return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);
216
- }
217
- function emailLabel(code) {
218
- if (code === 46) {
219
- effects.consume(code);
220
- size = 0;
221
- return emailAtSignOrDot;
222
- }
223
- if (code === 62) {
224
- effects.exit("autolinkProtocol").type = "autolinkEmail";
225
- effects.enter("autolinkMarker");
226
- effects.consume(code);
227
- effects.exit("autolinkMarker");
228
- effects.exit("autolink");
229
- return ok;
230
- }
231
- return emailValue(code);
232
- }
233
- function emailValue(code) {
234
- if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {
235
- const next = code === 45 ? emailValue : emailLabel;
236
- effects.consume(code);
237
- return next;
238
- }
239
- return nok(code);
240
- }
241
- }
242
- const blankLine = {
243
- partial: true,
244
- tokenize: tokenizeBlankLine
245
- };
246
- function tokenizeBlankLine(effects, ok, nok) {
247
- return start;
248
- function start(code) {
249
- return markdownSpace(code) ? factorySpace(effects, after, "linePrefix")(code) : after(code);
250
- }
251
- function after(code) {
252
- return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
253
- }
254
- }
255
- const blockQuote = {
256
- continuation: {
257
- tokenize: tokenizeBlockQuoteContinuation
258
- },
259
- exit,
260
- name: "blockQuote",
261
- tokenize: tokenizeBlockQuoteStart
262
- };
263
- function tokenizeBlockQuoteStart(effects, ok, nok) {
264
- const self = this;
265
- return start;
266
- function start(code) {
267
- if (code === 62) {
268
- const state = self.containerState;
269
- if (!state.open) {
270
- effects.enter("blockQuote", {
271
- _container: true
272
- });
273
- state.open = true;
274
- }
275
- effects.enter("blockQuotePrefix");
276
- effects.enter("blockQuoteMarker");
277
- effects.consume(code);
278
- effects.exit("blockQuoteMarker");
279
- return after;
280
- }
281
- return nok(code);
282
- }
283
- function after(code) {
284
- if (markdownSpace(code)) {
285
- effects.enter("blockQuotePrefixWhitespace");
286
- effects.consume(code);
287
- effects.exit("blockQuotePrefixWhitespace");
288
- effects.exit("blockQuotePrefix");
289
- return ok;
290
- }
291
- effects.exit("blockQuotePrefix");
292
- return ok(code);
293
- }
294
- }
295
- function tokenizeBlockQuoteContinuation(effects, ok, nok) {
296
- const self = this;
297
- return contStart;
298
- function contStart(code) {
299
- if (markdownSpace(code)) {
300
- return factorySpace(effects, contBefore, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
301
- }
302
- return contBefore(code);
303
- }
304
- function contBefore(code) {
305
- return effects.attempt(blockQuote, ok, nok)(code);
306
- }
307
- }
308
- function exit(effects) {
309
- effects.exit("blockQuote");
310
- }
311
- const characterEscape = {
312
- name: "characterEscape",
313
- tokenize: tokenizeCharacterEscape
314
- };
315
- function tokenizeCharacterEscape(effects, ok, nok) {
316
- return start;
317
- function start(code) {
318
- effects.enter("characterEscape");
319
- effects.enter("escapeMarker");
320
- effects.consume(code);
321
- effects.exit("escapeMarker");
322
- return inside;
323
- }
324
- function inside(code) {
325
- if (asciiPunctuation(code)) {
326
- effects.enter("characterEscapeValue");
327
- effects.consume(code);
328
- effects.exit("characterEscapeValue");
329
- effects.exit("characterEscape");
330
- return ok;
331
- }
332
- return nok(code);
333
- }
334
- }
335
- const characterReference = {
336
- name: "characterReference",
337
- tokenize: tokenizeCharacterReference
338
- };
339
- function tokenizeCharacterReference(effects, ok, nok) {
340
- const self = this;
341
- let size = 0;
342
- let max;
343
- let test;
344
- return start;
345
- function start(code) {
346
- effects.enter("characterReference");
347
- effects.enter("characterReferenceMarker");
348
- effects.consume(code);
349
- effects.exit("characterReferenceMarker");
350
- return open;
351
- }
352
- function open(code) {
353
- if (code === 35) {
354
- effects.enter("characterReferenceMarkerNumeric");
355
- effects.consume(code);
356
- effects.exit("characterReferenceMarkerNumeric");
357
- return numeric;
358
- }
359
- effects.enter("characterReferenceValue");
360
- max = 31;
361
- test = asciiAlphanumeric;
362
- return value(code);
363
- }
364
- function numeric(code) {
365
- if (code === 88 || code === 120) {
366
- effects.enter("characterReferenceMarkerHexadecimal");
367
- effects.consume(code);
368
- effects.exit("characterReferenceMarkerHexadecimal");
369
- effects.enter("characterReferenceValue");
370
- max = 6;
371
- test = asciiHexDigit;
372
- return value;
373
- }
374
- effects.enter("characterReferenceValue");
375
- max = 7;
376
- test = asciiDigit;
377
- return value(code);
378
- }
379
- function value(code) {
380
- if (code === 59 && size) {
381
- const token = effects.exit("characterReferenceValue");
382
- if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) {
383
- return nok(code);
384
- }
385
- effects.enter("characterReferenceMarker");
386
- effects.consume(code);
387
- effects.exit("characterReferenceMarker");
388
- effects.exit("characterReference");
389
- return ok;
390
- }
391
- if (test(code) && size++ < max) {
392
- effects.consume(code);
393
- return value;
394
- }
395
- return nok(code);
396
- }
397
- }
398
- const nonLazyContinuation = {
399
- partial: true,
400
- tokenize: tokenizeNonLazyContinuation
401
- };
402
- const codeFenced = {
403
- concrete: true,
404
- name: "codeFenced",
405
- tokenize: tokenizeCodeFenced
406
- };
407
- function tokenizeCodeFenced(effects, ok, nok) {
408
- const self = this;
409
- const closeStart = {
410
- partial: true,
411
- tokenize: tokenizeCloseStart
412
- };
413
- let initialPrefix = 0;
414
- let sizeOpen = 0;
415
- let marker;
416
- return start;
417
- function start(code) {
418
- return beforeSequenceOpen(code);
419
- }
420
- function beforeSequenceOpen(code) {
421
- const tail = self.events[self.events.length - 1];
422
- initialPrefix = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
423
- marker = code;
424
- effects.enter("codeFenced");
425
- effects.enter("codeFencedFence");
426
- effects.enter("codeFencedFenceSequence");
427
- return sequenceOpen(code);
428
- }
429
- function sequenceOpen(code) {
430
- if (code === marker) {
431
- sizeOpen++;
432
- effects.consume(code);
433
- return sequenceOpen;
434
- }
435
- if (sizeOpen < 3) {
436
- return nok(code);
437
- }
438
- effects.exit("codeFencedFenceSequence");
439
- return markdownSpace(code) ? factorySpace(effects, infoBefore, "whitespace")(code) : infoBefore(code);
440
- }
441
- function infoBefore(code) {
442
- if (code === null || markdownLineEnding(code)) {
443
- effects.exit("codeFencedFence");
444
- return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
445
- }
446
- effects.enter("codeFencedFenceInfo");
447
- effects.enter("chunkString", {
448
- contentType: "string"
449
- });
450
- return info(code);
451
- }
452
- function info(code) {
453
- if (code === null || markdownLineEnding(code)) {
454
- effects.exit("chunkString");
455
- effects.exit("codeFencedFenceInfo");
456
- return infoBefore(code);
457
- }
458
- if (markdownSpace(code)) {
459
- effects.exit("chunkString");
460
- effects.exit("codeFencedFenceInfo");
461
- return factorySpace(effects, metaBefore, "whitespace")(code);
462
- }
463
- if (code === 96 && code === marker) {
464
- return nok(code);
465
- }
466
- effects.consume(code);
467
- return info;
468
- }
469
- function metaBefore(code) {
470
- if (code === null || markdownLineEnding(code)) {
471
- return infoBefore(code);
472
- }
473
- effects.enter("codeFencedFenceMeta");
474
- effects.enter("chunkString", {
475
- contentType: "string"
476
- });
477
- return meta(code);
478
- }
479
- function meta(code) {
480
- if (code === null || markdownLineEnding(code)) {
481
- effects.exit("chunkString");
482
- effects.exit("codeFencedFenceMeta");
483
- return infoBefore(code);
484
- }
485
- if (code === 96 && code === marker) {
486
- return nok(code);
487
- }
488
- effects.consume(code);
489
- return meta;
490
- }
491
- function atNonLazyBreak(code) {
492
- return effects.attempt(closeStart, after, contentBefore)(code);
493
- }
494
- function contentBefore(code) {
495
- effects.enter("lineEnding");
496
- effects.consume(code);
497
- effects.exit("lineEnding");
498
- return contentStart;
499
- }
500
- function contentStart(code) {
501
- return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, "linePrefix", initialPrefix + 1)(code) : beforeContentChunk(code);
502
- }
503
- function beforeContentChunk(code) {
504
- if (code === null || markdownLineEnding(code)) {
505
- return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
506
- }
507
- effects.enter("codeFlowValue");
508
- return contentChunk(code);
509
- }
510
- function contentChunk(code) {
511
- if (code === null || markdownLineEnding(code)) {
512
- effects.exit("codeFlowValue");
513
- return beforeContentChunk(code);
514
- }
515
- effects.consume(code);
516
- return contentChunk;
517
- }
518
- function after(code) {
519
- effects.exit("codeFenced");
520
- return ok(code);
521
- }
522
- function tokenizeCloseStart(effects2, ok2, nok2) {
523
- let size = 0;
524
- return startBefore;
525
- function startBefore(code) {
526
- effects2.enter("lineEnding");
527
- effects2.consume(code);
528
- effects2.exit("lineEnding");
529
- return start2;
530
- }
531
- function start2(code) {
532
- effects2.enter("codeFencedFence");
533
- return markdownSpace(code) ? factorySpace(effects2, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : beforeSequenceClose(code);
534
- }
535
- function beforeSequenceClose(code) {
536
- if (code === marker) {
537
- effects2.enter("codeFencedFenceSequence");
538
- return sequenceClose(code);
539
- }
540
- return nok2(code);
541
- }
542
- function sequenceClose(code) {
543
- if (code === marker) {
544
- size++;
545
- effects2.consume(code);
546
- return sequenceClose;
547
- }
548
- if (size >= sizeOpen) {
549
- effects2.exit("codeFencedFenceSequence");
550
- return markdownSpace(code) ? factorySpace(effects2, sequenceCloseAfter, "whitespace")(code) : sequenceCloseAfter(code);
551
- }
552
- return nok2(code);
553
- }
554
- function sequenceCloseAfter(code) {
555
- if (code === null || markdownLineEnding(code)) {
556
- effects2.exit("codeFencedFence");
557
- return ok2(code);
558
- }
559
- return nok2(code);
560
- }
561
- }
562
- }
563
- function tokenizeNonLazyContinuation(effects, ok, nok) {
564
- const self = this;
565
- return start;
566
- function start(code) {
567
- if (code === null) {
568
- return nok(code);
569
- }
570
- effects.enter("lineEnding");
571
- effects.consume(code);
572
- effects.exit("lineEnding");
573
- return lineStart;
574
- }
575
- function lineStart(code) {
576
- return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
577
- }
578
- }
579
- const codeIndented = {
580
- name: "codeIndented",
581
- tokenize: tokenizeCodeIndented
582
- };
583
- const furtherStart = {
584
- partial: true,
585
- tokenize: tokenizeFurtherStart
586
- };
587
- function tokenizeCodeIndented(effects, ok, nok) {
588
- const self = this;
589
- return start;
590
- function start(code) {
591
- effects.enter("codeIndented");
592
- return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code);
593
- }
594
- function afterPrefix(code) {
595
- const tail = self.events[self.events.length - 1];
596
- return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code) : nok(code);
597
- }
598
- function atBreak(code) {
599
- if (code === null) {
600
- return after(code);
601
- }
602
- if (markdownLineEnding(code)) {
603
- return effects.attempt(furtherStart, atBreak, after)(code);
604
- }
605
- effects.enter("codeFlowValue");
606
- return inside(code);
607
- }
608
- function inside(code) {
609
- if (code === null || markdownLineEnding(code)) {
610
- effects.exit("codeFlowValue");
611
- return atBreak(code);
612
- }
613
- effects.consume(code);
614
- return inside;
615
- }
616
- function after(code) {
617
- effects.exit("codeIndented");
618
- return ok(code);
619
- }
620
- }
621
- function tokenizeFurtherStart(effects, ok, nok) {
622
- const self = this;
623
- return furtherStart2;
624
- function furtherStart2(code) {
625
- if (self.parser.lazy[self.now().line]) {
626
- return nok(code);
627
- }
628
- if (markdownLineEnding(code)) {
629
- effects.enter("lineEnding");
630
- effects.consume(code);
631
- effects.exit("lineEnding");
632
- return furtherStart2;
633
- }
634
- return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code);
635
- }
636
- function afterPrefix(code) {
637
- const tail = self.events[self.events.length - 1];
638
- return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok(code) : markdownLineEnding(code) ? furtherStart2(code) : nok(code);
639
- }
640
- }
641
- const codeText = {
642
- name: "codeText",
643
- previous,
644
- resolve: resolveCodeText,
645
- tokenize: tokenizeCodeText
646
- };
647
- function resolveCodeText(events) {
648
- let tailExitIndex = events.length - 4;
649
- let headEnterIndex = 3;
650
- let index;
651
- let enter;
652
- if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === "space") && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === "space")) {
653
- index = headEnterIndex;
654
- while (++index < tailExitIndex) {
655
- if (events[index][1].type === "codeTextData") {
656
- events[headEnterIndex][1].type = "codeTextPadding";
657
- events[tailExitIndex][1].type = "codeTextPadding";
658
- headEnterIndex += 2;
659
- tailExitIndex -= 2;
660
- break;
661
- }
662
- }
663
- }
664
- index = headEnterIndex - 1;
665
- tailExitIndex++;
666
- while (++index <= tailExitIndex) {
667
- if (enter === void 0) {
668
- if (index !== tailExitIndex && events[index][1].type !== "lineEnding") {
669
- enter = index;
670
- }
671
- } else if (index === tailExitIndex || events[index][1].type === "lineEnding") {
672
- events[enter][1].type = "codeTextData";
673
- if (index !== enter + 2) {
674
- events[enter][1].end = events[index - 1][1].end;
675
- events.splice(enter + 2, index - enter - 2);
676
- tailExitIndex -= index - enter - 2;
677
- index = enter + 2;
678
- }
679
- enter = void 0;
680
- }
681
- }
682
- return events;
683
- }
684
- function previous(code) {
685
- return code !== 96 || this.events[this.events.length - 1][1].type === "characterEscape";
686
- }
687
- function tokenizeCodeText(effects, ok, nok) {
688
- let sizeOpen = 0;
689
- let size;
690
- let token;
691
- return start;
692
- function start(code) {
693
- effects.enter("codeText");
694
- effects.enter("codeTextSequence");
695
- return sequenceOpen(code);
696
- }
697
- function sequenceOpen(code) {
698
- if (code === 96) {
699
- effects.consume(code);
700
- sizeOpen++;
701
- return sequenceOpen;
702
- }
703
- effects.exit("codeTextSequence");
704
- return between(code);
705
- }
706
- function between(code) {
707
- if (code === null) {
708
- return nok(code);
709
- }
710
- if (code === 32) {
711
- effects.enter("space");
712
- effects.consume(code);
713
- effects.exit("space");
714
- return between;
715
- }
716
- if (code === 96) {
717
- token = effects.enter("codeTextSequence");
718
- size = 0;
719
- return sequenceClose(code);
720
- }
721
- if (markdownLineEnding(code)) {
722
- effects.enter("lineEnding");
723
- effects.consume(code);
724
- effects.exit("lineEnding");
725
- return between;
726
- }
727
- effects.enter("codeTextData");
728
- return data(code);
729
- }
730
- function data(code) {
731
- if (code === null || code === 32 || code === 96 || markdownLineEnding(code)) {
732
- effects.exit("codeTextData");
733
- return between(code);
734
- }
735
- effects.consume(code);
736
- return data;
737
- }
738
- function sequenceClose(code) {
739
- if (code === 96) {
740
- effects.consume(code);
741
- size++;
742
- return sequenceClose;
743
- }
744
- if (size === sizeOpen) {
745
- effects.exit("codeTextSequence");
746
- effects.exit("codeText");
747
- return ok(code);
748
- }
749
- token.type = "codeTextData";
750
- return data(code);
751
- }
752
- }
753
- const content = {
754
- resolve: resolveContent,
755
- tokenize: tokenizeContent
756
- };
757
- const continuationConstruct = {
758
- partial: true,
759
- tokenize: tokenizeContinuation
760
- };
761
- function resolveContent(events) {
762
- subtokenize(events);
763
- return events;
764
- }
765
- function tokenizeContent(effects, ok) {
766
- let previous2;
767
- return chunkStart;
768
- function chunkStart(code) {
769
- effects.enter("content");
770
- previous2 = effects.enter("chunkContent", {
771
- contentType: "content"
772
- });
773
- return chunkInside(code);
774
- }
775
- function chunkInside(code) {
776
- if (code === null) {
777
- return contentEnd(code);
778
- }
779
- if (markdownLineEnding(code)) {
780
- return effects.check(continuationConstruct, contentContinue, contentEnd)(code);
781
- }
782
- effects.consume(code);
783
- return chunkInside;
784
- }
785
- function contentEnd(code) {
786
- effects.exit("chunkContent");
787
- effects.exit("content");
788
- return ok(code);
789
- }
790
- function contentContinue(code) {
791
- effects.consume(code);
792
- effects.exit("chunkContent");
793
- previous2.next = effects.enter("chunkContent", {
794
- contentType: "content",
795
- previous: previous2
796
- });
797
- previous2 = previous2.next;
798
- return chunkInside;
799
- }
800
- }
801
- function tokenizeContinuation(effects, ok, nok) {
802
- const self = this;
803
- return startLookahead;
804
- function startLookahead(code) {
805
- effects.exit("chunkContent");
806
- effects.enter("lineEnding");
807
- effects.consume(code);
808
- effects.exit("lineEnding");
809
- return factorySpace(effects, prefixed, "linePrefix");
810
- }
811
- function prefixed(code) {
812
- if (code === null || markdownLineEnding(code)) {
813
- return nok(code);
814
- }
815
- const tail = self.events[self.events.length - 1];
816
- if (!self.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4) {
817
- return ok(code);
818
- }
819
- return effects.interrupt(self.parser.constructs.flow, nok, ok)(code);
820
- }
821
- }
822
- const definition = {
823
- name: "definition",
824
- tokenize: tokenizeDefinition
825
- };
826
- const titleBefore = {
827
- partial: true,
828
- tokenize: tokenizeTitleBefore
829
- };
830
- function tokenizeDefinition(effects, ok, nok) {
831
- const self = this;
832
- let identifier;
833
- return start;
834
- function start(code) {
835
- effects.enter("definition");
836
- return before(code);
837
- }
838
- function before(code) {
839
- return factoryLabel.call(
840
- self,
841
- effects,
842
- labelAfter,
843
- // Note: we don’t need to reset the way `markdown-rs` does.
844
- nok,
845
- "definitionLabel",
846
- "definitionLabelMarker",
847
- "definitionLabelString"
848
- )(code);
849
- }
850
- function labelAfter(code) {
851
- identifier = normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1));
852
- if (code === 58) {
853
- effects.enter("definitionMarker");
854
- effects.consume(code);
855
- effects.exit("definitionMarker");
856
- return markerAfter;
857
- }
858
- return nok(code);
859
- }
860
- function markerAfter(code) {
861
- return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, destinationBefore)(code) : destinationBefore(code);
862
- }
863
- function destinationBefore(code) {
864
- return factoryDestination(
865
- effects,
866
- destinationAfter,
867
- // Note: we don’t need to reset the way `markdown-rs` does.
868
- nok,
869
- "definitionDestination",
870
- "definitionDestinationLiteral",
871
- "definitionDestinationLiteralMarker",
872
- "definitionDestinationRaw",
873
- "definitionDestinationString"
874
- )(code);
875
- }
876
- function destinationAfter(code) {
877
- return effects.attempt(titleBefore, after, after)(code);
878
- }
879
- function after(code) {
880
- return markdownSpace(code) ? factorySpace(effects, afterWhitespace, "whitespace")(code) : afterWhitespace(code);
881
- }
882
- function afterWhitespace(code) {
883
- if (code === null || markdownLineEnding(code)) {
884
- effects.exit("definition");
885
- self.parser.defined.push(identifier);
886
- return ok(code);
887
- }
888
- return nok(code);
889
- }
890
- }
891
- function tokenizeTitleBefore(effects, ok, nok) {
892
- return titleBefore2;
893
- function titleBefore2(code) {
894
- return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, beforeMarker)(code) : nok(code);
895
- }
896
- function beforeMarker(code) {
897
- return factoryTitle(effects, titleAfter, nok, "definitionTitle", "definitionTitleMarker", "definitionTitleString")(code);
898
- }
899
- function titleAfter(code) {
900
- return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, "whitespace")(code) : titleAfterOptionalWhitespace(code);
901
- }
902
- function titleAfterOptionalWhitespace(code) {
903
- return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
904
- }
905
- }
906
- const hardBreakEscape = {
907
- name: "hardBreakEscape",
908
- tokenize: tokenizeHardBreakEscape
909
- };
910
- function tokenizeHardBreakEscape(effects, ok, nok) {
911
- return start;
912
- function start(code) {
913
- effects.enter("hardBreakEscape");
914
- effects.consume(code);
915
- return after;
916
- }
917
- function after(code) {
918
- if (markdownLineEnding(code)) {
919
- effects.exit("hardBreakEscape");
920
- return ok(code);
921
- }
922
- return nok(code);
923
- }
924
- }
925
- const headingAtx = {
926
- name: "headingAtx",
927
- resolve: resolveHeadingAtx,
928
- tokenize: tokenizeHeadingAtx
929
- };
930
- function resolveHeadingAtx(events, context) {
931
- let contentEnd = events.length - 2;
932
- let contentStart = 3;
933
- let content2;
934
- let text;
935
- if (events[contentStart][1].type === "whitespace") {
936
- contentStart += 2;
937
- }
938
- if (contentEnd - 2 > contentStart && events[contentEnd][1].type === "whitespace") {
939
- contentEnd -= 2;
940
- }
941
- if (events[contentEnd][1].type === "atxHeadingSequence" && (contentStart === contentEnd - 1 || contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === "whitespace")) {
942
- contentEnd -= contentStart + 1 === contentEnd ? 2 : 4;
943
- }
944
- if (contentEnd > contentStart) {
945
- content2 = {
946
- type: "atxHeadingText",
947
- start: events[contentStart][1].start,
948
- end: events[contentEnd][1].end
949
- };
950
- text = {
951
- type: "chunkText",
952
- start: events[contentStart][1].start,
953
- end: events[contentEnd][1].end,
954
- contentType: "text"
955
- };
956
- splice(events, contentStart, contentEnd - contentStart + 1, [["enter", content2, context], ["enter", text, context], ["exit", text, context], ["exit", content2, context]]);
957
- }
958
- return events;
959
- }
960
- function tokenizeHeadingAtx(effects, ok, nok) {
961
- let size = 0;
962
- return start;
963
- function start(code) {
964
- effects.enter("atxHeading");
965
- return before(code);
966
- }
967
- function before(code) {
968
- effects.enter("atxHeadingSequence");
969
- return sequenceOpen(code);
970
- }
971
- function sequenceOpen(code) {
972
- if (code === 35 && size++ < 6) {
973
- effects.consume(code);
974
- return sequenceOpen;
975
- }
976
- if (code === null || markdownLineEndingOrSpace(code)) {
977
- effects.exit("atxHeadingSequence");
978
- return atBreak(code);
979
- }
980
- return nok(code);
981
- }
982
- function atBreak(code) {
983
- if (code === 35) {
984
- effects.enter("atxHeadingSequence");
985
- return sequenceFurther(code);
986
- }
987
- if (code === null || markdownLineEnding(code)) {
988
- effects.exit("atxHeading");
989
- return ok(code);
990
- }
991
- if (markdownSpace(code)) {
992
- return factorySpace(effects, atBreak, "whitespace")(code);
993
- }
994
- effects.enter("atxHeadingText");
995
- return data(code);
996
- }
997
- function sequenceFurther(code) {
998
- if (code === 35) {
999
- effects.consume(code);
1000
- return sequenceFurther;
1001
- }
1002
- effects.exit("atxHeadingSequence");
1003
- return atBreak(code);
1004
- }
1005
- function data(code) {
1006
- if (code === null || code === 35 || markdownLineEndingOrSpace(code)) {
1007
- effects.exit("atxHeadingText");
1008
- return atBreak(code);
1009
- }
1010
- effects.consume(code);
1011
- return data;
1012
- }
1013
- }
1014
- const htmlFlow = {
1015
- concrete: true,
1016
- name: "htmlFlow",
1017
- resolveTo: resolveToHtmlFlow,
1018
- tokenize: tokenizeHtmlFlow
1019
- };
1020
- const blankLineBefore = {
1021
- partial: true,
1022
- tokenize: tokenizeBlankLineBefore
1023
- };
1024
- const nonLazyContinuationStart = {
1025
- partial: true,
1026
- tokenize: tokenizeNonLazyContinuationStart
1027
- };
1028
- function resolveToHtmlFlow(events) {
1029
- let index = events.length;
1030
- while (index--) {
1031
- if (events[index][0] === "enter" && events[index][1].type === "htmlFlow") {
1032
- break;
1033
- }
1034
- }
1035
- if (index > 1 && events[index - 2][1].type === "linePrefix") {
1036
- events[index][1].start = events[index - 2][1].start;
1037
- events[index + 1][1].start = events[index - 2][1].start;
1038
- events.splice(index - 2, 2);
1039
- }
1040
- return events;
1041
- }
1042
- function tokenizeHtmlFlow(effects, ok, nok) {
1043
- const self = this;
1044
- let marker;
1045
- let closingTag;
1046
- let buffer;
1047
- let index;
1048
- let markerB;
1049
- return start;
1050
- function start(code) {
1051
- return before(code);
1052
- }
1053
- function before(code) {
1054
- effects.enter("htmlFlow");
1055
- effects.enter("htmlFlowData");
1056
- effects.consume(code);
1057
- return open;
1058
- }
1059
- function open(code) {
1060
- if (code === 33) {
1061
- effects.consume(code);
1062
- return declarationOpen;
1063
- }
1064
- if (code === 47) {
1065
- effects.consume(code);
1066
- closingTag = true;
1067
- return tagCloseStart;
1068
- }
1069
- if (code === 63) {
1070
- effects.consume(code);
1071
- marker = 3;
1072
- return self.interrupt ? ok : continuationDeclarationInside;
1073
- }
1074
- if (asciiAlpha(code)) {
1075
- effects.consume(code);
1076
- buffer = String.fromCharCode(code);
1077
- return tagName;
1078
- }
1079
- return nok(code);
1080
- }
1081
- function declarationOpen(code) {
1082
- if (code === 45) {
1083
- effects.consume(code);
1084
- marker = 2;
1085
- return commentOpenInside;
1086
- }
1087
- if (code === 91) {
1088
- effects.consume(code);
1089
- marker = 5;
1090
- index = 0;
1091
- return cdataOpenInside;
1092
- }
1093
- if (asciiAlpha(code)) {
1094
- effects.consume(code);
1095
- marker = 4;
1096
- return self.interrupt ? ok : continuationDeclarationInside;
1097
- }
1098
- return nok(code);
1099
- }
1100
- function commentOpenInside(code) {
1101
- if (code === 45) {
1102
- effects.consume(code);
1103
- return self.interrupt ? ok : continuationDeclarationInside;
1104
- }
1105
- return nok(code);
1106
- }
1107
- function cdataOpenInside(code) {
1108
- const value = "CDATA[";
1109
- if (code === value.charCodeAt(index++)) {
1110
- effects.consume(code);
1111
- if (index === value.length) {
1112
- return self.interrupt ? ok : continuation;
1113
- }
1114
- return cdataOpenInside;
1115
- }
1116
- return nok(code);
1117
- }
1118
- function tagCloseStart(code) {
1119
- if (asciiAlpha(code)) {
1120
- effects.consume(code);
1121
- buffer = String.fromCharCode(code);
1122
- return tagName;
1123
- }
1124
- return nok(code);
1125
- }
1126
- function tagName(code) {
1127
- if (code === null || code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
1128
- const slash = code === 47;
1129
- const name = buffer.toLowerCase();
1130
- if (!slash && !closingTag && htmlRawNames.includes(name)) {
1131
- marker = 1;
1132
- return self.interrupt ? ok(code) : continuation(code);
1133
- }
1134
- if (htmlBlockNames.includes(buffer.toLowerCase())) {
1135
- marker = 6;
1136
- if (slash) {
1137
- effects.consume(code);
1138
- return basicSelfClosing;
1139
- }
1140
- return self.interrupt ? ok(code) : continuation(code);
1141
- }
1142
- marker = 7;
1143
- return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);
1144
- }
1145
- if (code === 45 || asciiAlphanumeric(code)) {
1146
- effects.consume(code);
1147
- buffer += String.fromCharCode(code);
1148
- return tagName;
1149
- }
1150
- return nok(code);
1151
- }
1152
- function basicSelfClosing(code) {
1153
- if (code === 62) {
1154
- effects.consume(code);
1155
- return self.interrupt ? ok : continuation;
1156
- }
1157
- return nok(code);
1158
- }
1159
- function completeClosingTagAfter(code) {
1160
- if (markdownSpace(code)) {
1161
- effects.consume(code);
1162
- return completeClosingTagAfter;
1163
- }
1164
- return completeEnd(code);
1165
- }
1166
- function completeAttributeNameBefore(code) {
1167
- if (code === 47) {
1168
- effects.consume(code);
1169
- return completeEnd;
1170
- }
1171
- if (code === 58 || code === 95 || asciiAlpha(code)) {
1172
- effects.consume(code);
1173
- return completeAttributeName;
1174
- }
1175
- if (markdownSpace(code)) {
1176
- effects.consume(code);
1177
- return completeAttributeNameBefore;
1178
- }
1179
- return completeEnd(code);
1180
- }
1181
- function completeAttributeName(code) {
1182
- if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
1183
- effects.consume(code);
1184
- return completeAttributeName;
1185
- }
1186
- return completeAttributeNameAfter(code);
1187
- }
1188
- function completeAttributeNameAfter(code) {
1189
- if (code === 61) {
1190
- effects.consume(code);
1191
- return completeAttributeValueBefore;
1192
- }
1193
- if (markdownSpace(code)) {
1194
- effects.consume(code);
1195
- return completeAttributeNameAfter;
1196
- }
1197
- return completeAttributeNameBefore(code);
1198
- }
1199
- function completeAttributeValueBefore(code) {
1200
- if (code === null || code === 60 || code === 61 || code === 62 || code === 96) {
1201
- return nok(code);
1202
- }
1203
- if (code === 34 || code === 39) {
1204
- effects.consume(code);
1205
- markerB = code;
1206
- return completeAttributeValueQuoted;
1207
- }
1208
- if (markdownSpace(code)) {
1209
- effects.consume(code);
1210
- return completeAttributeValueBefore;
1211
- }
1212
- return completeAttributeValueUnquoted(code);
1213
- }
1214
- function completeAttributeValueQuoted(code) {
1215
- if (code === markerB) {
1216
- effects.consume(code);
1217
- markerB = null;
1218
- return completeAttributeValueQuotedAfter;
1219
- }
1220
- if (code === null || markdownLineEnding(code)) {
1221
- return nok(code);
1222
- }
1223
- effects.consume(code);
1224
- return completeAttributeValueQuoted;
1225
- }
1226
- function completeAttributeValueUnquoted(code) {
1227
- if (code === null || code === 34 || code === 39 || code === 47 || code === 60 || code === 61 || code === 62 || code === 96 || markdownLineEndingOrSpace(code)) {
1228
- return completeAttributeNameAfter(code);
1229
- }
1230
- effects.consume(code);
1231
- return completeAttributeValueUnquoted;
1232
- }
1233
- function completeAttributeValueQuotedAfter(code) {
1234
- if (code === 47 || code === 62 || markdownSpace(code)) {
1235
- return completeAttributeNameBefore(code);
1236
- }
1237
- return nok(code);
1238
- }
1239
- function completeEnd(code) {
1240
- if (code === 62) {
1241
- effects.consume(code);
1242
- return completeAfter;
1243
- }
1244
- return nok(code);
1245
- }
1246
- function completeAfter(code) {
1247
- if (code === null || markdownLineEnding(code)) {
1248
- return continuation(code);
1249
- }
1250
- if (markdownSpace(code)) {
1251
- effects.consume(code);
1252
- return completeAfter;
1253
- }
1254
- return nok(code);
1255
- }
1256
- function continuation(code) {
1257
- if (code === 45 && marker === 2) {
1258
- effects.consume(code);
1259
- return continuationCommentInside;
1260
- }
1261
- if (code === 60 && marker === 1) {
1262
- effects.consume(code);
1263
- return continuationRawTagOpen;
1264
- }
1265
- if (code === 62 && marker === 4) {
1266
- effects.consume(code);
1267
- return continuationClose;
1268
- }
1269
- if (code === 63 && marker === 3) {
1270
- effects.consume(code);
1271
- return continuationDeclarationInside;
1272
- }
1273
- if (code === 93 && marker === 5) {
1274
- effects.consume(code);
1275
- return continuationCdataInside;
1276
- }
1277
- if (markdownLineEnding(code) && (marker === 6 || marker === 7)) {
1278
- effects.exit("htmlFlowData");
1279
- return effects.check(blankLineBefore, continuationAfter, continuationStart)(code);
1280
- }
1281
- if (code === null || markdownLineEnding(code)) {
1282
- effects.exit("htmlFlowData");
1283
- return continuationStart(code);
1284
- }
1285
- effects.consume(code);
1286
- return continuation;
1287
- }
1288
- function continuationStart(code) {
1289
- return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code);
1290
- }
1291
- function continuationStartNonLazy(code) {
1292
- effects.enter("lineEnding");
1293
- effects.consume(code);
1294
- effects.exit("lineEnding");
1295
- return continuationBefore;
1296
- }
1297
- function continuationBefore(code) {
1298
- if (code === null || markdownLineEnding(code)) {
1299
- return continuationStart(code);
1300
- }
1301
- effects.enter("htmlFlowData");
1302
- return continuation(code);
1303
- }
1304
- function continuationCommentInside(code) {
1305
- if (code === 45) {
1306
- effects.consume(code);
1307
- return continuationDeclarationInside;
1308
- }
1309
- return continuation(code);
1310
- }
1311
- function continuationRawTagOpen(code) {
1312
- if (code === 47) {
1313
- effects.consume(code);
1314
- buffer = "";
1315
- return continuationRawEndTag;
1316
- }
1317
- return continuation(code);
1318
- }
1319
- function continuationRawEndTag(code) {
1320
- if (code === 62) {
1321
- const name = buffer.toLowerCase();
1322
- if (htmlRawNames.includes(name)) {
1323
- effects.consume(code);
1324
- return continuationClose;
1325
- }
1326
- return continuation(code);
1327
- }
1328
- if (asciiAlpha(code) && buffer.length < 8) {
1329
- effects.consume(code);
1330
- buffer += String.fromCharCode(code);
1331
- return continuationRawEndTag;
1332
- }
1333
- return continuation(code);
1334
- }
1335
- function continuationCdataInside(code) {
1336
- if (code === 93) {
1337
- effects.consume(code);
1338
- return continuationDeclarationInside;
1339
- }
1340
- return continuation(code);
1341
- }
1342
- function continuationDeclarationInside(code) {
1343
- if (code === 62) {
1344
- effects.consume(code);
1345
- return continuationClose;
1346
- }
1347
- if (code === 45 && marker === 2) {
1348
- effects.consume(code);
1349
- return continuationDeclarationInside;
1350
- }
1351
- return continuation(code);
1352
- }
1353
- function continuationClose(code) {
1354
- if (code === null || markdownLineEnding(code)) {
1355
- effects.exit("htmlFlowData");
1356
- return continuationAfter(code);
1357
- }
1358
- effects.consume(code);
1359
- return continuationClose;
1360
- }
1361
- function continuationAfter(code) {
1362
- effects.exit("htmlFlow");
1363
- return ok(code);
1364
- }
1365
- }
1366
- function tokenizeNonLazyContinuationStart(effects, ok, nok) {
1367
- const self = this;
1368
- return start;
1369
- function start(code) {
1370
- if (markdownLineEnding(code)) {
1371
- effects.enter("lineEnding");
1372
- effects.consume(code);
1373
- effects.exit("lineEnding");
1374
- return after;
1375
- }
1376
- return nok(code);
1377
- }
1378
- function after(code) {
1379
- return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
1380
- }
1381
- }
1382
- function tokenizeBlankLineBefore(effects, ok, nok) {
1383
- return start;
1384
- function start(code) {
1385
- effects.enter("lineEnding");
1386
- effects.consume(code);
1387
- effects.exit("lineEnding");
1388
- return effects.attempt(blankLine, ok, nok);
1389
- }
1390
- }
1391
- const htmlText = {
1392
- name: "htmlText",
1393
- tokenize: tokenizeHtmlText
1394
- };
1395
- function tokenizeHtmlText(effects, ok, nok) {
1396
- const self = this;
1397
- let marker;
1398
- let index;
1399
- let returnState;
1400
- return start;
1401
- function start(code) {
1402
- effects.enter("htmlText");
1403
- effects.enter("htmlTextData");
1404
- effects.consume(code);
1405
- return open;
1406
- }
1407
- function open(code) {
1408
- if (code === 33) {
1409
- effects.consume(code);
1410
- return declarationOpen;
1411
- }
1412
- if (code === 47) {
1413
- effects.consume(code);
1414
- return tagCloseStart;
1415
- }
1416
- if (code === 63) {
1417
- effects.consume(code);
1418
- return instruction;
1419
- }
1420
- if (asciiAlpha(code)) {
1421
- effects.consume(code);
1422
- return tagOpen;
1423
- }
1424
- return nok(code);
1425
- }
1426
- function declarationOpen(code) {
1427
- if (code === 45) {
1428
- effects.consume(code);
1429
- return commentOpenInside;
1430
- }
1431
- if (code === 91) {
1432
- effects.consume(code);
1433
- index = 0;
1434
- return cdataOpenInside;
1435
- }
1436
- if (asciiAlpha(code)) {
1437
- effects.consume(code);
1438
- return declaration;
1439
- }
1440
- return nok(code);
1441
- }
1442
- function commentOpenInside(code) {
1443
- if (code === 45) {
1444
- effects.consume(code);
1445
- return commentEnd;
1446
- }
1447
- return nok(code);
1448
- }
1449
- function comment(code) {
1450
- if (code === null) {
1451
- return nok(code);
1452
- }
1453
- if (code === 45) {
1454
- effects.consume(code);
1455
- return commentClose;
1456
- }
1457
- if (markdownLineEnding(code)) {
1458
- returnState = comment;
1459
- return lineEndingBefore(code);
1460
- }
1461
- effects.consume(code);
1462
- return comment;
1463
- }
1464
- function commentClose(code) {
1465
- if (code === 45) {
1466
- effects.consume(code);
1467
- return commentEnd;
1468
- }
1469
- return comment(code);
1470
- }
1471
- function commentEnd(code) {
1472
- return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);
1473
- }
1474
- function cdataOpenInside(code) {
1475
- const value = "CDATA[";
1476
- if (code === value.charCodeAt(index++)) {
1477
- effects.consume(code);
1478
- return index === value.length ? cdata : cdataOpenInside;
1479
- }
1480
- return nok(code);
1481
- }
1482
- function cdata(code) {
1483
- if (code === null) {
1484
- return nok(code);
1485
- }
1486
- if (code === 93) {
1487
- effects.consume(code);
1488
- return cdataClose;
1489
- }
1490
- if (markdownLineEnding(code)) {
1491
- returnState = cdata;
1492
- return lineEndingBefore(code);
1493
- }
1494
- effects.consume(code);
1495
- return cdata;
1496
- }
1497
- function cdataClose(code) {
1498
- if (code === 93) {
1499
- effects.consume(code);
1500
- return cdataEnd;
1501
- }
1502
- return cdata(code);
1503
- }
1504
- function cdataEnd(code) {
1505
- if (code === 62) {
1506
- return end(code);
1507
- }
1508
- if (code === 93) {
1509
- effects.consume(code);
1510
- return cdataEnd;
1511
- }
1512
- return cdata(code);
1513
- }
1514
- function declaration(code) {
1515
- if (code === null || code === 62) {
1516
- return end(code);
1517
- }
1518
- if (markdownLineEnding(code)) {
1519
- returnState = declaration;
1520
- return lineEndingBefore(code);
1521
- }
1522
- effects.consume(code);
1523
- return declaration;
1524
- }
1525
- function instruction(code) {
1526
- if (code === null) {
1527
- return nok(code);
1528
- }
1529
- if (code === 63) {
1530
- effects.consume(code);
1531
- return instructionClose;
1532
- }
1533
- if (markdownLineEnding(code)) {
1534
- returnState = instruction;
1535
- return lineEndingBefore(code);
1536
- }
1537
- effects.consume(code);
1538
- return instruction;
1539
- }
1540
- function instructionClose(code) {
1541
- return code === 62 ? end(code) : instruction(code);
1542
- }
1543
- function tagCloseStart(code) {
1544
- if (asciiAlpha(code)) {
1545
- effects.consume(code);
1546
- return tagClose;
1547
- }
1548
- return nok(code);
1549
- }
1550
- function tagClose(code) {
1551
- if (code === 45 || asciiAlphanumeric(code)) {
1552
- effects.consume(code);
1553
- return tagClose;
1554
- }
1555
- return tagCloseBetween(code);
1556
- }
1557
- function tagCloseBetween(code) {
1558
- if (markdownLineEnding(code)) {
1559
- returnState = tagCloseBetween;
1560
- return lineEndingBefore(code);
1561
- }
1562
- if (markdownSpace(code)) {
1563
- effects.consume(code);
1564
- return tagCloseBetween;
1565
- }
1566
- return end(code);
1567
- }
1568
- function tagOpen(code) {
1569
- if (code === 45 || asciiAlphanumeric(code)) {
1570
- effects.consume(code);
1571
- return tagOpen;
1572
- }
1573
- if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
1574
- return tagOpenBetween(code);
1575
- }
1576
- return nok(code);
1577
- }
1578
- function tagOpenBetween(code) {
1579
- if (code === 47) {
1580
- effects.consume(code);
1581
- return end;
1582
- }
1583
- if (code === 58 || code === 95 || asciiAlpha(code)) {
1584
- effects.consume(code);
1585
- return tagOpenAttributeName;
1586
- }
1587
- if (markdownLineEnding(code)) {
1588
- returnState = tagOpenBetween;
1589
- return lineEndingBefore(code);
1590
- }
1591
- if (markdownSpace(code)) {
1592
- effects.consume(code);
1593
- return tagOpenBetween;
1594
- }
1595
- return end(code);
1596
- }
1597
- function tagOpenAttributeName(code) {
1598
- if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
1599
- effects.consume(code);
1600
- return tagOpenAttributeName;
1601
- }
1602
- return tagOpenAttributeNameAfter(code);
1603
- }
1604
- function tagOpenAttributeNameAfter(code) {
1605
- if (code === 61) {
1606
- effects.consume(code);
1607
- return tagOpenAttributeValueBefore;
1608
- }
1609
- if (markdownLineEnding(code)) {
1610
- returnState = tagOpenAttributeNameAfter;
1611
- return lineEndingBefore(code);
1612
- }
1613
- if (markdownSpace(code)) {
1614
- effects.consume(code);
1615
- return tagOpenAttributeNameAfter;
1616
- }
1617
- return tagOpenBetween(code);
1618
- }
1619
- function tagOpenAttributeValueBefore(code) {
1620
- if (code === null || code === 60 || code === 61 || code === 62 || code === 96) {
1621
- return nok(code);
1622
- }
1623
- if (code === 34 || code === 39) {
1624
- effects.consume(code);
1625
- marker = code;
1626
- return tagOpenAttributeValueQuoted;
1627
- }
1628
- if (markdownLineEnding(code)) {
1629
- returnState = tagOpenAttributeValueBefore;
1630
- return lineEndingBefore(code);
1631
- }
1632
- if (markdownSpace(code)) {
1633
- effects.consume(code);
1634
- return tagOpenAttributeValueBefore;
1635
- }
1636
- effects.consume(code);
1637
- return tagOpenAttributeValueUnquoted;
1638
- }
1639
- function tagOpenAttributeValueQuoted(code) {
1640
- if (code === marker) {
1641
- effects.consume(code);
1642
- marker = void 0;
1643
- return tagOpenAttributeValueQuotedAfter;
1644
- }
1645
- if (code === null) {
1646
- return nok(code);
1647
- }
1648
- if (markdownLineEnding(code)) {
1649
- returnState = tagOpenAttributeValueQuoted;
1650
- return lineEndingBefore(code);
1651
- }
1652
- effects.consume(code);
1653
- return tagOpenAttributeValueQuoted;
1654
- }
1655
- function tagOpenAttributeValueUnquoted(code) {
1656
- if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) {
1657
- return nok(code);
1658
- }
1659
- if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
1660
- return tagOpenBetween(code);
1661
- }
1662
- effects.consume(code);
1663
- return tagOpenAttributeValueUnquoted;
1664
- }
1665
- function tagOpenAttributeValueQuotedAfter(code) {
1666
- if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
1667
- return tagOpenBetween(code);
1668
- }
1669
- return nok(code);
1670
- }
1671
- function end(code) {
1672
- if (code === 62) {
1673
- effects.consume(code);
1674
- effects.exit("htmlTextData");
1675
- effects.exit("htmlText");
1676
- return ok;
1677
- }
1678
- return nok(code);
1679
- }
1680
- function lineEndingBefore(code) {
1681
- effects.exit("htmlTextData");
1682
- effects.enter("lineEnding");
1683
- effects.consume(code);
1684
- effects.exit("lineEnding");
1685
- return lineEndingAfter;
1686
- }
1687
- function lineEndingAfter(code) {
1688
- return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : lineEndingAfterPrefix(code);
1689
- }
1690
- function lineEndingAfterPrefix(code) {
1691
- effects.enter("htmlTextData");
1692
- return returnState(code);
1693
- }
1694
- }
1695
- const labelEnd = {
1696
- name: "labelEnd",
1697
- resolveAll: resolveAllLabelEnd,
1698
- resolveTo: resolveToLabelEnd,
1699
- tokenize: tokenizeLabelEnd
1700
- };
1701
- const resourceConstruct = {
1702
- tokenize: tokenizeResource
1703
- };
1704
- const referenceFullConstruct = {
1705
- tokenize: tokenizeReferenceFull
1706
- };
1707
- const referenceCollapsedConstruct = {
1708
- tokenize: tokenizeReferenceCollapsed
1709
- };
1710
- function resolveAllLabelEnd(events) {
1711
- let index = -1;
1712
- const newEvents = [];
1713
- while (++index < events.length) {
1714
- const token = events[index][1];
1715
- newEvents.push(events[index]);
1716
- if (token.type === "labelImage" || token.type === "labelLink" || token.type === "labelEnd") {
1717
- const offset = token.type === "labelImage" ? 4 : 2;
1718
- token.type = "data";
1719
- index += offset;
1720
- }
1721
- }
1722
- if (events.length !== newEvents.length) {
1723
- splice(events, 0, events.length, newEvents);
1724
- }
1725
- return events;
1726
- }
1727
- function resolveToLabelEnd(events, context) {
1728
- let index = events.length;
1729
- let offset = 0;
1730
- let token;
1731
- let open;
1732
- let close;
1733
- let media;
1734
- while (index--) {
1735
- token = events[index][1];
1736
- if (open) {
1737
- if (token.type === "link" || token.type === "labelLink" && token._inactive) {
1738
- break;
1739
- }
1740
- if (events[index][0] === "enter" && token.type === "labelLink") {
1741
- token._inactive = true;
1742
- }
1743
- } else if (close) {
1744
- if (events[index][0] === "enter" && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced) {
1745
- open = index;
1746
- if (token.type !== "labelLink") {
1747
- offset = 2;
1748
- break;
1749
- }
1750
- }
1751
- } else if (token.type === "labelEnd") {
1752
- close = index;
1753
- }
1754
- }
1755
- const group = {
1756
- type: events[open][1].type === "labelLink" ? "link" : "image",
1757
- start: {
1758
- ...events[open][1].start
1759
- },
1760
- end: {
1761
- ...events[events.length - 1][1].end
1762
- }
1763
- };
1764
- const label = {
1765
- type: "label",
1766
- start: {
1767
- ...events[open][1].start
1768
- },
1769
- end: {
1770
- ...events[close][1].end
1771
- }
1772
- };
1773
- const text = {
1774
- type: "labelText",
1775
- start: {
1776
- ...events[open + offset + 2][1].end
1777
- },
1778
- end: {
1779
- ...events[close - 2][1].start
1780
- }
1781
- };
1782
- media = [["enter", group, context], ["enter", label, context]];
1783
- media = push(media, events.slice(open + 1, open + offset + 3));
1784
- media = push(media, [["enter", text, context]]);
1785
- media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context));
1786
- media = push(media, [["exit", text, context], events[close - 2], events[close - 1], ["exit", label, context]]);
1787
- media = push(media, events.slice(close + 1));
1788
- media = push(media, [["exit", group, context]]);
1789
- splice(events, open, events.length, media);
1790
- return events;
1791
- }
1792
- function tokenizeLabelEnd(effects, ok, nok) {
1793
- const self = this;
1794
- let index = self.events.length;
1795
- let labelStart;
1796
- let defined;
1797
- while (index--) {
1798
- if ((self.events[index][1].type === "labelImage" || self.events[index][1].type === "labelLink") && !self.events[index][1]._balanced) {
1799
- labelStart = self.events[index][1];
1800
- break;
1801
- }
1802
- }
1803
- return start;
1804
- function start(code) {
1805
- if (!labelStart) {
1806
- return nok(code);
1807
- }
1808
- if (labelStart._inactive) {
1809
- return labelEndNok(code);
1810
- }
1811
- defined = self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize({
1812
- start: labelStart.end,
1813
- end: self.now()
1814
- })));
1815
- effects.enter("labelEnd");
1816
- effects.enter("labelMarker");
1817
- effects.consume(code);
1818
- effects.exit("labelMarker");
1819
- effects.exit("labelEnd");
1820
- return after;
1821
- }
1822
- function after(code) {
1823
- if (code === 40) {
1824
- return effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code);
1825
- }
1826
- if (code === 91) {
1827
- return effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code);
1828
- }
1829
- return defined ? labelEndOk(code) : labelEndNok(code);
1830
- }
1831
- function referenceNotFull(code) {
1832
- return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code);
1833
- }
1834
- function labelEndOk(code) {
1835
- return ok(code);
1836
- }
1837
- function labelEndNok(code) {
1838
- labelStart._balanced = true;
1839
- return nok(code);
1840
- }
1841
- }
1842
- function tokenizeResource(effects, ok, nok) {
1843
- return resourceStart;
1844
- function resourceStart(code) {
1845
- effects.enter("resource");
1846
- effects.enter("resourceMarker");
1847
- effects.consume(code);
1848
- effects.exit("resourceMarker");
1849
- return resourceBefore;
1850
- }
1851
- function resourceBefore(code) {
1852
- return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code);
1853
- }
1854
- function resourceOpen(code) {
1855
- if (code === 41) {
1856
- return resourceEnd(code);
1857
- }
1858
- return factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, "resourceDestination", "resourceDestinationLiteral", "resourceDestinationLiteralMarker", "resourceDestinationRaw", "resourceDestinationString", 32)(code);
1859
- }
1860
- function resourceDestinationAfter(code) {
1861
- return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code);
1862
- }
1863
- function resourceDestinationMissing(code) {
1864
- return nok(code);
1865
- }
1866
- function resourceBetween(code) {
1867
- if (code === 34 || code === 39 || code === 40) {
1868
- return factoryTitle(effects, resourceTitleAfter, nok, "resourceTitle", "resourceTitleMarker", "resourceTitleString")(code);
1869
- }
1870
- return resourceEnd(code);
1871
- }
1872
- function resourceTitleAfter(code) {
1873
- return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code);
1874
- }
1875
- function resourceEnd(code) {
1876
- if (code === 41) {
1877
- effects.enter("resourceMarker");
1878
- effects.consume(code);
1879
- effects.exit("resourceMarker");
1880
- effects.exit("resource");
1881
- return ok;
1882
- }
1883
- return nok(code);
1884
- }
1885
- }
1886
- function tokenizeReferenceFull(effects, ok, nok) {
1887
- const self = this;
1888
- return referenceFull;
1889
- function referenceFull(code) {
1890
- return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, "reference", "referenceMarker", "referenceString")(code);
1891
- }
1892
- function referenceFullAfter(code) {
1893
- return self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok(code) : nok(code);
1894
- }
1895
- function referenceFullMissing(code) {
1896
- return nok(code);
1897
- }
1898
- }
1899
- function tokenizeReferenceCollapsed(effects, ok, nok) {
1900
- return referenceCollapsedStart;
1901
- function referenceCollapsedStart(code) {
1902
- effects.enter("reference");
1903
- effects.enter("referenceMarker");
1904
- effects.consume(code);
1905
- effects.exit("referenceMarker");
1906
- return referenceCollapsedOpen;
1907
- }
1908
- function referenceCollapsedOpen(code) {
1909
- if (code === 93) {
1910
- effects.enter("referenceMarker");
1911
- effects.consume(code);
1912
- effects.exit("referenceMarker");
1913
- effects.exit("reference");
1914
- return ok;
1915
- }
1916
- return nok(code);
1917
- }
1918
- }
1919
- const labelStartImage = {
1920
- name: "labelStartImage",
1921
- resolveAll: labelEnd.resolveAll,
1922
- tokenize: tokenizeLabelStartImage
1923
- };
1924
- function tokenizeLabelStartImage(effects, ok, nok) {
1925
- const self = this;
1926
- return start;
1927
- function start(code) {
1928
- effects.enter("labelImage");
1929
- effects.enter("labelImageMarker");
1930
- effects.consume(code);
1931
- effects.exit("labelImageMarker");
1932
- return open;
1933
- }
1934
- function open(code) {
1935
- if (code === 91) {
1936
- effects.enter("labelMarker");
1937
- effects.consume(code);
1938
- effects.exit("labelMarker");
1939
- effects.exit("labelImage");
1940
- return after;
1941
- }
1942
- return nok(code);
1943
- }
1944
- function after(code) {
1945
- return code === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok(code);
1946
- }
1947
- }
1948
- const labelStartLink = {
1949
- name: "labelStartLink",
1950
- resolveAll: labelEnd.resolveAll,
1951
- tokenize: tokenizeLabelStartLink
1952
- };
1953
- function tokenizeLabelStartLink(effects, ok, nok) {
1954
- const self = this;
1955
- return start;
1956
- function start(code) {
1957
- effects.enter("labelLink");
1958
- effects.enter("labelMarker");
1959
- effects.consume(code);
1960
- effects.exit("labelMarker");
1961
- effects.exit("labelLink");
1962
- return after;
1963
- }
1964
- function after(code) {
1965
- return code === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok(code);
1966
- }
1967
- }
1968
- const lineEnding = {
1969
- name: "lineEnding",
1970
- tokenize: tokenizeLineEnding
1971
- };
1972
- function tokenizeLineEnding(effects, ok) {
1973
- return start;
1974
- function start(code) {
1975
- effects.enter("lineEnding");
1976
- effects.consume(code);
1977
- effects.exit("lineEnding");
1978
- return factorySpace(effects, ok, "linePrefix");
1979
- }
1980
- }
1981
- const thematicBreak = {
1982
- name: "thematicBreak",
1983
- tokenize: tokenizeThematicBreak
1984
- };
1985
- function tokenizeThematicBreak(effects, ok, nok) {
1986
- let size = 0;
1987
- let marker;
1988
- return start;
1989
- function start(code) {
1990
- effects.enter("thematicBreak");
1991
- return before(code);
1992
- }
1993
- function before(code) {
1994
- marker = code;
1995
- return atBreak(code);
1996
- }
1997
- function atBreak(code) {
1998
- if (code === marker) {
1999
- effects.enter("thematicBreakSequence");
2000
- return sequence(code);
2001
- }
2002
- if (size >= 3 && (code === null || markdownLineEnding(code))) {
2003
- effects.exit("thematicBreak");
2004
- return ok(code);
2005
- }
2006
- return nok(code);
2007
- }
2008
- function sequence(code) {
2009
- if (code === marker) {
2010
- effects.consume(code);
2011
- size++;
2012
- return sequence;
2013
- }
2014
- effects.exit("thematicBreakSequence");
2015
- return markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code);
2016
- }
2017
- }
2018
- const list = {
2019
- continuation: {
2020
- tokenize: tokenizeListContinuation
2021
- },
2022
- exit: tokenizeListEnd,
2023
- name: "list",
2024
- tokenize: tokenizeListStart
2025
- };
2026
- const listItemPrefixWhitespaceConstruct = {
2027
- partial: true,
2028
- tokenize: tokenizeListItemPrefixWhitespace
2029
- };
2030
- const indentConstruct = {
2031
- partial: true,
2032
- tokenize: tokenizeIndent
2033
- };
2034
- function tokenizeListStart(effects, ok, nok) {
2035
- const self = this;
2036
- const tail = self.events[self.events.length - 1];
2037
- let initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
2038
- let size = 0;
2039
- return start;
2040
- function start(code) {
2041
- const kind = self.containerState.type || (code === 42 || code === 43 || code === 45 ? "listUnordered" : "listOrdered");
2042
- if (kind === "listUnordered" ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) {
2043
- if (!self.containerState.type) {
2044
- self.containerState.type = kind;
2045
- effects.enter(kind, {
2046
- _container: true
2047
- });
2048
- }
2049
- if (kind === "listUnordered") {
2050
- effects.enter("listItemPrefix");
2051
- return code === 42 || code === 45 ? effects.check(thematicBreak, nok, atMarker)(code) : atMarker(code);
2052
- }
2053
- if (!self.interrupt || code === 49) {
2054
- effects.enter("listItemPrefix");
2055
- effects.enter("listItemValue");
2056
- return inside(code);
2057
- }
2058
- }
2059
- return nok(code);
2060
- }
2061
- function inside(code) {
2062
- if (asciiDigit(code) && ++size < 10) {
2063
- effects.consume(code);
2064
- return inside;
2065
- }
2066
- if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === 41 || code === 46)) {
2067
- effects.exit("listItemValue");
2068
- return atMarker(code);
2069
- }
2070
- return nok(code);
2071
- }
2072
- function atMarker(code) {
2073
- effects.enter("listItemMarker");
2074
- effects.consume(code);
2075
- effects.exit("listItemMarker");
2076
- self.containerState.marker = self.containerState.marker || code;
2077
- return effects.check(
2078
- blankLine,
2079
- // Can’t be empty when interrupting.
2080
- self.interrupt ? nok : onBlank,
2081
- effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix)
2082
- );
2083
- }
2084
- function onBlank(code) {
2085
- self.containerState.initialBlankLine = true;
2086
- initialSize++;
2087
- return endOfPrefix(code);
2088
- }
2089
- function otherPrefix(code) {
2090
- if (markdownSpace(code)) {
2091
- effects.enter("listItemPrefixWhitespace");
2092
- effects.consume(code);
2093
- effects.exit("listItemPrefixWhitespace");
2094
- return endOfPrefix;
2095
- }
2096
- return nok(code);
2097
- }
2098
- function endOfPrefix(code) {
2099
- self.containerState.size = initialSize + self.sliceSerialize(effects.exit("listItemPrefix"), true).length;
2100
- return ok(code);
2101
- }
2102
- }
2103
- function tokenizeListContinuation(effects, ok, nok) {
2104
- const self = this;
2105
- self.containerState._closeFlow = void 0;
2106
- return effects.check(blankLine, onBlank, notBlank);
2107
- function onBlank(code) {
2108
- self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine;
2109
- return factorySpace(effects, ok, "listItemIndent", self.containerState.size + 1)(code);
2110
- }
2111
- function notBlank(code) {
2112
- if (self.containerState.furtherBlankLines || !markdownSpace(code)) {
2113
- self.containerState.furtherBlankLines = void 0;
2114
- self.containerState.initialBlankLine = void 0;
2115
- return notInCurrentItem(code);
2116
- }
2117
- self.containerState.furtherBlankLines = void 0;
2118
- self.containerState.initialBlankLine = void 0;
2119
- return effects.attempt(indentConstruct, ok, notInCurrentItem)(code);
2120
- }
2121
- function notInCurrentItem(code) {
2122
- self.containerState._closeFlow = true;
2123
- self.interrupt = void 0;
2124
- return factorySpace(effects, effects.attempt(list, ok, nok), "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
2125
- }
2126
- }
2127
- function tokenizeIndent(effects, ok, nok) {
2128
- const self = this;
2129
- return factorySpace(effects, afterPrefix, "listItemIndent", self.containerState.size + 1);
2130
- function afterPrefix(code) {
2131
- const tail = self.events[self.events.length - 1];
2132
- return tail && tail[1].type === "listItemIndent" && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok(code) : nok(code);
2133
- }
2134
- }
2135
- function tokenizeListEnd(effects) {
2136
- effects.exit(this.containerState.type);
2137
- }
2138
- function tokenizeListItemPrefixWhitespace(effects, ok, nok) {
2139
- const self = this;
2140
- return factorySpace(effects, afterPrefix, "listItemPrefixWhitespace", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4 + 1);
2141
- function afterPrefix(code) {
2142
- const tail = self.events[self.events.length - 1];
2143
- return !markdownSpace(code) && tail && tail[1].type === "listItemPrefixWhitespace" ? ok(code) : nok(code);
2144
- }
2145
- }
2146
- const setextUnderline = {
2147
- name: "setextUnderline",
2148
- resolveTo: resolveToSetextUnderline,
2149
- tokenize: tokenizeSetextUnderline
2150
- };
2151
- function resolveToSetextUnderline(events, context) {
2152
- let index = events.length;
2153
- let content2;
2154
- let text;
2155
- let definition2;
2156
- while (index--) {
2157
- if (events[index][0] === "enter") {
2158
- if (events[index][1].type === "content") {
2159
- content2 = index;
2160
- break;
2161
- }
2162
- if (events[index][1].type === "paragraph") {
2163
- text = index;
2164
- }
2165
- } else {
2166
- if (events[index][1].type === "content") {
2167
- events.splice(index, 1);
2168
- }
2169
- if (!definition2 && events[index][1].type === "definition") {
2170
- definition2 = index;
2171
- }
2172
- }
2173
- }
2174
- const heading = {
2175
- type: "setextHeading",
2176
- start: {
2177
- ...events[content2][1].start
2178
- },
2179
- end: {
2180
- ...events[events.length - 1][1].end
2181
- }
2182
- };
2183
- events[text][1].type = "setextHeadingText";
2184
- if (definition2) {
2185
- events.splice(text, 0, ["enter", heading, context]);
2186
- events.splice(definition2 + 1, 0, ["exit", events[content2][1], context]);
2187
- events[content2][1].end = {
2188
- ...events[definition2][1].end
2189
- };
2190
- } else {
2191
- events[content2][1] = heading;
2192
- }
2193
- events.push(["exit", heading, context]);
2194
- return events;
2195
- }
2196
- function tokenizeSetextUnderline(effects, ok, nok) {
2197
- const self = this;
2198
- let marker;
2199
- return start;
2200
- function start(code) {
2201
- let index = self.events.length;
2202
- let paragraph;
2203
- while (index--) {
2204
- if (self.events[index][1].type !== "lineEnding" && self.events[index][1].type !== "linePrefix" && self.events[index][1].type !== "content") {
2205
- paragraph = self.events[index][1].type === "paragraph";
2206
- break;
2207
- }
2208
- }
2209
- if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) {
2210
- effects.enter("setextHeadingLine");
2211
- marker = code;
2212
- return before(code);
2213
- }
2214
- return nok(code);
2215
- }
2216
- function before(code) {
2217
- effects.enter("setextHeadingLineSequence");
2218
- return inside(code);
2219
- }
2220
- function inside(code) {
2221
- if (code === marker) {
2222
- effects.consume(code);
2223
- return inside;
2224
- }
2225
- effects.exit("setextHeadingLineSequence");
2226
- return markdownSpace(code) ? factorySpace(effects, after, "lineSuffix")(code) : after(code);
2227
- }
2228
- function after(code) {
2229
- if (code === null || markdownLineEnding(code)) {
2230
- effects.exit("setextHeadingLine");
2231
- return ok(code);
2232
- }
2233
- return nok(code);
2234
- }
2235
- }
2236
- export {
2237
- blockQuote as a,
2238
- blankLine as b,
2239
- content as c,
2240
- definition as d,
2241
- codeFenced as e,
2242
- headingAtx as f,
2243
- codeIndented as g,
2244
- htmlFlow as h,
2245
- attention as i,
2246
- characterEscape as j,
2247
- characterReference as k,
2248
- list as l,
2249
- codeText as m,
2250
- labelEnd as n,
2251
- hardBreakEscape as o,
2252
- labelStartLink as p,
2253
- autolink as q,
2254
- htmlText as r,
2255
- setextUnderline as s,
2256
- thematicBreak as t,
2257
- labelStartImage as u,
2258
- lineEnding as v
2259
- };