@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,101 @@
1
+ {
2
+ "name": "mdast-util-gfm-table",
3
+ "version": "2.0.0",
4
+ "description": "mdast extension to parse and serialize GFM tables",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "unist",
8
+ "mdast",
9
+ "mdast-util",
10
+ "util",
11
+ "utility",
12
+ "markdown",
13
+ "markup",
14
+ "table",
15
+ "row",
16
+ "column",
17
+ "cell",
18
+ "tabular",
19
+ "gfm"
20
+ ],
21
+ "repository": "syntax-tree/mdast-util-gfm-table",
22
+ "bugs": "https://github.com/syntax-tree/mdast-util-gfm-table/issues",
23
+ "funding": {
24
+ "type": "opencollective",
25
+ "url": "https://opencollective.com/unified"
26
+ },
27
+ "author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
28
+ "contributors": [
29
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
30
+ ],
31
+ "sideEffects": false,
32
+ "type": "module",
33
+ "exports": "./index.js",
34
+ "files": [
35
+ "lib/",
36
+ "index.d.ts",
37
+ "index.js"
38
+ ],
39
+ "dependencies": {
40
+ "@types/mdast": "^4.0.0",
41
+ "devlop": "^1.0.0",
42
+ "markdown-table": "^3.0.0",
43
+ "mdast-util-from-markdown": "^2.0.0",
44
+ "mdast-util-to-markdown": "^2.0.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^20.0.0",
48
+ "c8": "^8.0.0",
49
+ "micromark-extension-gfm-table": "^2.0.0",
50
+ "prettier": "^2.0.0",
51
+ "remark-cli": "^11.0.0",
52
+ "remark-preset-wooorm": "^9.0.0",
53
+ "string-width": "^6.0.0",
54
+ "type-coverage": "^2.0.0",
55
+ "typescript": "^5.0.0",
56
+ "unist-util-remove-position": "^5.0.0",
57
+ "xo": "^0.54.0"
58
+ },
59
+ "scripts": {
60
+ "prepack": "npm run build && npm run format",
61
+ "build": "tsc --build --clean && tsc --build && type-coverage",
62
+ "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
63
+ "test-api-prod": "node --conditions production test.js",
64
+ "test-api-dev": "node --conditions development test.js",
65
+ "test-api": "npm run test-api-dev && npm run test-api-prod",
66
+ "test-coverage": "c8 --100 --reporter lcov npm run test-api",
67
+ "test": "npm run build && npm run format && npm run test-coverage"
68
+ },
69
+ "prettier": {
70
+ "bracketSpacing": false,
71
+ "semi": false,
72
+ "singleQuote": true,
73
+ "tabWidth": 2,
74
+ "trailingComma": "none",
75
+ "useTabs": false
76
+ },
77
+ "remarkConfig": {
78
+ "plugins": [
79
+ "remark-preset-wooorm"
80
+ ]
81
+ },
82
+ "typeCoverage": {
83
+ "atLeast": 100,
84
+ "detail": true,
85
+ "ignoreCatch": true,
86
+ "strict": true
87
+ },
88
+ "xo": {
89
+ "overrides": [
90
+ {
91
+ "files": [
92
+ "**/*.ts"
93
+ ],
94
+ "rules": {
95
+ "@typescript-eslint/consistent-type-definitions": "off"
96
+ }
97
+ }
98
+ ],
99
+ "prettier": true
100
+ }
101
+ }
@@ -0,0 +1,4 @@
1
+ export {
2
+ gfmTaskListItemFromMarkdown,
3
+ gfmTaskListItemToMarkdown
4
+ } from './lib/index.js'
@@ -0,0 +1,141 @@
1
+ /**
2
+ * @typedef {import('mdast').ListItem} ListItem
3
+ * @typedef {import('mdast').Paragraph} Paragraph
4
+ * @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext
5
+ * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
6
+ * @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle
7
+ * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
8
+ * @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle
9
+ */
10
+
11
+ import {ok as assert} from 'devlop'
12
+ import {defaultHandlers} from 'mdast-util-to-markdown'
13
+
14
+ /**
15
+ * Create an extension for `mdast-util-from-markdown` to enable GFM task
16
+ * list items in markdown.
17
+ *
18
+ * @returns {FromMarkdownExtension}
19
+ * Extension for `mdast-util-from-markdown` to enable GFM task list items.
20
+ */
21
+ export function gfmTaskListItemFromMarkdown() {
22
+ return {
23
+ exit: {
24
+ taskListCheckValueChecked: exitCheck,
25
+ taskListCheckValueUnchecked: exitCheck,
26
+ paragraph: exitParagraphWithTaskListItem
27
+ }
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Create an extension for `mdast-util-to-markdown` to enable GFM task list
33
+ * items in markdown.
34
+ *
35
+ * @returns {ToMarkdownExtension}
36
+ * Extension for `mdast-util-to-markdown` to enable GFM task list items.
37
+ */
38
+ export function gfmTaskListItemToMarkdown() {
39
+ return {
40
+ unsafe: [{atBreak: true, character: '-', after: '[:|-]'}],
41
+ handlers: {listItem: listItemWithTaskListItem}
42
+ }
43
+ }
44
+
45
+ /**
46
+ * @this {CompileContext}
47
+ * @type {FromMarkdownHandle}
48
+ */
49
+ function exitCheck(token) {
50
+ // We’re always in a paragraph, in a list item.
51
+ const node = this.stack[this.stack.length - 2]
52
+ assert(node.type === 'listItem')
53
+ node.checked = token.type === 'taskListCheckValueChecked'
54
+ }
55
+
56
+ /**
57
+ * @this {CompileContext}
58
+ * @type {FromMarkdownHandle}
59
+ */
60
+ function exitParagraphWithTaskListItem(token) {
61
+ const parent = this.stack[this.stack.length - 2]
62
+
63
+ if (
64
+ parent &&
65
+ parent.type === 'listItem' &&
66
+ typeof parent.checked === 'boolean'
67
+ ) {
68
+ const node = this.stack[this.stack.length - 1]
69
+ assert(node.type === 'paragraph')
70
+ const head = node.children[0]
71
+
72
+ if (head && head.type === 'text') {
73
+ const siblings = parent.children
74
+ let index = -1
75
+ /** @type {Paragraph | undefined} */
76
+ let firstParaghraph
77
+
78
+ while (++index < siblings.length) {
79
+ const sibling = siblings[index]
80
+ if (sibling.type === 'paragraph') {
81
+ firstParaghraph = sibling
82
+ break
83
+ }
84
+ }
85
+
86
+ if (firstParaghraph === node) {
87
+ // Must start with a space or a tab.
88
+ head.value = head.value.slice(1)
89
+
90
+ if (head.value.length === 0) {
91
+ node.children.shift()
92
+ } else if (
93
+ node.position &&
94
+ head.position &&
95
+ typeof head.position.start.offset === 'number'
96
+ ) {
97
+ head.position.start.column++
98
+ head.position.start.offset++
99
+ node.position.start = Object.assign({}, head.position.start)
100
+ }
101
+ }
102
+ }
103
+ }
104
+
105
+ this.exit(token)
106
+ }
107
+
108
+ /**
109
+ * @type {ToMarkdownHandle}
110
+ * @param {ListItem} node
111
+ */
112
+ function listItemWithTaskListItem(node, parent, state, info) {
113
+ const head = node.children[0]
114
+ const checkable =
115
+ typeof node.checked === 'boolean' && head && head.type === 'paragraph'
116
+ const checkbox = '[' + (node.checked ? 'x' : ' ') + '] '
117
+ const tracker = state.createTracker(info)
118
+
119
+ if (checkable) {
120
+ tracker.move(checkbox)
121
+ }
122
+
123
+ let value = defaultHandlers.listItem(node, parent, state, {
124
+ ...info,
125
+ ...tracker.current()
126
+ })
127
+
128
+ if (checkable) {
129
+ value = value.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, check)
130
+ }
131
+
132
+ return value
133
+
134
+ /**
135
+ * @param {string} $0
136
+ * @returns {string}
137
+ */
138
+ function check($0) {
139
+ return $0 + checkbox
140
+ }
141
+ }
@@ -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,90 @@
1
+ {
2
+ "name": "mdast-util-gfm-task-list-item",
3
+ "version": "2.0.0",
4
+ "description": "mdast extension to parse and serialize GFM task list items",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "unist",
8
+ "mdast",
9
+ "mdast-util",
10
+ "util",
11
+ "utility",
12
+ "markdown",
13
+ "markup",
14
+ "task",
15
+ "list",
16
+ "item",
17
+ "check",
18
+ "checkbox",
19
+ "todo",
20
+ "gfm"
21
+ ],
22
+ "repository": "syntax-tree/mdast-util-gfm-task-list-item",
23
+ "bugs": "https://github.com/syntax-tree/mdast-util-gfm-task-list-item/issues",
24
+ "funding": {
25
+ "type": "opencollective",
26
+ "url": "https://opencollective.com/unified"
27
+ },
28
+ "author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
29
+ "contributors": [
30
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
31
+ ],
32
+ "sideEffects": false,
33
+ "type": "module",
34
+ "exports": "./index.js",
35
+ "files": [
36
+ "lib/",
37
+ "index.d.ts",
38
+ "index.js"
39
+ ],
40
+ "dependencies": {
41
+ "@types/mdast": "^4.0.0",
42
+ "devlop": "^1.0.0",
43
+ "mdast-util-from-markdown": "^2.0.0",
44
+ "mdast-util-to-markdown": "^2.0.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^20.0.0",
48
+ "c8": "^8.0.0",
49
+ "micromark-extension-gfm-task-list-item": "^2.0.0",
50
+ "prettier": "^2.0.0",
51
+ "remark-cli": "^11.0.0",
52
+ "remark-preset-wooorm": "^9.0.0",
53
+ "type-coverage": "^2.0.0",
54
+ "typescript": "^5.0.0",
55
+ "unist-util-remove-position": "^5.0.0",
56
+ "xo": "^0.54.0"
57
+ },
58
+ "scripts": {
59
+ "prepack": "npm run build && npm run format",
60
+ "build": "tsc --build --clean && tsc --build && type-coverage",
61
+ "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
62
+ "test-api-prod": "node --conditions production test.js",
63
+ "test-api-dev": "node --conditions development test.js",
64
+ "test-api": "npm run test-api-dev && npm run test-api-prod",
65
+ "test-coverage": "c8 --100 --reporter lcov npm run test-api",
66
+ "test": "npm run build && npm run format && npm run test-coverage"
67
+ },
68
+ "prettier": {
69
+ "bracketSpacing": false,
70
+ "semi": false,
71
+ "singleQuote": true,
72
+ "tabWidth": 2,
73
+ "trailingComma": "none",
74
+ "useTabs": false
75
+ },
76
+ "remarkConfig": {
77
+ "plugins": [
78
+ "remark-preset-wooorm"
79
+ ]
80
+ },
81
+ "typeCoverage": {
82
+ "atLeast": 100,
83
+ "detail": true,
84
+ "ignoreCatch": true,
85
+ "strict": true
86
+ },
87
+ "xo": {
88
+ "prettier": true
89
+ }
90
+ }
@@ -0,0 +1 @@
1
+ export {phrasing} from './lib/index.js'
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @typedef {import('mdast').Html} Html
3
+ * @typedef {import('mdast').PhrasingContent} PhrasingContent
4
+ */
5
+
6
+ import {convert} from 'unist-util-is'
7
+
8
+ /**
9
+ * Check if the given value is *phrasing content*.
10
+ *
11
+ * > 👉 **Note**: Excludes `html`, which can be both phrasing or flow.
12
+ *
13
+ * @param node
14
+ * Thing to check, typically `Node`.
15
+ * @returns
16
+ * Whether `value` is phrasing content.
17
+ */
18
+
19
+ export const phrasing =
20
+ /** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
21
+ (
22
+ convert([
23
+ 'break',
24
+ 'delete',
25
+ 'emphasis',
26
+ // To do: next major: removed since footnotes were added to GFM.
27
+ 'footnote',
28
+ 'footnoteReference',
29
+ 'image',
30
+ 'imageReference',
31
+ 'inlineCode',
32
+ // Enabled by `mdast-util-math`:
33
+ 'inlineMath',
34
+ 'link',
35
+ 'linkReference',
36
+ // Enabled by `mdast-util-mdx`:
37
+ 'mdxJsxTextElement',
38
+ // Enabled by `mdast-util-mdx`:
39
+ 'mdxTextExpression',
40
+ 'strong',
41
+ 'text',
42
+ // Enabled by `mdast-util-directive`:
43
+ 'textDirective'
44
+ ])
45
+ )
@@ -0,0 +1,23 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017 Titus Wormer <tituswormer@gmail.com>
4
+ Copyright (c) 2017 Victor Felder <victor@draft.li>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "mdast-util-phrasing",
3
+ "version": "4.1.0",
4
+ "description": "mdast utility to check if a node is phrasing content",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "unist",
8
+ "mdast",
9
+ "mdast=util",
10
+ "util",
11
+ "utility",
12
+ "markdown",
13
+ "phrasing"
14
+ ],
15
+ "repository": "syntax-tree/mdast-util-phrasing",
16
+ "bugs": "https://github.com/syntax-tree/mdast-util-phrasing/issues",
17
+ "funding": {
18
+ "type": "opencollective",
19
+ "url": "https://opencollective.com/unified"
20
+ },
21
+ "author": "Victor Felder <victor@draft.li> (https://draft.li)",
22
+ "contributors": [
23
+ "Victor Felder <victor@draft.li> (https://draft.li)",
24
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
25
+ ],
26
+ "sideEffects": false,
27
+ "type": "module",
28
+ "exports": "./index.js",
29
+ "files": [
30
+ "lib/",
31
+ "index.d.ts",
32
+ "index.js"
33
+ ],
34
+ "dependencies": {
35
+ "@types/mdast": "^4.0.0",
36
+ "unist-util-is": "^6.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^20.0.0",
40
+ "c8": "^9.0.0",
41
+ "prettier": "^3.0.0",
42
+ "remark-cli": "^11.0.0",
43
+ "remark-preset-wooorm": "^9.0.0",
44
+ "type-coverage": "^2.0.0",
45
+ "typescript": "^5.0.0",
46
+ "xo": "^0.56.0"
47
+ },
48
+ "scripts": {
49
+ "prepack": "npm run build && npm run format",
50
+ "build": "tsc --build --clean && tsc --build && type-coverage",
51
+ "format": "remark . -qfo && prettier . -w --log-level warn && xo --fix",
52
+ "test-api": "node --conditions development test.js",
53
+ "test-coverage": "c8 --100 --reporter lcov npm run test-api",
54
+ "test": "npm run build && npm run format && npm run test-coverage"
55
+ },
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
+ "typeCoverage": {
70
+ "atLeast": 100,
71
+ "detail": true,
72
+ "ignoreCatch": true,
73
+ "strict": true
74
+ },
75
+ "xo": {
76
+ "prettier": true
77
+ }
78
+ }
@@ -0,0 +1,3 @@
1
+ // Note: extra types exposed from `index.d.ts`.
2
+ export {toMarkdown} from './lib/index.js'
3
+ export {handle as defaultHandlers} from './lib/handle/index.js'
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @import {Options, State} from './types.js'
3
+ */
4
+
5
+ const own = {}.hasOwnProperty
6
+
7
+ /**
8
+ * Configure a base state w/ an extension.
9
+ *
10
+ * @param {State} base
11
+ * Base state to configure.
12
+ * @param {Options} extension
13
+ * Extension to apply.
14
+ * @returns {State}
15
+ * Given `base`.
16
+ */
17
+ export function configure(base, extension) {
18
+ let index = -1
19
+ /** @type {keyof Options} */
20
+ let key
21
+
22
+ // First do subextensions.
23
+ if (extension.extensions) {
24
+ while (++index < extension.extensions.length) {
25
+ configure(base, extension.extensions[index])
26
+ }
27
+ }
28
+
29
+ for (key in extension) {
30
+ if (own.call(extension, key)) {
31
+ switch (key) {
32
+ case 'extensions': {
33
+ // Empty.
34
+ break
35
+ }
36
+
37
+ /* c8 ignore next 4 */
38
+ case 'unsafe': {
39
+ list(base[key], extension[key])
40
+ break
41
+ }
42
+
43
+ case 'join': {
44
+ list(base[key], extension[key])
45
+ break
46
+ }
47
+
48
+ case 'handlers': {
49
+ map(base[key], extension[key])
50
+ break
51
+ }
52
+
53
+ default: {
54
+ // @ts-expect-error: matches.
55
+ base.options[key] = extension[key]
56
+ }
57
+ }
58
+ }
59
+ }
60
+
61
+ return base
62
+ }
63
+
64
+ /**
65
+ * Merge arrays from the extension into the base state.
66
+ *
67
+ * @template T
68
+ * Kind.
69
+ * @param {Array<T>} left
70
+ * List to merge into.
71
+ * @param {Array<T> | null | undefined} right
72
+ * List to merge from.
73
+ * @returns {undefined}
74
+ * Nothing.
75
+ */
76
+ function list(left, right) {
77
+ if (right) {
78
+ left.push(...right)
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Merge objects from the extension into the base state.
84
+ *
85
+ * @template T
86
+ * Kind.
87
+ * @param {Record<string, T>} left
88
+ * Object to merge into.
89
+ * @param {Record<string, T> | null | undefined} right
90
+ * Object to merge from.
91
+ * @returns {undefined}
92
+ * Nothing.
93
+ */
94
+ function map(left, right) {
95
+ if (right) {
96
+ Object.assign(left, right)
97
+ }
98
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @import {Blockquote, Parents} from 'mdast'
3
+ * @import {Info, Map, State} from 'mdast-util-to-markdown'
4
+ */
5
+
6
+ /**
7
+ * Serialize a blockquote node.
8
+ *
9
+ * @param {Blockquote} node
10
+ * Node to serialize.
11
+ * @param {Parents | undefined} _
12
+ * Parent node.
13
+ * @param {State} state
14
+ * Info passed around.
15
+ * @param {Info} info
16
+ * Info on surrounding context.
17
+ * @returns {string}
18
+ * Serialized markdown.
19
+ */
20
+ export function blockquote(node, _, state, info) {
21
+ const exit = state.enter('blockquote')
22
+ const tracker = state.createTracker(info)
23
+ tracker.move('> ')
24
+ tracker.shift(2)
25
+ const value = state.indentLines(
26
+ state.containerFlow(node, tracker.current()),
27
+ map
28
+ )
29
+ exit()
30
+ return value
31
+ }
32
+
33
+ /**
34
+ * Indent lines w/ blockquote markers.
35
+ *
36
+ * @type {Map}
37
+ */
38
+ function map(line, _, blank) {
39
+ return '>' + (blank ? '' : ' ') + line
40
+ }