@tinta-lang/syntax 0.0.0-stage → 0.1.16

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/README.md +16 -2
  3. package/THIRD_PARTY_NOTICES.txt +13651 -0
  4. package/dist/directive.d.ts +40 -0
  5. package/dist/editing.d.ts +46 -0
  6. package/dist/enrichment.d.ts +5 -0
  7. package/dist/expression.d.ts +26 -0
  8. package/dist/image-destinations.d.ts +3 -0
  9. package/dist/index.d.ts +8 -0
  10. package/dist/index.js +10118 -0
  11. package/dist/parser.d.ts +40 -0
  12. package/dist/registry.d.ts +144 -0
  13. package/dist/source.d.ts +28 -0
  14. package/package.json +289 -3
  15. package/parser-provenance.json +1419 -0
  16. package/patches/README.md +5 -0
  17. package/patches/micromark.patch +84 -0
  18. package/vendor/@noble/hashes/LICENSE +21 -0
  19. package/vendor/@noble/hashes/_md.js +209 -0
  20. package/vendor/@noble/hashes/_u64.js +77 -0
  21. package/vendor/@noble/hashes/package.json +91 -0
  22. package/vendor/@noble/hashes/sha2.js +446 -0
  23. package/vendor/@noble/hashes/utils.js +687 -0
  24. package/vendor/character-entities/index.js +2132 -0
  25. package/vendor/character-entities/license +22 -0
  26. package/vendor/character-entities/package.json +78 -0
  27. package/vendor/decode-named-character-reference/index.js +19 -0
  28. package/vendor/decode-named-character-reference/license +22 -0
  29. package/vendor/decode-named-character-reference/package.json +90 -0
  30. package/vendor/devlop/lib/default.js +9 -0
  31. package/vendor/devlop/license +22 -0
  32. package/vendor/devlop/package.json +80 -0
  33. package/vendor/longest-streak/index.js +36 -0
  34. package/vendor/longest-streak/license +22 -0
  35. package/vendor/longest-streak/package.json +73 -0
  36. package/vendor/markdown-table/index.js +393 -0
  37. package/vendor/markdown-table/license +22 -0
  38. package/vendor/markdown-table/package.json +77 -0
  39. package/vendor/mdast-util-from-markdown/index.js +2 -0
  40. package/vendor/mdast-util-from-markdown/lib/index.js +1270 -0
  41. package/vendor/mdast-util-from-markdown/license +22 -0
  42. package/vendor/mdast-util-from-markdown/package.json +98 -0
  43. package/vendor/mdast-util-gfm-strikethrough/index.js +5 -0
  44. package/vendor/mdast-util-gfm-strikethrough/lib/index.js +133 -0
  45. package/vendor/mdast-util-gfm-strikethrough/license +22 -0
  46. package/vendor/mdast-util-gfm-strikethrough/package.json +84 -0
  47. package/vendor/mdast-util-gfm-table/index.js +2 -0
  48. package/vendor/mdast-util-gfm-table/lib/index.js +300 -0
  49. package/vendor/mdast-util-gfm-table/license +22 -0
  50. package/vendor/mdast-util-gfm-table/package.json +101 -0
  51. package/vendor/mdast-util-gfm-task-list-item/index.js +4 -0
  52. package/vendor/mdast-util-gfm-task-list-item/lib/index.js +141 -0
  53. package/vendor/mdast-util-gfm-task-list-item/license +22 -0
  54. package/vendor/mdast-util-gfm-task-list-item/package.json +90 -0
  55. package/vendor/mdast-util-phrasing/index.js +1 -0
  56. package/vendor/mdast-util-phrasing/lib/index.js +45 -0
  57. package/vendor/mdast-util-phrasing/license +23 -0
  58. package/vendor/mdast-util-phrasing/package.json +78 -0
  59. package/vendor/mdast-util-to-markdown/index.js +3 -0
  60. package/vendor/mdast-util-to-markdown/lib/configure.js +98 -0
  61. package/vendor/mdast-util-to-markdown/lib/handle/blockquote.js +40 -0
  62. package/vendor/mdast-util-to-markdown/lib/handle/break.js +41 -0
  63. package/vendor/mdast-util-to-markdown/lib/handle/code.js +86 -0
  64. package/vendor/mdast-util-to-markdown/lib/handle/definition.js +83 -0
  65. package/vendor/mdast-util-to-markdown/lib/handle/emphasis.js +67 -0
  66. package/vendor/mdast-util-to-markdown/lib/handle/heading.js +84 -0
  67. package/vendor/mdast-util-to-markdown/lib/handle/html.js +27 -0
  68. package/vendor/mdast-util-to-markdown/lib/handle/image-reference.js +78 -0
  69. package/vendor/mdast-util-to-markdown/lib/handle/image.js +92 -0
  70. package/vendor/mdast-util-to-markdown/lib/handle/index.js +45 -0
  71. package/vendor/mdast-util-to-markdown/lib/handle/inline-code.js +86 -0
  72. package/vendor/mdast-util-to-markdown/lib/handle/link-reference.js +78 -0
  73. package/vendor/mdast-util-to-markdown/lib/handle/link.js +129 -0
  74. package/vendor/mdast-util-to-markdown/lib/handle/list-item.js +73 -0
  75. package/vendor/mdast-util-to-markdown/lib/handle/list.js +107 -0
  76. package/vendor/mdast-util-to-markdown/lib/handle/paragraph.js +27 -0
  77. package/vendor/mdast-util-to-markdown/lib/handle/root.js +34 -0
  78. package/vendor/mdast-util-to-markdown/lib/handle/strong.js +67 -0
  79. package/vendor/mdast-util-to-markdown/lib/handle/text.js +30 -0
  80. package/vendor/mdast-util-to-markdown/lib/handle/thematic-break.js +27 -0
  81. package/vendor/mdast-util-to-markdown/lib/index.js +213 -0
  82. package/vendor/mdast-util-to-markdown/lib/join.js +56 -0
  83. package/vendor/mdast-util-to-markdown/lib/unsafe.js +160 -0
  84. package/vendor/mdast-util-to-markdown/lib/util/association.js +33 -0
  85. package/vendor/mdast-util-to-markdown/lib/util/character.js +32 -0
  86. package/vendor/mdast-util-to-markdown/lib/util/check-bullet-ordered.js +25 -0
  87. package/vendor/mdast-util-to-markdown/lib/util/check-bullet-other.js +42 -0
  88. package/vendor/mdast-util-to-markdown/lib/util/check-bullet.js +25 -0
  89. package/vendor/mdast-util-to-markdown/lib/util/check-emphasis.js +25 -0
  90. package/vendor/mdast-util-to-markdown/lib/util/check-fence.js +25 -0
  91. package/vendor/mdast-util-to-markdown/lib/util/check-list-item-indent.js +25 -0
  92. package/vendor/mdast-util-to-markdown/lib/util/check-quote.js +25 -0
  93. package/vendor/mdast-util-to-markdown/lib/util/check-rule-repetition.js +25 -0
  94. package/vendor/mdast-util-to-markdown/lib/util/check-rule.js +25 -0
  95. package/vendor/mdast-util-to-markdown/lib/util/check-strong.js +25 -0
  96. package/vendor/mdast-util-to-markdown/lib/util/compile-pattern.js +30 -0
  97. package/vendor/mdast-util-to-markdown/lib/util/container-flow.js +93 -0
  98. package/vendor/mdast-util-to-markdown/lib/util/container-phrasing.js +704 -0
  99. package/vendor/mdast-util-to-markdown/lib/util/encode-character-reference.js +11 -0
  100. package/vendor/mdast-util-to-markdown/lib/util/encode-info.js +82 -0
  101. package/vendor/mdast-util-to-markdown/lib/util/format-code-as-indented.js +27 -0
  102. package/vendor/mdast-util-to-markdown/lib/util/format-heading-as-setext.js +39 -0
  103. package/vendor/mdast-util-to-markdown/lib/util/format-link-as-autolink.js +39 -0
  104. package/vendor/mdast-util-to-markdown/lib/util/html-kind.js +63 -0
  105. package/vendor/mdast-util-to-markdown/lib/util/indent-lines.js +40 -0
  106. package/vendor/mdast-util-to-markdown/lib/util/pattern-in-scope.js +52 -0
  107. package/vendor/mdast-util-to-markdown/lib/util/safe.js +263 -0
  108. package/vendor/mdast-util-to-markdown/lib/util/track.js +55 -0
  109. package/vendor/mdast-util-to-markdown/license +22 -0
  110. package/vendor/mdast-util-to-markdown/package.json +88 -0
  111. package/vendor/mdast-util-to-string/index.js +5 -0
  112. package/vendor/mdast-util-to-string/lib/index.js +108 -0
  113. package/vendor/mdast-util-to-string/license +22 -0
  114. package/vendor/mdast-util-to-string/package.json +78 -0
  115. package/vendor/micromark/index.js +60 -0
  116. package/vendor/micromark/lib/compile.js +1068 -0
  117. package/vendor/micromark/lib/constructs.js +85 -0
  118. package/vendor/micromark/lib/create-tokenizer.js +615 -0
  119. package/vendor/micromark/lib/initialize/content.js +79 -0
  120. package/vendor/micromark/lib/initialize/document.js +370 -0
  121. package/vendor/micromark/lib/initialize/flow.js +58 -0
  122. package/vendor/micromark/lib/initialize/text.js +216 -0
  123. package/vendor/micromark/lib/parse.js +56 -0
  124. package/vendor/micromark/lib/postprocess.js +18 -0
  125. package/vendor/micromark/lib/preprocess.js +112 -0
  126. package/vendor/micromark/license +22 -0
  127. package/vendor/micromark/package.json +87 -0
  128. package/vendor/micromark-core-commonmark/index.js +22 -0
  129. package/vendor/micromark-core-commonmark/lib/attention.js +231 -0
  130. package/vendor/micromark-core-commonmark/lib/autolink.js +233 -0
  131. package/vendor/micromark-core-commonmark/lib/blank-line.js +61 -0
  132. package/vendor/micromark-core-commonmark/lib/block-quote.js +143 -0
  133. package/vendor/micromark-core-commonmark/lib/character-escape.js +64 -0
  134. package/vendor/micromark-core-commonmark/lib/character-reference.js +149 -0
  135. package/vendor/micromark-core-commonmark/lib/code-fenced.js +422 -0
  136. package/vendor/micromark-core-commonmark/lib/code-indented.js +159 -0
  137. package/vendor/micromark-core-commonmark/lib/code-text.js +225 -0
  138. package/vendor/micromark-core-commonmark/lib/content.js +163 -0
  139. package/vendor/micromark-core-commonmark/lib/definition.js +254 -0
  140. package/vendor/micromark-core-commonmark/lib/hard-break-escape.js +60 -0
  141. package/vendor/micromark-core-commonmark/lib/heading-atx.js +191 -0
  142. package/vendor/micromark-core-commonmark/lib/html-flow.js +827 -0
  143. package/vendor/micromark-core-commonmark/lib/html-text.js +678 -0
  144. package/vendor/micromark-core-commonmark/lib/label-end.js +561 -0
  145. package/vendor/micromark-core-commonmark/lib/label-start-image.js +110 -0
  146. package/vendor/micromark-core-commonmark/lib/label-start-link.js +63 -0
  147. package/vendor/micromark-core-commonmark/lib/line-ending.js +33 -0
  148. package/vendor/micromark-core-commonmark/lib/list.js +213 -0
  149. package/vendor/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
  150. package/vendor/micromark-core-commonmark/lib/setext-underline.js +187 -0
  151. package/vendor/micromark-core-commonmark/lib/thematic-break.js +102 -0
  152. package/vendor/micromark-core-commonmark/license +22 -0
  153. package/vendor/micromark-core-commonmark/package.json +62 -0
  154. package/vendor/micromark-extension-gfm-strikethrough/index.js +3 -0
  155. package/vendor/micromark-extension-gfm-strikethrough/lib/html.js +26 -0
  156. package/vendor/micromark-extension-gfm-strikethrough/lib/syntax.js +142 -0
  157. package/vendor/micromark-extension-gfm-strikethrough/license +22 -0
  158. package/vendor/micromark-extension-gfm-strikethrough/package.json +129 -0
  159. package/vendor/micromark-extension-gfm-table/index.js +2 -0
  160. package/vendor/micromark-extension-gfm-table/lib/edit-map.js +222 -0
  161. package/vendor/micromark-extension-gfm-table/lib/html.js +135 -0
  162. package/vendor/micromark-extension-gfm-table/lib/infer.js +52 -0
  163. package/vendor/micromark-extension-gfm-table/lib/syntax.js +846 -0
  164. package/vendor/micromark-extension-gfm-table/license +22 -0
  165. package/vendor/micromark-extension-gfm-table/package.json +86 -0
  166. package/vendor/micromark-extension-gfm-task-list-item/index.js +2 -0
  167. package/vendor/micromark-extension-gfm-task-list-item/lib/html.js +29 -0
  168. package/vendor/micromark-extension-gfm-task-list-item/lib/syntax.js +158 -0
  169. package/vendor/micromark-extension-gfm-task-list-item/license +22 -0
  170. package/vendor/micromark-extension-gfm-task-list-item/package.json +131 -0
  171. package/vendor/micromark-factory-destination/index.js +206 -0
  172. package/vendor/micromark-factory-destination/license +22 -0
  173. package/vendor/micromark-factory-destination/package.json +57 -0
  174. package/vendor/micromark-factory-label/index.js +148 -0
  175. package/vendor/micromark-factory-label/license +22 -0
  176. package/vendor/micromark-factory-label/package.json +60 -0
  177. package/vendor/micromark-factory-space/index.js +116 -0
  178. package/vendor/micromark-factory-space/license +22 -0
  179. package/vendor/micromark-factory-space/package.json +46 -0
  180. package/vendor/micromark-factory-title/index.js +158 -0
  181. package/vendor/micromark-factory-title/license +22 -0
  182. package/vendor/micromark-factory-title/package.json +58 -0
  183. package/vendor/micromark-factory-whitespace/index.js +44 -0
  184. package/vendor/micromark-factory-whitespace/license +22 -0
  185. package/vendor/micromark-factory-whitespace/package.json +57 -0
  186. package/vendor/micromark-util-character/index.js +246 -0
  187. package/vendor/micromark-util-character/license +22 -0
  188. package/vendor/micromark-util-character/package.json +57 -0
  189. package/vendor/micromark-util-chunked/index.js +81 -0
  190. package/vendor/micromark-util-chunked/license +22 -0
  191. package/vendor/micromark-util-chunked/package.json +57 -0
  192. package/vendor/micromark-util-classify-character/index.js +27 -0
  193. package/vendor/micromark-util-classify-character/license +22 -0
  194. package/vendor/micromark-util-classify-character/package.json +59 -0
  195. package/vendor/micromark-util-combine-extensions/index.js +143 -0
  196. package/vendor/micromark-util-combine-extensions/license +22 -0
  197. package/vendor/micromark-util-combine-extensions/package.json +52 -0
  198. package/vendor/micromark-util-decode-numeric-character-reference/index.js +32 -0
  199. package/vendor/micromark-util-decode-numeric-character-reference/license +22 -0
  200. package/vendor/micromark-util-decode-numeric-character-reference/package.json +59 -0
  201. package/vendor/micromark-util-decode-string/index.js +45 -0
  202. package/vendor/micromark-util-decode-string/license +22 -0
  203. package/vendor/micromark-util-decode-string/package.json +63 -0
  204. package/vendor/micromark-util-edit-map/index.js +225 -0
  205. package/vendor/micromark-util-edit-map/license +22 -0
  206. package/vendor/micromark-util-edit-map/package.json +48 -0
  207. package/vendor/micromark-util-encode/index.js +33 -0
  208. package/vendor/micromark-util-encode/license +22 -0
  209. package/vendor/micromark-util-encode/package.json +47 -0
  210. package/vendor/micromark-util-html-tag-name/index.js +93 -0
  211. package/vendor/micromark-util-html-tag-name/license +22 -0
  212. package/vendor/micromark-util-html-tag-name/package.json +47 -0
  213. package/vendor/micromark-util-normalize-identifier/index.js +33 -0
  214. package/vendor/micromark-util-normalize-identifier/license +22 -0
  215. package/vendor/micromark-util-normalize-identifier/package.json +58 -0
  216. package/vendor/micromark-util-resolve-all/index.js +32 -0
  217. package/vendor/micromark-util-resolve-all/license +22 -0
  218. package/vendor/micromark-util-resolve-all/package.json +48 -0
  219. package/vendor/micromark-util-sanitize-uri/index.js +107 -0
  220. package/vendor/micromark-util-sanitize-uri/license +22 -0
  221. package/vendor/micromark-util-sanitize-uri/package.json +59 -0
  222. package/vendor/micromark-util-subtokenize/index.js +228 -0
  223. package/vendor/micromark-util-subtokenize/lib/splice-buffer.js +251 -0
  224. package/vendor/micromark-util-subtokenize/license +22 -0
  225. package/vendor/micromark-util-subtokenize/package.json +60 -0
  226. package/vendor/unist-util-is/index.js +7 -0
  227. package/vendor/unist-util-is/lib/index.js +296 -0
  228. package/vendor/unist-util-is/license +22 -0
  229. package/vendor/unist-util-is/package.json +103 -0
  230. package/vendor/unist-util-stringify-position/index.js +1 -0
  231. package/vendor/unist-util-stringify-position/lib/index.js +84 -0
  232. package/vendor/unist-util-stringify-position/license +22 -0
  233. package/vendor/unist-util-stringify-position/package.json +80 -0
  234. package/vendor/unist-util-visit/index.js +2 -0
  235. package/vendor/unist-util-visit/lib/index.js +312 -0
  236. package/vendor/unist-util-visit/license +22 -0
  237. package/vendor/unist-util-visit/package.json +108 -0
  238. package/vendor/unist-util-visit-parents/index.js +2 -0
  239. package/vendor/unist-util-visit-parents/lib/color.js +7 -0
  240. package/vendor/unist-util-visit-parents/lib/index.js +399 -0
  241. package/vendor/unist-util-visit-parents/license +22 -0
  242. package/vendor/unist-util-visit-parents/package.json +106 -0
  243. package/vendor/zwitch/index.js +118 -0
  244. package/vendor/zwitch/license +22 -0
  245. package/vendor/zwitch/package.json +72 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @import {Options, State} from 'mdast-util-to-markdown'
3
+ */
4
+
5
+ /**
6
+ * Checks the preferred rule repetition option.
7
+ *
8
+ * @param {State} state
9
+ * Info passed around.
10
+ * @returns {Exclude<Options['ruleRepetition'], null | undefined>}
11
+ * Preferred rule repetition.
12
+ */
13
+ export function checkRuleRepetition(state) {
14
+ const repetition = state.options.ruleRepetition || 3
15
+
16
+ if (repetition < 3) {
17
+ throw new Error(
18
+ 'Cannot serialize rules with repetition `' +
19
+ repetition +
20
+ '` for `options.ruleRepetition`, expected `3` or more'
21
+ )
22
+ }
23
+
24
+ return repetition
25
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @import {Options, State} from 'mdast-util-to-markdown'
3
+ */
4
+
5
+ /**
6
+ * Checks the preferred rule option.
7
+ *
8
+ * @param {State} state
9
+ * Info passed around.
10
+ * @returns {Exclude<Options['rule'], null | undefined>}
11
+ * Preferred rule marker.
12
+ */
13
+ export function checkRule(state) {
14
+ const marker = state.options.rule || '*'
15
+
16
+ if (marker !== '*' && marker !== '-' && marker !== '_') {
17
+ throw new Error(
18
+ 'Cannot serialize rules with `' +
19
+ marker +
20
+ '` for `options.rule`, expected `*`, `-`, or `_`'
21
+ )
22
+ }
23
+
24
+ return marker
25
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @import {Options, State} from 'mdast-util-to-markdown'
3
+ */
4
+
5
+ /**
6
+ * Checks the preferred strong option.
7
+ *
8
+ * @param {State} state
9
+ * Info passed around.
10
+ * @returns {Exclude<Options['strong'], null | undefined>}
11
+ * Preferred strong marker.
12
+ */
13
+ export function checkStrong(state) {
14
+ const marker = state.options.strong || '*'
15
+
16
+ if (marker !== '*' && marker !== '_') {
17
+ throw new Error(
18
+ 'Cannot serialize strong with `' +
19
+ marker +
20
+ '` for `options.strong`, expected `*`, or `_`'
21
+ )
22
+ }
23
+
24
+ return marker
25
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @import {CompilePattern} from '../types.js'
3
+ */
4
+
5
+ /**
6
+ * Compiles a pattern object into a regular expression.
7
+ *
8
+ * @type {CompilePattern}
9
+ */
10
+ export function compilePattern(pattern) {
11
+ if (!pattern._compiled) {
12
+ const before =
13
+ (pattern.atBreak ? '[\\r\\n][\\t ]*' : '') +
14
+ (pattern.before ? '(?:' + pattern.before + ')' : '')
15
+
16
+ pattern._compiled = new RegExp(
17
+ (pattern.beforeNode ? '^' : before ? '(' + before + ')' : '') +
18
+ (/[$()*+.?[\\\]^{|}]/.test(pattern.character) ? '\\' : '') +
19
+ pattern.character +
20
+ (pattern.afterNode
21
+ ? '$'
22
+ : pattern.after
23
+ ? '(?:' + pattern.after + ')'
24
+ : ''),
25
+ pattern.unicode ? 'gu' : 'g'
26
+ )
27
+ }
28
+
29
+ return pattern._compiled
30
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @import {State} from 'mdast-util-to-markdown'
3
+ * @import {FlowChildren, FlowParents, TrackFields} from '../types.js'
4
+ */
5
+
6
+ /**
7
+ * Serialize the children of a parent that contains flow children.
8
+ *
9
+ * @param {FlowParents} parent
10
+ * Parent of flow nodes.
11
+ * @param {State} state
12
+ * Info passed around about the current state.
13
+ * @param {TrackFields} info
14
+ * Info on where we are in the document we are generating.
15
+ * @returns {string}
16
+ * Serialized children, joined by (blank) lines.
17
+ */
18
+ export function containerFlow(parent, state, info) {
19
+ const indexStack = state.indexStack
20
+ const children = parent.children || []
21
+ const tracker = state.createTracker(info)
22
+ /** @type {Array<string>} */
23
+ const results = []
24
+ let index = -1
25
+
26
+ indexStack.push(-1)
27
+
28
+ while (++index < children.length) {
29
+ const child = children[index]
30
+
31
+ indexStack[indexStack.length - 1] = index
32
+
33
+ results.push(
34
+ tracker.move(
35
+ state.handle(child, parent, state, {
36
+ before: '\n',
37
+ after: '\n',
38
+ ...tracker.current()
39
+ })
40
+ )
41
+ )
42
+
43
+ if (child.type !== 'list') {
44
+ state.bulletLastUsed = undefined
45
+ }
46
+
47
+ if (index < children.length - 1) {
48
+ results.push(
49
+ tracker.move(between(child, children[index + 1], parent, state))
50
+ )
51
+ }
52
+ }
53
+
54
+ indexStack.pop()
55
+
56
+ return results.join('')
57
+ }
58
+
59
+ /**
60
+ * Determine the markdown to insert between two flow nodes.
61
+ *
62
+ * @param {FlowChildren} left
63
+ * Left flow node.
64
+ * @param {FlowChildren} right
65
+ * Right flow node.
66
+ * @param {FlowParents} parent
67
+ * Parent of the flow nodes.
68
+ * @param {State} state
69
+ * Info passed around.
70
+ * @returns {string}
71
+ * Markdown to insert between the two flow nodes.
72
+ */
73
+ function between(left, right, parent, state) {
74
+ let index = state.join.length
75
+
76
+ while (index--) {
77
+ const result = state.join[index](left, right, parent, state)
78
+
79
+ if (result === true || result === 1) {
80
+ break
81
+ }
82
+
83
+ if (typeof result === 'number') {
84
+ return '\n'.repeat(1 + result)
85
+ }
86
+
87
+ if (result === false) {
88
+ return '\n\n<!---->\n\n'
89
+ }
90
+ }
91
+
92
+ return '\n\n'
93
+ }