@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,58 @@
1
+ {
2
+ "name": "micromark-factory-title",
3
+ "version": "2.0.1",
4
+ "description": "micromark factory to parse markdown titles (found in resources, definitions)",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "micromark",
8
+ "factory",
9
+ "title"
10
+ ],
11
+ "repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-factory-title",
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
+ "index.d.ts.map",
32
+ "index.d.ts",
33
+ "index.js"
34
+ ],
35
+ "exports": {
36
+ "development": "./dev/index.js",
37
+ "default": "./index.js"
38
+ },
39
+ "dependencies": {
40
+ "micromark-factory-space": "^2.0.0",
41
+ "micromark-util-character": "^2.0.0",
42
+ "micromark-util-symbol": "^2.0.0",
43
+ "micromark-util-types": "^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
+ "max-params": "off",
55
+ "unicorn/prefer-code-point": "off"
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @import {Effects, State} from 'micromark-util-types'
3
+ */
4
+
5
+ import { factorySpace } from 'micromark-factory-space';
6
+ import { markdownLineEnding, markdownSpace } from 'micromark-util-character';
7
+ /**
8
+ * Parse spaces and tabs.
9
+ *
10
+ * There is no `nok` parameter:
11
+ *
12
+ * * line endings or spaces in markdown are often optional, in which case this
13
+ * factory can be used and `ok` will be switched to whether spaces were found
14
+ * or not
15
+ * * one line ending or space can be detected with
16
+ * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace`
17
+ *
18
+ * @param {Effects} effects
19
+ * Context.
20
+ * @param {State} ok
21
+ * State switched to when successful.
22
+ * @returns {State}
23
+ * Start state.
24
+ */
25
+ export function factoryWhitespace(effects, ok) {
26
+ /** @type {boolean} */
27
+ let seen;
28
+ return start;
29
+
30
+ /** @type {State} */
31
+ function start(code) {
32
+ if (markdownLineEnding(code)) {
33
+ effects.enter("lineEnding");
34
+ effects.consume(code);
35
+ effects.exit("lineEnding");
36
+ seen = true;
37
+ return start;
38
+ }
39
+ if (markdownSpace(code)) {
40
+ return factorySpace(effects, start, seen ? "linePrefix" : "lineSuffix")(code);
41
+ }
42
+ return ok(code);
43
+ }
44
+ }
@@ -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,57 @@
1
+ {
2
+ "name": "micromark-factory-whitespace",
3
+ "version": "2.0.1",
4
+ "description": "micromark factory to parse markdown whitespace (found in lots of places)",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "micromark",
8
+ "factory",
9
+ "whitespace"
10
+ ],
11
+ "repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-factory-whitespace",
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
+ "index.d.ts.map",
32
+ "index.d.ts",
33
+ "index.js"
34
+ ],
35
+ "exports": {
36
+ "development": "./dev/index.js",
37
+ "default": "./index.js"
38
+ },
39
+ "dependencies": {
40
+ "micromark-factory-space": "^2.0.0",
41
+ "micromark-util-character": "^2.0.0",
42
+ "micromark-util-symbol": "^2.0.0",
43
+ "micromark-util-types": "^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
+ }
56
+ }
57
+ }
@@ -0,0 +1,246 @@
1
+ /**
2
+ * @import {Code} from 'micromark-util-types'
3
+ */
4
+
5
+ /**
6
+ * Check whether the character code represents an ASCII alpha (`a` through `z`,
7
+ * case insensitive).
8
+ *
9
+ * An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha.
10
+ *
11
+ * An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`)
12
+ * to U+005A (`Z`).
13
+ *
14
+ * An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`)
15
+ * to U+007A (`z`).
16
+ *
17
+ * @param code
18
+ * Code.
19
+ * @returns {boolean}
20
+ * Whether it matches.
21
+ */
22
+ export const asciiAlpha = regexCheck(/[A-Za-z]/);
23
+
24
+ /**
25
+ * Check whether the character code represents an ASCII alphanumeric (`a`
26
+ * through `z`, case insensitive, or `0` through `9`).
27
+ *
28
+ * An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha
29
+ * (see `asciiAlpha`).
30
+ *
31
+ * @param code
32
+ * Code.
33
+ * @returns {boolean}
34
+ * Whether it matches.
35
+ */
36
+ export const asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
37
+
38
+ /**
39
+ * Check whether the character code represents an ASCII atext.
40
+ *
41
+ * atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in
42
+ * the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`),
43
+ * U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F
44
+ * SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E
45
+ * CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE
46
+ * (`{`) to U+007E TILDE (`~`).
47
+ *
48
+ * See:
49
+ * **\[RFC5322]**:
50
+ * [Internet Message Format](https://tools.ietf.org/html/rfc5322).
51
+ * P. Resnick.
52
+ * IETF.
53
+ *
54
+ * @param code
55
+ * Code.
56
+ * @returns {boolean}
57
+ * Whether it matches.
58
+ */
59
+ export const asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
60
+
61
+ /**
62
+ * Check whether a character code is an ASCII control character.
63
+ *
64
+ * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL)
65
+ * to U+001F (US), or U+007F (DEL).
66
+ *
67
+ * @param {Code} code
68
+ * Code.
69
+ * @returns {boolean}
70
+ * Whether it matches.
71
+ */
72
+ export function asciiControl(code) {
73
+ return (
74
+ // Special whitespace codes (which have negative values), C0 and Control
75
+ // character DEL
76
+ code !== null && (code < 32 || code === 127)
77
+ );
78
+ }
79
+
80
+ /**
81
+ * Check whether the character code represents an ASCII digit (`0` through `9`).
82
+ *
83
+ * An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to
84
+ * U+0039 (`9`).
85
+ *
86
+ * @param code
87
+ * Code.
88
+ * @returns {boolean}
89
+ * Whether it matches.
90
+ */
91
+ export const asciiDigit = regexCheck(/\d/);
92
+
93
+ /**
94
+ * Check whether the character code represents an ASCII hex digit (`a` through
95
+ * `f`, case insensitive, or `0` through `9`).
96
+ *
97
+ * An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex
98
+ * digit, or an ASCII lower hex digit.
99
+ *
100
+ * An **ASCII upper hex digit** is a character in the inclusive range U+0041
101
+ * (`A`) to U+0046 (`F`).
102
+ *
103
+ * An **ASCII lower hex digit** is a character in the inclusive range U+0061
104
+ * (`a`) to U+0066 (`f`).
105
+ *
106
+ * @param code
107
+ * Code.
108
+ * @returns {boolean}
109
+ * Whether it matches.
110
+ */
111
+ export const asciiHexDigit = regexCheck(/[\dA-Fa-f]/);
112
+
113
+ /**
114
+ * Check whether the character code represents ASCII punctuation.
115
+ *
116
+ * An **ASCII punctuation** is a character in the inclusive ranges U+0021
117
+ * EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT
118
+ * SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT
119
+ * (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`).
120
+ *
121
+ * @param code
122
+ * Code.
123
+ * @returns {boolean}
124
+ * Whether it matches.
125
+ */
126
+ export const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);
127
+
128
+ /**
129
+ * Check whether a character code is a markdown line ending.
130
+ *
131
+ * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN
132
+ * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).
133
+ *
134
+ * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE
135
+ * RETURN (CR) are replaced by these virtual characters depending on whether
136
+ * they occurred together.
137
+ *
138
+ * @param {Code} code
139
+ * Code.
140
+ * @returns {boolean}
141
+ * Whether it matches.
142
+ */
143
+ export function markdownLineEnding(code) {
144
+ return code !== null && code < -2;
145
+ }
146
+
147
+ /**
148
+ * Check whether a character code is a markdown line ending (see
149
+ * `markdownLineEnding`) or markdown space (see `markdownSpace`).
150
+ *
151
+ * @param {Code} code
152
+ * Code.
153
+ * @returns {boolean}
154
+ * Whether it matches.
155
+ */
156
+ export function markdownLineEndingOrSpace(code) {
157
+ return code !== null && (code < 0 || code === 32);
158
+ }
159
+
160
+ /**
161
+ * Check whether a character code is a markdown space.
162
+ *
163
+ * A **markdown space** is the concrete character U+0020 SPACE (SP) and the
164
+ * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).
165
+ *
166
+ * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is
167
+ * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL
168
+ * SPACE (VS) characters, depending on the column at which the tab occurred.
169
+ *
170
+ * @param {Code} code
171
+ * Code.
172
+ * @returns {boolean}
173
+ * Whether it matches.
174
+ */
175
+ export function markdownSpace(code) {
176
+ return code === -2 || code === -1 || code === 32;
177
+ }
178
+
179
+ // Size note: removing ASCII from the regex and using `asciiPunctuation` here
180
+ // In fact adds to the bundle size.
181
+ /**
182
+ * Check whether the character code represents Unicode punctuation.
183
+ *
184
+ * A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation,
185
+ * Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf`
186
+ * (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po`
187
+ * (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII
188
+ * punctuation (see `asciiPunctuation`).
189
+ *
190
+ * See:
191
+ * **\[UNICODE]**:
192
+ * [The Unicode Standard](https://www.unicode.org/versions/).
193
+ * Unicode Consortium.
194
+ *
195
+ * @param code
196
+ * Code.
197
+ * @returns
198
+ * Whether it matches.
199
+ */
200
+ export const unicodePunctuation = regexCheck(/\p{P}|\p{S}/u);
201
+
202
+ /**
203
+ * Check whether the character code represents Unicode whitespace.
204
+ *
205
+ * Note that this does handle micromark specific markdown whitespace characters.
206
+ * See `markdownLineEndingOrSpace` to check that.
207
+ *
208
+ * A **Unicode whitespace** is a character in the Unicode `Zs` (Separator,
209
+ * Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF),
210
+ * U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**).
211
+ *
212
+ * See:
213
+ * **\[UNICODE]**:
214
+ * [The Unicode Standard](https://www.unicode.org/versions/).
215
+ * Unicode Consortium.
216
+ *
217
+ * @param code
218
+ * Code.
219
+ * @returns
220
+ * Whether it matches.
221
+ */
222
+ export const unicodeWhitespace = regexCheck(/\s/);
223
+
224
+ /**
225
+ * Create a code check from a regex.
226
+ *
227
+ * @param {RegExp} regex
228
+ * Expression.
229
+ * @returns {(code: Code) => boolean}
230
+ * Check.
231
+ */
232
+ function regexCheck(regex) {
233
+ return check;
234
+
235
+ /**
236
+ * Check whether a code matches the bound regex.
237
+ *
238
+ * @param {Code} code
239
+ * Character code.
240
+ * @returns {boolean}
241
+ * Whether the character code matches the bound regex.
242
+ */
243
+ function check(code) {
244
+ return code !== null && code > -1 && regex.test(String.fromCharCode(code));
245
+ }
246
+ }
@@ -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,57 @@
1
+ {
2
+ "name": "micromark-util-character",
3
+ "version": "2.1.1",
4
+ "description": "micromark utility to handle character codes",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "micromark",
8
+ "util",
9
+ "utility",
10
+ "character"
11
+ ],
12
+ "repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-util-character",
13
+ "bugs": "https://github.com/micromark/micromark/issues",
14
+ "funding": [
15
+ {
16
+ "type": "GitHub Sponsors",
17
+ "url": "https://github.com/sponsors/unifiedjs"
18
+ },
19
+ {
20
+ "type": "OpenCollective",
21
+ "url": "https://opencollective.com/unified"
22
+ }
23
+ ],
24
+ "author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
25
+ "contributors": [
26
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
27
+ ],
28
+ "sideEffects": false,
29
+ "type": "module",
30
+ "files": [
31
+ "dev/",
32
+ "lib/",
33
+ "index.d.ts.map",
34
+ "index.d.ts",
35
+ "index.js"
36
+ ],
37
+ "exports": {
38
+ "development": "./dev/index.js",
39
+ "default": "./index.js"
40
+ },
41
+ "dependencies": {
42
+ "micromark-util-symbol": "^2.0.0",
43
+ "micromark-util-types": "^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
+ }
56
+ }
57
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Like `Array#splice`, but smarter for giant arrays.
3
+ *
4
+ * `Array#splice` takes all items to be inserted as individual argument which
5
+ * causes a stack overflow in V8 when trying to insert 100k items for instance.
6
+ *
7
+ * Otherwise, this does not return the removed items, and takes `items` as an
8
+ * array instead of rest parameters.
9
+ *
10
+ * @template {unknown} T
11
+ * Item type.
12
+ * @param {Array<T>} list
13
+ * List to operate on.
14
+ * @param {number} start
15
+ * Index to remove/insert at (can be negative).
16
+ * @param {number} remove
17
+ * Number of items to remove.
18
+ * @param {Array<T>} items
19
+ * Items to inject into `list`.
20
+ * @returns {undefined}
21
+ * Nothing.
22
+ */
23
+ export function splice(list, start, remove, items) {
24
+ const end = list.length;
25
+ let chunkStart = 0;
26
+ /** @type {Array<unknown>} */
27
+ let parameters;
28
+
29
+ // Make start between zero and `end` (included).
30
+ if (start < 0) {
31
+ start = -start > end ? 0 : end + start;
32
+ } else {
33
+ start = start > end ? end : start;
34
+ }
35
+ remove = remove > 0 ? remove : 0;
36
+
37
+ // No need to chunk the items if there’s only a couple (10k) items.
38
+ if (items.length < 10000) {
39
+ parameters = Array.from(items);
40
+ parameters.unshift(start, remove);
41
+ // @ts-expect-error Hush, it’s fine.
42
+ list.splice(...parameters);
43
+ } else {
44
+ // Delete `remove` items starting from `start`
45
+ if (remove) list.splice(start, remove);
46
+
47
+ // Insert the items in chunks to not cause stack overflows.
48
+ while (chunkStart < items.length) {
49
+ parameters = items.slice(chunkStart, chunkStart + 10000);
50
+ parameters.unshift(start, 0);
51
+ // @ts-expect-error Hush, it’s fine.
52
+ list.splice(...parameters);
53
+ chunkStart += 10000;
54
+ start += 10000;
55
+ }
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Append `items` (an array) at the end of `list` (another array).
61
+ * When `list` was empty, returns `items` instead.
62
+ *
63
+ * This prevents a potentially expensive operation when `list` is empty,
64
+ * and adds items in batches to prevent V8 from hanging.
65
+ *
66
+ * @template {unknown} T
67
+ * Item type.
68
+ * @param {Array<T>} list
69
+ * List to operate on.
70
+ * @param {Array<T>} items
71
+ * Items to add to `list`.
72
+ * @returns {Array<T>}
73
+ * Either `list` or `items`.
74
+ */
75
+ export function push(list, items) {
76
+ if (list.length > 0) {
77
+ splice(list, list.length, 0, items);
78
+ return list;
79
+ }
80
+ return items;
81
+ }
@@ -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,57 @@
1
+ {
2
+ "name": "micromark-util-chunked",
3
+ "version": "2.0.1",
4
+ "description": "micromark utility to splice and push with giant arrays",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "micromark",
8
+ "util",
9
+ "utility",
10
+ "chunk",
11
+ "splice",
12
+ "push"
13
+ ],
14
+ "repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-util-chunked",
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
+ }
56
+ }
57
+ }