@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,225 @@
1
+ /**
2
+ * @import {Event} from 'micromark-util-types'
3
+ */
4
+
5
+ /**
6
+ * @typedef {[number, number, Array<Event>]} Change
7
+ * @typedef {[number, number, number]} Jump
8
+ */
9
+
10
+ /**
11
+ * Tracks a bunch of edits.
12
+ *
13
+ * Port of `edit_map.rs` from `markdown-rs`:
14
+ * <https://github.com/wooorm/markdown-rs/blob/1506572f/src/util/edit_map.rs>.
15
+ *
16
+ * Deal with several changes in events, batching them together.
17
+ *
18
+ * Preferably, changes should be kept to a minimum.
19
+ * Sometimes, it’s needed to change the list of events, because parsing can be
20
+ * messy, and it helps to expose a cleaner interface of events to the compiler
21
+ * and other users.
22
+ * It can also help to merge many adjacent similar events.
23
+ * And, in other cases, it’s needed to parse subcontent: pass some events
24
+ * through another tokenizer and inject the result.
25
+ */
26
+ export class EditMap {
27
+ /**
28
+ * Create a new edit map.
29
+ *
30
+ * @returns
31
+ * New instance.
32
+ */
33
+ constructor() {
34
+ /**
35
+ * Changes by index, so `add` does not need to scan `map` (which is
36
+ * quadratic for documents with many edits at different places).
37
+ *
38
+ * @type {Map<number, Change>}
39
+ */
40
+ this.index = new Map();
41
+
42
+ /**
43
+ * Record of changes.
44
+ *
45
+ * @type {Array<Change>}
46
+ */
47
+ this.map = [];
48
+ }
49
+
50
+ /**
51
+ * Create an edit: a remove and/or add at a certain place.
52
+ *
53
+ * @param {number} index
54
+ * Index at which to apply the edit.
55
+ * @param {number} remove
56
+ * Count of items to remove at the index.
57
+ * @param {Array<Event>} add
58
+ * Items to add at the index.
59
+ * @returns {undefined}
60
+ * Nothing.
61
+ */
62
+ add(index, remove, add) {
63
+ addImplementation(this, index, remove, add, false);
64
+ }
65
+
66
+ /**
67
+ * Create an edit: but insert `add` before existing additions, instead of
68
+ * after them.
69
+ *
70
+ * @param {number} index
71
+ * Index at which to apply the edit.
72
+ * @param {number} remove
73
+ * Count of items to remove at the index.
74
+ * @param {Array<Event>} add
75
+ * Items to add at the index.
76
+ * @returns {undefined}
77
+ * Nothing.
78
+ */
79
+ addBefore(index, remove, add) {
80
+ addImplementation(this, index, remove, add, true);
81
+ }
82
+
83
+ /**
84
+ * Done, change the events.
85
+ *
86
+ * @param {Array<Event>} events
87
+ * List of events to apply the edits to.
88
+ * @returns {undefined}
89
+ * Nothing.
90
+ */
91
+ consume(events) {
92
+ this.map.sort(function (a, b) {
93
+ return a[0] - b[0];
94
+ });
95
+ if (this.map.length === 0) {
96
+ return;
97
+ }
98
+
99
+ // To do: if links are added in events, like they are in `markdown-rs`,
100
+ // this is needed.
101
+ // // Calculate jumps: where items in the current list move to.
102
+ // /** @type {Array<Jump>} */
103
+ // const jumps = []
104
+ // let index = 0
105
+ // let addAcc = 0
106
+ // let removeAcc = 0
107
+ // while (index < this.map.length) {
108
+ // const [at, remove, add] = this.map[index]
109
+ // removeAcc += remove
110
+ // addAcc += add.length
111
+ // jumps.push([at, removeAcc, addAcc])
112
+ // index += 1
113
+ // }
114
+ //
115
+ // shiftLinks(events, jumps)
116
+
117
+ let index = this.map.length;
118
+ /** @type {Array<Array<Event>>} */
119
+ const vecs = [];
120
+ while (index > 0) {
121
+ index -= 1;
122
+ vecs.push(events.slice(this.map[index][0] + this.map[index][1]), this.map[index][2]);
123
+
124
+ // Truncate rest.
125
+ events.length = this.map[index][0];
126
+ }
127
+ vecs.push(events.slice());
128
+ events.length = 0;
129
+ let slice = vecs.pop();
130
+ while (slice) {
131
+ for (const element of slice) {
132
+ events.push(element);
133
+ }
134
+ slice = vecs.pop();
135
+ }
136
+
137
+ // Truncate everything.
138
+ this.map.length = 0;
139
+ this.index.clear();
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Create an edit.
145
+ *
146
+ * @param {EditMap} editMap
147
+ * Edit map to apply to.
148
+ * @param {number} at
149
+ * Index at which to apply the edit.
150
+ * @param {number} remove
151
+ * Count of items to remove at the index.
152
+ * @param {Array<Event>} add
153
+ * Items to add at the index.
154
+ * @param {boolean} before
155
+ * Insert `add` before existing additions at `at`, instead of after them.
156
+ * @returns {undefined}
157
+ * Nothing.
158
+ */
159
+ function addImplementation(editMap, at, remove, add, before) {
160
+ if (remove === 0 && add.length === 0) {
161
+ return;
162
+ }
163
+ const existing = editMap.index.get(at);
164
+ if (existing) {
165
+ existing[1] += remove;
166
+ if (before) {
167
+ add.push(...existing[2]);
168
+ existing[2] = add;
169
+ } else {
170
+ existing[2].push(...add);
171
+ }
172
+ return;
173
+ }
174
+
175
+ /** @type {Change} */
176
+ const change = [at, remove, add];
177
+ editMap.map.push(change);
178
+ editMap.index.set(at, change);
179
+ }
180
+
181
+ // /**
182
+ // * Shift `previous` and `next` links according to `jumps`.
183
+ // *
184
+ // * This fixes links in case there are events removed or added between them.
185
+ // *
186
+ // * @param {Array<Event>} events
187
+ // * @param {Array<Jump>} jumps
188
+ // */
189
+ // function shiftLinks(events, jumps) {
190
+ // let jumpIndex = 0
191
+ // let index = 0
192
+ // let add = 0
193
+ // let rm = 0
194
+
195
+ // while (index < events.length) {
196
+ // const rmCurr = rm
197
+
198
+ // while (jumpIndex < jumps.length && jumps[jumpIndex][0] <= index) {
199
+ // add = jumps[jumpIndex][2]
200
+ // rm = jumps[jumpIndex][1]
201
+ // jumpIndex += 1
202
+ // }
203
+
204
+ // // Ignore items that will be removed.
205
+ // if (rm > rmCurr) {
206
+ // index += rm - rmCurr
207
+ // } else {
208
+ // // ?
209
+ // // if let Some(link) = &events[index].link {
210
+ // // if let Some(next) = link.next {
211
+ // // events[next].link.as_mut().unwrap().previous = Some(index + add - rm);
212
+ // // while jumpIndex < jumps.len() && jumps[jumpIndex].0 <= next {
213
+ // // add = jumps[jumpIndex].2;
214
+ // // rm = jumps[jumpIndex].1;
215
+ // // jumpIndex += 1;
216
+ // // }
217
+ // // events[index].link.as_mut().unwrap().next = Some(next + add - rm);
218
+ // // index = next;
219
+ // // continue;
220
+ // // }
221
+ // // }
222
+ // index += 1
223
+ // }
224
+ // }
225
+ // }
@@ -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,48 @@
1
+ {
2
+ "name": "micromark-util-edit-map",
3
+ "version": "1.0.0",
4
+ "description": "micromark utility to batch changes to lists of events",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "micromark",
8
+ "util",
9
+ "utility",
10
+ "edit",
11
+ "map",
12
+ "splice"
13
+ ],
14
+ "repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-util-edit-map",
15
+ "bugs": "https://github.com/micromark/micromark/issues",
16
+ "funding": [
17
+ {
18
+ "type": "GitHub Sponsors",
19
+ "url": "https://github.com/sponsors/unifiedjs"
20
+ },
21
+ {
22
+ "type": "OpenCollective",
23
+ "url": "https://opencollective.com/unified"
24
+ }
25
+ ],
26
+ "author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
27
+ "contributors": [
28
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
29
+ ],
30
+ "sideEffects": false,
31
+ "type": "module",
32
+ "files": [
33
+ "dev/",
34
+ "index.d.ts.map",
35
+ "index.d.ts",
36
+ "index.js"
37
+ ],
38
+ "exports": {
39
+ "development": "./dev/index.js",
40
+ "default": "./index.js"
41
+ },
42
+ "dependencies": {
43
+ "micromark-util-types": "^2.0.0"
44
+ },
45
+ "scripts": {
46
+ "build": "micromark-build"
47
+ }
48
+ }
@@ -0,0 +1,33 @@
1
+ const characterReferences = {'"': 'quot', '&': 'amp', '<': 'lt', '>': 'gt'}
2
+
3
+ /**
4
+ * Encode only the dangerous HTML characters.
5
+ *
6
+ * This ensures that certain characters which have special meaning in HTML are
7
+ * dealt with.
8
+ * Technically, we can skip `>` and `"` in many cases, but CM includes them.
9
+ *
10
+ * @param {string} value
11
+ * Value to encode.
12
+ * @returns {string}
13
+ * Encoded value.
14
+ */
15
+ export function encode(value) {
16
+ return value.replace(/["&<>]/g, replace)
17
+
18
+ /**
19
+ * @param {string} value
20
+ * Value to replace.
21
+ * @returns {string}
22
+ * Encoded value.
23
+ */
24
+ function replace(value) {
25
+ return (
26
+ '&' +
27
+ characterReferences[
28
+ /** @type {keyof typeof characterReferences} */ (value)
29
+ ] +
30
+ ';'
31
+ )
32
+ }
33
+ }
@@ -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,47 @@
1
+ {
2
+ "name": "micromark-util-encode",
3
+ "version": "2.0.1",
4
+ "description": "micromark utility to encode dangerous html characters",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "micromark",
8
+ "util",
9
+ "utility",
10
+ "html",
11
+ "encode"
12
+ ],
13
+ "repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-util-encode",
14
+ "bugs": "https://github.com/micromark/micromark/issues",
15
+ "funding": [
16
+ {
17
+ "type": "GitHub Sponsors",
18
+ "url": "https://github.com/sponsors/unifiedjs"
19
+ },
20
+ {
21
+ "type": "OpenCollective",
22
+ "url": "https://opencollective.com/unified"
23
+ }
24
+ ],
25
+ "author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
26
+ "contributors": [
27
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
28
+ ],
29
+ "sideEffects": false,
30
+ "type": "module",
31
+ "files": [
32
+ "index.d.ts.map",
33
+ "index.d.ts",
34
+ "index.js"
35
+ ],
36
+ "exports": "./index.js",
37
+ "xo": {
38
+ "envs": [
39
+ "shared-node-browser"
40
+ ],
41
+ "prettier": true,
42
+ "rules": {
43
+ "unicorn/prefer-string-replace-all": "off",
44
+ "unicorn/prefer-code-point": "off"
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * List of lowercase HTML “block” tag names.
3
+ *
4
+ * The list, when parsing HTML (flow), results in more relaxed rules (condition
5
+ * 6).
6
+ * Because they are known blocks, the HTML-like syntax doesn’t have to be
7
+ * strictly parsed.
8
+ * For tag names not in this list, a more strict algorithm (condition 7) is used
9
+ * to detect whether the HTML-like syntax is seen as HTML (flow) or not.
10
+ *
11
+ * This is copied from:
12
+ * <https://spec.commonmark.org/0.30/#html-blocks>.
13
+ *
14
+ * > 👉 **Note**: `search` was added in `CommonMark@0.31`.
15
+ */
16
+ export const htmlBlockNames = [
17
+ 'address',
18
+ 'article',
19
+ 'aside',
20
+ 'base',
21
+ 'basefont',
22
+ 'blockquote',
23
+ 'body',
24
+ 'caption',
25
+ 'center',
26
+ 'col',
27
+ 'colgroup',
28
+ 'dd',
29
+ 'details',
30
+ 'dialog',
31
+ 'dir',
32
+ 'div',
33
+ 'dl',
34
+ 'dt',
35
+ 'fieldset',
36
+ 'figcaption',
37
+ 'figure',
38
+ 'footer',
39
+ 'form',
40
+ 'frame',
41
+ 'frameset',
42
+ 'h1',
43
+ 'h2',
44
+ 'h3',
45
+ 'h4',
46
+ 'h5',
47
+ 'h6',
48
+ 'head',
49
+ 'header',
50
+ 'hr',
51
+ 'html',
52
+ 'iframe',
53
+ 'legend',
54
+ 'li',
55
+ 'link',
56
+ 'main',
57
+ 'menu',
58
+ 'menuitem',
59
+ 'nav',
60
+ 'noframes',
61
+ 'ol',
62
+ 'optgroup',
63
+ 'option',
64
+ 'p',
65
+ 'param',
66
+ 'search',
67
+ 'section',
68
+ 'summary',
69
+ 'table',
70
+ 'tbody',
71
+ 'td',
72
+ 'tfoot',
73
+ 'th',
74
+ 'thead',
75
+ 'title',
76
+ 'tr',
77
+ 'track',
78
+ 'ul'
79
+ ]
80
+
81
+ /**
82
+ * List of lowercase HTML “raw” tag names.
83
+ *
84
+ * The list, when parsing HTML (flow), results in HTML that can include lines
85
+ * without exiting, until a closing tag also in this list is found (condition
86
+ * 1).
87
+ *
88
+ * This module is copied from:
89
+ * <https://spec.commonmark.org/0.30/#html-blocks>.
90
+ *
91
+ * > 👉 **Note**: `textarea` was added in `CommonMark@0.30`.
92
+ */
93
+ export const htmlRawNames = ['pre', 'script', 'style', 'textarea']
@@ -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,47 @@
1
+ {
2
+ "name": "micromark-util-html-tag-name",
3
+ "version": "2.0.1",
4
+ "description": "micromark utility with list of html tag names",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "micromark",
8
+ "util",
9
+ "utility",
10
+ "html",
11
+ "tag",
12
+ "name"
13
+ ],
14
+ "repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-util-html-tag-name",
15
+ "bugs": "https://github.com/micromark/micromark/issues",
16
+ "funding": [
17
+ {
18
+ "type": "GitHub Sponsors",
19
+ "url": "https://github.com/sponsors/unifiedjs"
20
+ },
21
+ {
22
+ "type": "OpenCollective",
23
+ "url": "https://opencollective.com/unified"
24
+ }
25
+ ],
26
+ "author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
27
+ "contributors": [
28
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
29
+ ],
30
+ "sideEffects": false,
31
+ "type": "module",
32
+ "files": [
33
+ "index.d.ts.map",
34
+ "index.d.ts",
35
+ "index.js"
36
+ ],
37
+ "exports": "./index.js",
38
+ "xo": {
39
+ "envs": [
40
+ "shared-node-browser"
41
+ ],
42
+ "prettier": true,
43
+ "rules": {
44
+ "unicorn/prefer-code-point": "off"
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Normalize an identifier (as found in references, definitions).
3
+ *
4
+ * Collapses markdown whitespace, trim, and then lower- and uppercase.
5
+ *
6
+ * Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their
7
+ * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different
8
+ * uppercase character (U+0398 (`Θ`)).
9
+ * So, to get a canonical form, we perform both lower- and uppercase.
10
+ *
11
+ * Using uppercase last makes sure keys will never interact with default
12
+ * prototypal values (such as `constructor`): nothing in the prototype of
13
+ * `Object` is uppercase.
14
+ *
15
+ * @param {string} value
16
+ * Identifier to normalize.
17
+ * @returns {string}
18
+ * Normalized identifier.
19
+ */
20
+ export function normalizeIdentifier(value) {
21
+ return value
22
+ // Collapse markdown whitespace.
23
+ .replace(/[\t\n\r ]+/g, " ")
24
+ // Trim.
25
+ .replace(/^ | $/g, '')
26
+ // Some characters are considered “uppercase”, but if their lowercase
27
+ // counterpart is uppercased will result in a different uppercase
28
+ // character.
29
+ // Hence, to get that form, we perform both lower- and uppercase.
30
+ // Upper case makes sure keys will not interact with default prototypal
31
+ // methods: no method is uppercase.
32
+ .toLowerCase().toUpperCase();
33
+ }
@@ -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,58 @@
1
+ {
2
+ "name": "micromark-util-normalize-identifier",
3
+ "version": "2.0.1",
4
+ "description": "micromark utility normalize identifiers (as found in references, definitions)",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "micromark",
8
+ "util",
9
+ "utility",
10
+ "normalize",
11
+ "id",
12
+ "identifier"
13
+ ],
14
+ "repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-util-normalize-identifier",
15
+ "bugs": "https://github.com/micromark/micromark/issues",
16
+ "funding": [
17
+ {
18
+ "type": "GitHub Sponsors",
19
+ "url": "https://github.com/sponsors/unifiedjs"
20
+ },
21
+ {
22
+ "type": "OpenCollective",
23
+ "url": "https://opencollective.com/unified"
24
+ }
25
+ ],
26
+ "author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
27
+ "contributors": [
28
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
29
+ ],
30
+ "sideEffects": false,
31
+ "type": "module",
32
+ "files": [
33
+ "dev/",
34
+ "index.d.ts.map",
35
+ "index.d.ts",
36
+ "index.js"
37
+ ],
38
+ "exports": {
39
+ "development": "./dev/index.js",
40
+ "default": "./index.js"
41
+ },
42
+ "dependencies": {
43
+ "micromark-util-symbol": "^2.0.0"
44
+ },
45
+ "scripts": {
46
+ "build": "micromark-build"
47
+ },
48
+ "xo": {
49
+ "envs": [
50
+ "shared-node-browser"
51
+ ],
52
+ "prettier": true,
53
+ "rules": {
54
+ "unicorn/prefer-code-point": "off",
55
+ "unicorn/prefer-string-replace-all": "off"
56
+ }
57
+ }
58
+ }