@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,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,86 @@
1
+ {
2
+ "author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
3
+ "bugs": "https://github.com/micromark/micromark-extension-gfm-table/issues",
4
+ "contributors": [
5
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
6
+ ],
7
+ "dependencies": {
8
+ "devlop": "^1.0.0",
9
+ "micromark-factory-space": "^2.0.0",
10
+ "micromark-util-character": "^2.0.0",
11
+ "micromark-util-symbol": "^2.0.0",
12
+ "micromark-util-types": "^2.0.0"
13
+ },
14
+ "description": "micromark extension to support GFM tables",
15
+ "devDependencies": {
16
+ "@types/node": "^26.0.0",
17
+ "c8": "^12.0.0",
18
+ "create-gfm-fixtures": "^2.0.0",
19
+ "micromark": "^4.0.0",
20
+ "micromark-build": "^2.0.0",
21
+ "prettier": "^3.0.0",
22
+ "remark-cli": "^12.0.0",
23
+ "remark-preset-wooorm": "^11.0.0",
24
+ "type-coverage": "^2.0.0",
25
+ "typescript": "^6.0.0",
26
+ "xo": "^4.0.0"
27
+ },
28
+ "exports": {
29
+ "development": "./dev/index.js",
30
+ "default": "./index.js"
31
+ },
32
+ "files": [
33
+ "dev/",
34
+ "index.d.ts",
35
+ "index.js",
36
+ "lib/"
37
+ ],
38
+ "funding": {
39
+ "type": "opencollective",
40
+ "url": "https://opencollective.com/unified"
41
+ },
42
+ "keywords": [
43
+ "cell",
44
+ "column",
45
+ "gfm",
46
+ "markdown",
47
+ "micromark-extension",
48
+ "micromark",
49
+ "row",
50
+ "table",
51
+ "tabular",
52
+ "unified"
53
+ ],
54
+ "license": "MIT",
55
+ "name": "micromark-extension-gfm-table",
56
+ "prettier": {
57
+ "bracketSpacing": false,
58
+ "semi": false,
59
+ "singleQuote": true,
60
+ "tabWidth": 2,
61
+ "trailingComma": "none",
62
+ "useTabs": false
63
+ },
64
+ "remarkConfig": {
65
+ "plugins": [
66
+ "remark-preset-wooorm"
67
+ ]
68
+ },
69
+ "repository": "micromark/micromark-extension-gfm-table",
70
+ "scripts": {
71
+ "build": "tsc --build --clean && tsc --build && type-coverage && micromark-build",
72
+ "format": "remark --frail --quiet --output -- . && prettier --log-level warn --write -- . && xo --fix",
73
+ "test-api-dev": "node --conditions development test/index.js",
74
+ "test-api-prod": "node --conditions production test/index.js",
75
+ "test-api": "npm run test-api-dev && npm run test-api-prod",
76
+ "test-coverage": "c8 --100 --reporter lcov -- npm run test-api",
77
+ "test": "npm run build && npm run format && npm run test-coverage"
78
+ },
79
+ "sideEffects": false,
80
+ "typeCoverage": {
81
+ "atLeast": 100,
82
+ "strict": true
83
+ },
84
+ "type": "module",
85
+ "version": "2.1.2"
86
+ }
@@ -0,0 +1,2 @@
1
+ export { gfmTaskListItemHtml } from './lib/html.js';
2
+ export { gfmTaskListItem } from './lib/syntax.js';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @import {HtmlExtension} from 'micromark-util-types'
3
+ */
4
+
5
+ /**
6
+ * Create an HTML extension for `micromark` to support GFM task list items when
7
+ * serializing to HTML.
8
+ *
9
+ * @returns {HtmlExtension}
10
+ * Extension for `micromark` that can be passed in `htmlExtensions` to
11
+ * support GFM task list items when serializing to HTML.
12
+ */
13
+ export function gfmTaskListItemHtml() {
14
+ return {
15
+ enter: {
16
+ taskListCheck() {
17
+ this.tag('<input type="checkbox" disabled="" ');
18
+ }
19
+ },
20
+ exit: {
21
+ taskListCheck() {
22
+ this.tag('/>');
23
+ },
24
+ taskListCheckValueChecked() {
25
+ this.tag('checked="" ');
26
+ }
27
+ }
28
+ };
29
+ }
@@ -0,0 +1,158 @@
1
+ /**
2
+ * @import {Extension, State, TokenizeContext, Tokenizer} from 'micromark-util-types'
3
+ */
4
+
5
+ import { factorySpace } from 'micromark-factory-space';
6
+ import { markdownLineEnding, markdownLineEndingOrSpace, markdownSpace } from 'micromark-util-character';
7
+ const tasklistCheck = {
8
+ name: 'tasklistCheck',
9
+ tokenize: tokenizeTasklistCheck
10
+ };
11
+
12
+ /**
13
+ * Create an HTML extension for `micromark` to support GFM task list items
14
+ * syntax.
15
+ *
16
+ * @returns {Extension}
17
+ * Extension for `micromark` that can be passed in `htmlExtensions` to
18
+ * support GFM task list items when serializing to HTML.
19
+ */
20
+ export function gfmTaskListItem() {
21
+ return {
22
+ text: {
23
+ [91]: tasklistCheck
24
+ }
25
+ };
26
+ }
27
+
28
+ /**
29
+ * @this {TokenizeContext}
30
+ * @type {Tokenizer}
31
+ */
32
+ function tokenizeTasklistCheck(effects, ok, nok) {
33
+ const self = this;
34
+ return open;
35
+
36
+ /**
37
+ * At start of task list item check.
38
+ *
39
+ * ```markdown
40
+ * > | * [x] y.
41
+ * ^
42
+ * ```
43
+ *
44
+ * @type {State}
45
+ */
46
+ function open(code) {
47
+ if (
48
+ // Exit if there’s stuff before.
49
+ self.previous !== null ||
50
+ // Exit if not in the first content that is the first child of a list
51
+ // item.
52
+ !self._gfmTasklistFirstContentOfListItem) {
53
+ return nok(code);
54
+ }
55
+ effects.enter('taskListCheck');
56
+ effects.enter('taskListCheckMarker');
57
+ effects.consume(code);
58
+ effects.exit('taskListCheckMarker');
59
+ return inside;
60
+ }
61
+
62
+ /**
63
+ * In task list item check.
64
+ *
65
+ * ```markdown
66
+ * > | * [x] y.
67
+ * ^
68
+ * ```
69
+ *
70
+ * @type {State}
71
+ */
72
+ function inside(code) {
73
+ // Currently we match how GH works in files.
74
+ // To match how GH works in comments, use `markdownSpace` (`[\t ]`) instead
75
+ // of `markdownLineEndingOrSpace` (`[\t\n\r ]`).
76
+ if (markdownLineEndingOrSpace(code)) {
77
+ effects.enter('taskListCheckValueUnchecked');
78
+ effects.consume(code);
79
+ effects.exit('taskListCheckValueUnchecked');
80
+ return close;
81
+ }
82
+ if (code === 88 || code === 120) {
83
+ effects.enter('taskListCheckValueChecked');
84
+ effects.consume(code);
85
+ effects.exit('taskListCheckValueChecked');
86
+ return close;
87
+ }
88
+ return nok(code);
89
+ }
90
+
91
+ /**
92
+ * At close of task list item check.
93
+ *
94
+ * ```markdown
95
+ * > | * [x] y.
96
+ * ^
97
+ * ```
98
+ *
99
+ * @type {State}
100
+ */
101
+ function close(code) {
102
+ if (code === 93) {
103
+ effects.enter('taskListCheckMarker');
104
+ effects.consume(code);
105
+ effects.exit('taskListCheckMarker');
106
+ effects.exit('taskListCheck');
107
+ return after;
108
+ }
109
+ return nok(code);
110
+ }
111
+
112
+ /**
113
+ * @type {State}
114
+ */
115
+ function after(code) {
116
+ // EOL in paragraph means there must be something else after it.
117
+ if (markdownLineEnding(code)) {
118
+ return ok(code);
119
+ }
120
+
121
+ // Space or tab?
122
+ // Check what comes after.
123
+ if (markdownSpace(code)) {
124
+ return effects.check({
125
+ tokenize: spaceThenNonSpace
126
+ }, ok, nok)(code);
127
+ }
128
+
129
+ // EOF, or non-whitespace, both wrong.
130
+ return nok(code);
131
+ }
132
+ }
133
+
134
+ /**
135
+ * @this {TokenizeContext}
136
+ * @type {Tokenizer}
137
+ */
138
+ function spaceThenNonSpace(effects, ok, nok) {
139
+ return factorySpace(effects, after, "whitespace");
140
+
141
+ /**
142
+ * After whitespace, after task list item check.
143
+ *
144
+ * ```markdown
145
+ * > | * [x] y.
146
+ * ^
147
+ * ```
148
+ *
149
+ * @type {State}
150
+ */
151
+ function after(code) {
152
+ // EOF means there was nothing, so bad.
153
+ // EOL means there’s content after it, so good.
154
+ // Impossible to have more spaces.
155
+ // Anything else is good.
156
+ return code === null ? nok(code) : ok(code);
157
+ }
158
+ }
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2020 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,131 @@
1
+ {
2
+ "name": "micromark-extension-gfm-task-list-item",
3
+ "version": "2.1.0",
4
+ "description": "micromark extension to support GFM task list items",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "micromark",
8
+ "micromark-extension",
9
+ "task",
10
+ "list",
11
+ "item",
12
+ "check",
13
+ "checkbox",
14
+ "todo",
15
+ "gfm",
16
+ "markdown",
17
+ "unified"
18
+ ],
19
+ "repository": "micromark/micromark-extension-gfm-task-list-item",
20
+ "bugs": "https://github.com/micromark/micromark-extension-gfm-task-list-item/issues",
21
+ "funding": {
22
+ "type": "opencollective",
23
+ "url": "https://opencollective.com/unified"
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
+ "dev/",
33
+ "lib/",
34
+ "index.d.ts",
35
+ "index.js"
36
+ ],
37
+ "exports": {
38
+ "development": "./dev/index.js",
39
+ "default": "./index.js"
40
+ },
41
+ "dependencies": {
42
+ "devlop": "^1.0.0",
43
+ "micromark-factory-space": "^2.0.0",
44
+ "micromark-util-character": "^2.0.0",
45
+ "micromark-util-symbol": "^2.0.0",
46
+ "micromark-util-types": "^2.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "@types/node": "^20.0.0",
50
+ "c8": "^10.0.0",
51
+ "control-pictures": "^2.0.0",
52
+ "create-gfm-fixtures": "^1.0.0",
53
+ "micromark": "^4.0.0",
54
+ "micromark-build": "^2.0.0",
55
+ "prettier": "^3.0.0",
56
+ "remark-cli": "^12.0.0",
57
+ "remark-preset-wooorm": "^10.0.0",
58
+ "type-coverage": "^2.0.0",
59
+ "typescript": "^5.0.0",
60
+ "xo": "^0.58.0"
61
+ },
62
+ "scripts": {
63
+ "prepack": "npm run build && npm run format",
64
+ "build": "tsc --build --clean && tsc --build && type-coverage && micromark-build",
65
+ "format": "remark . -qfo && prettier . -w --log-level warn && xo --fix",
66
+ "test-api-prod": "node --conditions production test/index.js",
67
+ "test-api-dev": "node --conditions development test/index.js",
68
+ "test-api": "npm run test-api-dev && npm run test-api-prod",
69
+ "test-coverage": "c8 --100 --reporter lcov npm run test-api",
70
+ "test": "npm run build && npm run format && npm run test-coverage"
71
+ },
72
+ "prettier": {
73
+ "bracketSpacing": false,
74
+ "semi": false,
75
+ "singleQuote": true,
76
+ "tabWidth": 2,
77
+ "trailingComma": "none",
78
+ "useTabs": false
79
+ },
80
+ "remarkConfig": {
81
+ "plugins": [
82
+ "remark-preset-wooorm"
83
+ ]
84
+ },
85
+ "typeCoverage": {
86
+ "atLeast": 100,
87
+ "detail": true,
88
+ "ignoreCatch": true,
89
+ "strict": true
90
+ },
91
+ "xo": {
92
+ "prettier": true,
93
+ "rules": {
94
+ "unicorn/no-this-assignment": "off",
95
+ "unicorn/prefer-string-replace-all": "off"
96
+ },
97
+ "overrides": [
98
+ {
99
+ "files": [
100
+ "**/*.d.ts"
101
+ ],
102
+ "rules": {
103
+ "@typescript-eslint/array-type": [
104
+ "error",
105
+ {
106
+ "default": "generic"
107
+ }
108
+ ],
109
+ "@typescript-eslint/ban-types": [
110
+ "error",
111
+ {
112
+ "extendDefaults": true
113
+ }
114
+ ],
115
+ "@typescript-eslint/consistent-type-definitions": [
116
+ "error",
117
+ "interface"
118
+ ]
119
+ }
120
+ },
121
+ {
122
+ "files": [
123
+ "test/**/*.js"
124
+ ],
125
+ "rules": {
126
+ "no-await-in-loop": "off"
127
+ }
128
+ }
129
+ ]
130
+ }
131
+ }
@@ -0,0 +1,206 @@
1
+ /**
2
+ * @import {Effects, State, TokenType} from 'micromark-util-types'
3
+ */
4
+
5
+ import { asciiControl, markdownLineEndingOrSpace, markdownLineEnding } from 'micromark-util-character';
6
+ /**
7
+ * Parse destinations.
8
+ *
9
+ * ###### Examples
10
+ *
11
+ * ```markdown
12
+ * <a>
13
+ * <a\>b>
14
+ * <a b>
15
+ * <a)>
16
+ * a
17
+ * a\)b
18
+ * a(b)c
19
+ * a(b)
20
+ * ```
21
+ *
22
+ * @param {Effects} effects
23
+ * Context.
24
+ * @param {State} ok
25
+ * State switched to when successful.
26
+ * @param {State} nok
27
+ * State switched to when unsuccessful.
28
+ * @param {TokenType} type
29
+ * Type for whole (`<a>` or `b`).
30
+ * @param {TokenType} literalType
31
+ * Type when enclosed (`<a>`).
32
+ * @param {TokenType} literalMarkerType
33
+ * Type for enclosing (`<` and `>`).
34
+ * @param {TokenType} rawType
35
+ * Type when not enclosed (`b`).
36
+ * @param {TokenType} stringType
37
+ * Type for the value (`a` or `b`).
38
+ * @param {number | undefined} [max=Infinity]
39
+ * Depth of nested parens (inclusive).
40
+ * @returns {State}
41
+ * Start state.
42
+ */
43
+ export function factoryDestination(effects, ok, nok, type, literalType, literalMarkerType, rawType, stringType, max) {
44
+ const limit = max || Number.POSITIVE_INFINITY;
45
+ let balance = 0;
46
+ return start;
47
+
48
+ /**
49
+ * Start of destination.
50
+ *
51
+ * ```markdown
52
+ * > | <aa>
53
+ * ^
54
+ * > | aa
55
+ * ^
56
+ * ```
57
+ *
58
+ * @type {State}
59
+ */
60
+ function start(code) {
61
+ if (code === 60) {
62
+ effects.enter(type);
63
+ effects.enter(literalType);
64
+ effects.enter(literalMarkerType);
65
+ effects.consume(code);
66
+ effects.exit(literalMarkerType);
67
+ return enclosedBefore;
68
+ }
69
+
70
+ // ASCII control, space, closing paren.
71
+ if (code === null || code === 32 || code === 41 || asciiControl(code)) {
72
+ return nok(code);
73
+ }
74
+ effects.enter(type);
75
+ effects.enter(rawType);
76
+ effects.enter(stringType);
77
+ effects.enter("chunkString", {
78
+ contentType: "string"
79
+ });
80
+ return raw(code);
81
+ }
82
+
83
+ /**
84
+ * After `<`, at an enclosed destination.
85
+ *
86
+ * ```markdown
87
+ * > | <aa>
88
+ * ^
89
+ * ```
90
+ *
91
+ * @type {State}
92
+ */
93
+ function enclosedBefore(code) {
94
+ if (code === 62) {
95
+ effects.enter(literalMarkerType);
96
+ effects.consume(code);
97
+ effects.exit(literalMarkerType);
98
+ effects.exit(literalType);
99
+ effects.exit(type);
100
+ return ok;
101
+ }
102
+ effects.enter(stringType);
103
+ effects.enter("chunkString", {
104
+ contentType: "string"
105
+ });
106
+ return enclosed(code);
107
+ }
108
+
109
+ /**
110
+ * In enclosed destination.
111
+ *
112
+ * ```markdown
113
+ * > | <aa>
114
+ * ^
115
+ * ```
116
+ *
117
+ * @type {State}
118
+ */
119
+ function enclosed(code) {
120
+ if (code === 62) {
121
+ effects.exit("chunkString");
122
+ effects.exit(stringType);
123
+ return enclosedBefore(code);
124
+ }
125
+ if (code === null || code === 60 || markdownLineEnding(code)) {
126
+ return nok(code);
127
+ }
128
+ effects.consume(code);
129
+ return code === 92 ? enclosedEscape : enclosed;
130
+ }
131
+
132
+ /**
133
+ * After `\`, at a special character.
134
+ *
135
+ * ```markdown
136
+ * > | <a\*a>
137
+ * ^
138
+ * ```
139
+ *
140
+ * @type {State}
141
+ */
142
+ function enclosedEscape(code) {
143
+ if (code === 60 || code === 62 || code === 92) {
144
+ effects.consume(code);
145
+ return enclosed;
146
+ }
147
+ return enclosed(code);
148
+ }
149
+
150
+ /**
151
+ * In raw destination.
152
+ *
153
+ * ```markdown
154
+ * > | aa
155
+ * ^
156
+ * ```
157
+ *
158
+ * @type {State}
159
+ */
160
+ function raw(code) {
161
+ if (!balance && (code === null || code === 41 || markdownLineEndingOrSpace(code))) {
162
+ effects.exit("chunkString");
163
+ effects.exit(stringType);
164
+ effects.exit(rawType);
165
+ effects.exit(type);
166
+ return ok(code);
167
+ }
168
+ if (balance < limit && code === 40) {
169
+ effects.consume(code);
170
+ balance++;
171
+ return raw;
172
+ }
173
+ if (code === 41) {
174
+ effects.consume(code);
175
+ balance--;
176
+ return raw;
177
+ }
178
+
179
+ // ASCII control (but *not* `\0`) and space and `(`.
180
+ // Note: in `markdown-rs`, `\0` exists in codes, in `micromark-js` it
181
+ // doesn’t.
182
+ if (code === null || code === 32 || code === 40 || asciiControl(code)) {
183
+ return nok(code);
184
+ }
185
+ effects.consume(code);
186
+ return code === 92 ? rawEscape : raw;
187
+ }
188
+
189
+ /**
190
+ * After `\`, at special character.
191
+ *
192
+ * ```markdown
193
+ * > | a\*a
194
+ * ^
195
+ * ```
196
+ *
197
+ * @type {State}
198
+ */
199
+ function rawEscape(code) {
200
+ if (code === 40 || code === 41 || code === 92) {
201
+ effects.consume(code);
202
+ return raw;
203
+ }
204
+ return raw(code);
205
+ }
206
+ }
@@ -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.