@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,33 @@
1
+ /**
2
+ * @import {
3
+ * Construct,
4
+ * State,
5
+ * TokenizeContext,
6
+ * Tokenizer
7
+ * } from 'micromark-util-types'
8
+ */
9
+
10
+ import { factorySpace } from 'micromark-factory-space';
11
+ import { markdownLineEnding } from 'micromark-util-character';
12
+ /** @type {Construct} */
13
+ export const lineEnding = {
14
+ name: 'lineEnding',
15
+ tokenize: tokenizeLineEnding
16
+ };
17
+
18
+ /**
19
+ * @this {TokenizeContext}
20
+ * Context.
21
+ * @type {Tokenizer}
22
+ */
23
+ function tokenizeLineEnding(effects, ok) {
24
+ return start;
25
+
26
+ /** @type {State} */
27
+ function start(code) {
28
+ effects.enter("lineEnding");
29
+ effects.consume(code);
30
+ effects.exit("lineEnding");
31
+ return factorySpace(effects, ok, "linePrefix");
32
+ }
33
+ }
@@ -0,0 +1,213 @@
1
+ /**
2
+ * @import {
3
+ * Code,
4
+ * Construct,
5
+ * Exiter,
6
+ * State,
7
+ * TokenizeContext,
8
+ * Tokenizer
9
+ * } from 'micromark-util-types'
10
+ */
11
+
12
+ import { factorySpace } from 'micromark-factory-space';
13
+ import { asciiDigit, markdownSpace } from 'micromark-util-character';
14
+ import { blankLine } from './blank-line.js';
15
+ import { thematicBreak } from './thematic-break.js';
16
+
17
+ /** @type {Construct} */
18
+ export const list = {
19
+ continuation: {
20
+ tokenize: tokenizeListContinuation
21
+ },
22
+ exit: tokenizeListEnd,
23
+ name: 'list',
24
+ tokenize: tokenizeListStart
25
+ };
26
+
27
+ /** @type {Construct} */
28
+ const listItemPrefixWhitespaceConstruct = {
29
+ partial: true,
30
+ tokenize: tokenizeListItemPrefixWhitespace
31
+ };
32
+
33
+ /** @type {Construct} */
34
+ const indentConstruct = {
35
+ partial: true,
36
+ tokenize: tokenizeIndent
37
+ };
38
+
39
+ // To do: `markdown-rs` parses list items on their own and later stitches them
40
+ // together.
41
+
42
+ /**
43
+ * @this {TokenizeContext}
44
+ * Context.
45
+ * @type {Tokenizer}
46
+ */
47
+ function tokenizeListStart(effects, ok, nok) {
48
+ const self = this;
49
+ const tail = self.events[self.events.length - 1];
50
+ let initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
51
+ let size = 0;
52
+ return start;
53
+
54
+ /** @type {State} */
55
+ function start(code) {
56
+ const kind = self.containerState.type || (code === 42 || code === 43 || code === 45 ? "listUnordered" : "listOrdered");
57
+ if (kind === "listUnordered" ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) {
58
+ if (!self.containerState.type) {
59
+ self.containerState.type = kind;
60
+ effects.enter(kind, {
61
+ _container: true
62
+ });
63
+ }
64
+ if (kind === "listUnordered") {
65
+ effects.enter("listItemPrefix");
66
+ return code === 42 || code === 45 ? effects.check(thematicBreak, nok, atMarker)(code) : atMarker(code);
67
+ }
68
+ if (!self.interrupt || code === 49) {
69
+ effects.enter("listItemPrefix");
70
+ effects.enter("listItemValue");
71
+ return inside(code);
72
+ }
73
+ }
74
+ return nok(code);
75
+ }
76
+
77
+ /** @type {State} */
78
+ function inside(code) {
79
+ if (asciiDigit(code) && ++size < 10) {
80
+ effects.consume(code);
81
+ return inside;
82
+ }
83
+ if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === 41 || code === 46)) {
84
+ effects.exit("listItemValue");
85
+ return atMarker(code);
86
+ }
87
+ return nok(code);
88
+ }
89
+
90
+ /**
91
+ * @type {State}
92
+ **/
93
+ function atMarker(code) {
94
+ effects.enter("listItemMarker");
95
+ effects.consume(code);
96
+ effects.exit("listItemMarker");
97
+ self.containerState.marker = self.containerState.marker || code;
98
+ return effects.check(blankLine,
99
+ // Can’t be empty when interrupting.
100
+ self.interrupt ? nok : onBlank, effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix));
101
+ }
102
+
103
+ /** @type {State} */
104
+ function onBlank(code) {
105
+ self.containerState.initialBlankLine = true;
106
+ initialSize++;
107
+ return endOfPrefix(code);
108
+ }
109
+
110
+ /** @type {State} */
111
+ function otherPrefix(code) {
112
+ if (markdownSpace(code)) {
113
+ effects.enter("listItemPrefixWhitespace");
114
+ effects.consume(code);
115
+ effects.exit("listItemPrefixWhitespace");
116
+ return endOfPrefix;
117
+ }
118
+ return nok(code);
119
+ }
120
+
121
+ /** @type {State} */
122
+ function endOfPrefix(code) {
123
+ self.containerState.size = initialSize + self.sliceSerialize(effects.exit("listItemPrefix"), true).length;
124
+ return ok(code);
125
+ }
126
+ }
127
+
128
+ /**
129
+ * @this {TokenizeContext}
130
+ * Context.
131
+ * @type {Tokenizer}
132
+ */
133
+ function tokenizeListContinuation(effects, ok, nok) {
134
+ const self = this;
135
+ self.containerState._closeFlow = undefined;
136
+ return effects.check(blankLine, onBlank, notBlank);
137
+
138
+ /** @type {State} */
139
+ function onBlank(code) {
140
+ self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine;
141
+
142
+ // We have a blank line.
143
+ // Still, try to consume at most the items size.
144
+ return factorySpace(effects, ok, "listItemIndent", self.containerState.size + 1)(code);
145
+ }
146
+
147
+ /** @type {State} */
148
+ function notBlank(code) {
149
+ if (self.containerState.furtherBlankLines || !markdownSpace(code)) {
150
+ self.containerState.furtherBlankLines = undefined;
151
+ self.containerState.initialBlankLine = undefined;
152
+ return notInCurrentItem(code);
153
+ }
154
+ self.containerState.furtherBlankLines = undefined;
155
+ self.containerState.initialBlankLine = undefined;
156
+ return effects.attempt(indentConstruct, ok, notInCurrentItem)(code);
157
+ }
158
+
159
+ /** @type {State} */
160
+ function notInCurrentItem(code) {
161
+ // While we do continue, we signal that the flow should be closed.
162
+ self.containerState._closeFlow = true;
163
+ // As we’re closing flow, we’re no longer interrupting.
164
+ self.interrupt = undefined;
165
+ // Always populated by defaults.
166
+
167
+ return factorySpace(effects, effects.attempt(list, ok, nok), "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code);
168
+ }
169
+ }
170
+
171
+ /**
172
+ * @this {TokenizeContext}
173
+ * Context.
174
+ * @type {Tokenizer}
175
+ */
176
+ function tokenizeIndent(effects, ok, nok) {
177
+ const self = this;
178
+ return factorySpace(effects, afterPrefix, "listItemIndent", self.containerState.size + 1);
179
+
180
+ /** @type {State} */
181
+ function afterPrefix(code) {
182
+ const tail = self.events[self.events.length - 1];
183
+ return tail && tail[1].type === "listItemIndent" && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok(code) : nok(code);
184
+ }
185
+ }
186
+
187
+ /**
188
+ * @this {TokenizeContext}
189
+ * Context.
190
+ * @type {Exiter}
191
+ */
192
+ function tokenizeListEnd(effects) {
193
+ effects.exit(this.containerState.type);
194
+ }
195
+
196
+ /**
197
+ * @this {TokenizeContext}
198
+ * Context.
199
+ * @type {Tokenizer}
200
+ */
201
+ function tokenizeListItemPrefixWhitespace(effects, ok, nok) {
202
+ const self = this;
203
+
204
+ // Always populated by defaults.
205
+
206
+ return factorySpace(effects, afterPrefix, "listItemPrefixWhitespace", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4 + 1);
207
+
208
+ /** @type {State} */
209
+ function afterPrefix(code) {
210
+ const tail = self.events[self.events.length - 1];
211
+ return !markdownSpace(code) && tail && tail[1].type === "listItemPrefixWhitespace" ? ok(code) : nok(code);
212
+ }
213
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @import {
3
+ * Construct,
4
+ * State,
5
+ * TokenizeContext,
6
+ * Tokenizer
7
+ * } from 'micromark-util-types'
8
+ */
9
+
10
+ import { markdownLineEnding } from 'micromark-util-character';
11
+ /** @type {Construct} */
12
+ export const nonLazyContinuation = {
13
+ partial: true,
14
+ tokenize: tokenizeNonLazyContinuation
15
+ };
16
+
17
+ /**
18
+ * @this {TokenizeContext}
19
+ * Context.
20
+ * @type {Tokenizer}
21
+ */
22
+ function tokenizeNonLazyContinuation(effects, ok, nok) {
23
+ const self = this;
24
+ return start;
25
+
26
+ /**
27
+ * At eol, before continuation.
28
+ *
29
+ * ```markdown
30
+ * > | * ```js
31
+ * ^
32
+ * | b
33
+ * ```
34
+ *
35
+ * @type {State}
36
+ */
37
+ function start(code) {
38
+ if (code === null) {
39
+ return nok(code);
40
+ }
41
+ effects.enter("lineEnding");
42
+ effects.consume(code);
43
+ effects.exit("lineEnding");
44
+ return after;
45
+ }
46
+
47
+ /**
48
+ * A continuation.
49
+ *
50
+ * ```markdown
51
+ * | * ```js
52
+ * > | b
53
+ * ^
54
+ * ```
55
+ *
56
+ * @type {State}
57
+ */
58
+ function after(code) {
59
+ return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
60
+ }
61
+ }
@@ -0,0 +1,187 @@
1
+ /**
2
+ * @import {
3
+ * Code,
4
+ * Construct,
5
+ * Resolver,
6
+ * State,
7
+ * TokenizeContext,
8
+ * Tokenizer
9
+ * } from 'micromark-util-types'
10
+ */
11
+
12
+ import { factorySpace } from 'micromark-factory-space';
13
+ import { markdownLineEnding, markdownSpace } from 'micromark-util-character';
14
+ import { EditMap } from 'micromark-util-edit-map';
15
+ /** @type {Construct} */
16
+ export const setextUnderline = {
17
+ name: 'setextUnderline',
18
+ resolveTo: resolveToSetextUnderline,
19
+ tokenize: tokenizeSetextUnderline
20
+ };
21
+
22
+ /** @type {Resolver} */
23
+ function resolveToSetextUnderline(events, context) {
24
+ const editMap = new EditMap();
25
+ let index = events.length;
26
+ /** @type {number | undefined} */
27
+ let content;
28
+ /** @type {number | undefined} */
29
+ let text;
30
+ /** @type {number | undefined} */
31
+ let definition;
32
+
33
+ // Find the opening of the content.
34
+ // It’ll always exist: we don’t tokenize if it isn’t there.
35
+ while (index--) {
36
+ if (events[index][0] === 'enter') {
37
+ if (events[index][1].type === "content") {
38
+ content = index;
39
+ break;
40
+ }
41
+ if (events[index][1].type === "paragraph") {
42
+ text = index;
43
+ }
44
+ }
45
+ // Exit
46
+ else {
47
+ if (events[index][1].type === "content") {
48
+ // Remove the content end (if needed we’ll add it later)
49
+ editMap.add(index, 1, []);
50
+ }
51
+ if (!definition && events[index][1].type === "definition") {
52
+ definition = index;
53
+ }
54
+ }
55
+ }
56
+ const heading = {
57
+ type: "setextHeading",
58
+ start: {
59
+ ...events[content][1].start
60
+ },
61
+ end: {
62
+ ...events[events.length - 1][1].end
63
+ }
64
+ };
65
+
66
+ // Change the paragraph to setext heading text.
67
+ events[text][1].type = "setextHeadingText";
68
+
69
+ // If we have definitions in the content, we’ll keep on having content,
70
+ // but we need move it.
71
+ if (definition) {
72
+ editMap.add(text, 0, [['enter', heading, context]]);
73
+ editMap.add(definition + 1, 0, [['exit', events[content][1], context]]);
74
+ events[content][1].end = {
75
+ ...events[definition][1].end
76
+ };
77
+ } else {
78
+ events[content][1] = heading;
79
+ }
80
+
81
+ // Add the heading exit at the end.
82
+ editMap.add(events.length, 0, [['exit', heading, context]]);
83
+ editMap.consume(events);
84
+ return events;
85
+ }
86
+
87
+ /**
88
+ * @this {TokenizeContext}
89
+ * Context.
90
+ * @type {Tokenizer}
91
+ */
92
+ function tokenizeSetextUnderline(effects, ok, nok) {
93
+ const self = this;
94
+ /** @type {NonNullable<Code>} */
95
+ let marker;
96
+ return start;
97
+
98
+ /**
99
+ * At start of heading (setext) underline.
100
+ *
101
+ * ```markdown
102
+ * | aa
103
+ * > | ==
104
+ * ^
105
+ * ```
106
+ *
107
+ * @type {State}
108
+ */
109
+ function start(code) {
110
+ let index = self.events.length;
111
+ /** @type {boolean | undefined} */
112
+ let paragraph;
113
+ // Find an opening.
114
+ while (index--) {
115
+ // Skip enter/exit of line ending, line prefix, and content.
116
+ // We can now either have a definition or a paragraph.
117
+ if (self.events[index][1].type !== "lineEnding" && self.events[index][1].type !== "linePrefix" && self.events[index][1].type !== "content") {
118
+ paragraph = self.events[index][1].type === "paragraph";
119
+ break;
120
+ }
121
+ }
122
+
123
+ // To do: handle lazy/pierce like `markdown-rs`.
124
+ // To do: parse indent like `markdown-rs`.
125
+ if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) {
126
+ effects.enter("setextHeadingLine");
127
+ marker = code;
128
+ return before(code);
129
+ }
130
+ return nok(code);
131
+ }
132
+
133
+ /**
134
+ * After optional whitespace, at `-` or `=`.
135
+ *
136
+ * ```markdown
137
+ * | aa
138
+ * > | ==
139
+ * ^
140
+ * ```
141
+ *
142
+ * @type {State}
143
+ */
144
+ function before(code) {
145
+ effects.enter("setextHeadingLineSequence");
146
+ return inside(code);
147
+ }
148
+
149
+ /**
150
+ * In sequence.
151
+ *
152
+ * ```markdown
153
+ * | aa
154
+ * > | ==
155
+ * ^
156
+ * ```
157
+ *
158
+ * @type {State}
159
+ */
160
+ function inside(code) {
161
+ if (code === marker) {
162
+ effects.consume(code);
163
+ return inside;
164
+ }
165
+ effects.exit("setextHeadingLineSequence");
166
+ return markdownSpace(code) ? factorySpace(effects, after, "lineSuffix")(code) : after(code);
167
+ }
168
+
169
+ /**
170
+ * After sequence, after optional whitespace.
171
+ *
172
+ * ```markdown
173
+ * | aa
174
+ * > | ==
175
+ * ^
176
+ * ```
177
+ *
178
+ * @type {State}
179
+ */
180
+ function after(code) {
181
+ if (code === null || markdownLineEnding(code)) {
182
+ effects.exit("setextHeadingLine");
183
+ return ok(code);
184
+ }
185
+ return nok(code);
186
+ }
187
+ }
@@ -0,0 +1,102 @@
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 { markdownLineEnding, markdownSpace } from 'micromark-util-character';
13
+ /** @type {Construct} */
14
+ export const thematicBreak = {
15
+ name: 'thematicBreak',
16
+ tokenize: tokenizeThematicBreak
17
+ };
18
+
19
+ /**
20
+ * @this {TokenizeContext}
21
+ * Context.
22
+ * @type {Tokenizer}
23
+ */
24
+ function tokenizeThematicBreak(effects, ok, nok) {
25
+ let size = 0;
26
+ /** @type {NonNullable<Code>} */
27
+ let marker;
28
+ return start;
29
+
30
+ /**
31
+ * Start of thematic break.
32
+ *
33
+ * ```markdown
34
+ * > | ***
35
+ * ^
36
+ * ```
37
+ *
38
+ * @type {State}
39
+ */
40
+ function start(code) {
41
+ effects.enter("thematicBreak");
42
+ // To do: parse indent like `markdown-rs`.
43
+ return before(code);
44
+ }
45
+
46
+ /**
47
+ * After optional whitespace, at marker.
48
+ *
49
+ * ```markdown
50
+ * > | ***
51
+ * ^
52
+ * ```
53
+ *
54
+ * @type {State}
55
+ */
56
+ function before(code) {
57
+ marker = code;
58
+ return atBreak(code);
59
+ }
60
+
61
+ /**
62
+ * After something, before something else.
63
+ *
64
+ * ```markdown
65
+ * > | ***
66
+ * ^
67
+ * ```
68
+ *
69
+ * @type {State}
70
+ */
71
+ function atBreak(code) {
72
+ if (code === marker) {
73
+ effects.enter("thematicBreakSequence");
74
+ return sequence(code);
75
+ }
76
+ if (size >= 3 && (code === null || markdownLineEnding(code))) {
77
+ effects.exit("thematicBreak");
78
+ return ok(code);
79
+ }
80
+ return nok(code);
81
+ }
82
+
83
+ /**
84
+ * In sequence.
85
+ *
86
+ * ```markdown
87
+ * > | ***
88
+ * ^
89
+ * ```
90
+ *
91
+ * @type {State}
92
+ */
93
+ function sequence(code) {
94
+ if (code === marker) {
95
+ effects.consume(code);
96
+ size++;
97
+ return sequence;
98
+ }
99
+ effects.exit("thematicBreakSequence");
100
+ return markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code);
101
+ }
102
+ }
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) Titus Wormer <tituswormer@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "micromark-core-commonmark",
3
+ "version": "2.0.4",
4
+ "description": "The CommonMark markdown constructs",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "micromark",
8
+ "core",
9
+ "commonmark"
10
+ ],
11
+ "repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-core-commonmark",
12
+ "bugs": "https://github.com/micromark/micromark/issues",
13
+ "funding": [
14
+ {
15
+ "type": "GitHub Sponsors",
16
+ "url": "https://github.com/sponsors/unifiedjs"
17
+ },
18
+ {
19
+ "type": "OpenCollective",
20
+ "url": "https://opencollective.com/unified"
21
+ }
22
+ ],
23
+ "author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
24
+ "contributors": [
25
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
26
+ ],
27
+ "sideEffects": false,
28
+ "type": "module",
29
+ "files": [
30
+ "dev/",
31
+ "lib/",
32
+ "index.d.ts.map",
33
+ "index.d.ts",
34
+ "index.js"
35
+ ],
36
+ "exports": {
37
+ "development": "./dev/index.js",
38
+ "default": "./index.js"
39
+ },
40
+ "dependencies": {
41
+ "decode-named-character-reference": "^1.0.0",
42
+ "devlop": "^1.0.0",
43
+ "micromark-factory-destination": "^2.0.0",
44
+ "micromark-factory-label": "^2.0.0",
45
+ "micromark-factory-space": "^2.1.0",
46
+ "micromark-factory-title": "^2.0.0",
47
+ "micromark-factory-whitespace": "^2.0.0",
48
+ "micromark-util-character": "^2.0.0",
49
+ "micromark-util-chunked": "^2.0.0",
50
+ "micromark-util-classify-character": "^2.0.0",
51
+ "micromark-util-edit-map": "^1.0.0",
52
+ "micromark-util-html-tag-name": "^2.0.0",
53
+ "micromark-util-normalize-identifier": "^2.0.0",
54
+ "micromark-util-resolve-all": "^2.0.0",
55
+ "micromark-util-subtokenize": "^2.0.0",
56
+ "micromark-util-symbol": "^2.0.0",
57
+ "micromark-util-types": "^2.0.3"
58
+ },
59
+ "scripts": {
60
+ "build": "micromark-build"
61
+ }
62
+ }
@@ -0,0 +1,3 @@
1
+ // Note: more types exposed from `index.d.ts`.
2
+ export { gfmStrikethroughHtml } from './lib/html.js';
3
+ export { gfmStrikethrough } from './lib/syntax.js';