@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.
- package/LICENSE +21 -0
- package/THIRD_PARTY_NOTICES.txt +13651 -0
- package/dist/directive.d.ts +40 -0
- package/dist/editing.d.ts +46 -0
- package/dist/enrichment.d.ts +5 -0
- package/dist/expression.d.ts +26 -0
- package/dist/image-destinations.d.ts +3 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +10118 -0
- package/dist/parser.d.ts +40 -0
- package/dist/registry.d.ts +144 -0
- package/dist/source.d.ts +28 -0
- package/package.json +280 -3
- package/parser-provenance.json +1419 -0
- package/patches/README.md +5 -0
- package/patches/micromark.patch +84 -0
- package/vendor/@noble/hashes/LICENSE +21 -0
- package/vendor/@noble/hashes/_md.js +209 -0
- package/vendor/@noble/hashes/_u64.js +77 -0
- package/vendor/@noble/hashes/package.json +91 -0
- package/vendor/@noble/hashes/sha2.js +446 -0
- package/vendor/@noble/hashes/utils.js +687 -0
- package/vendor/character-entities/index.js +2132 -0
- package/vendor/character-entities/license +22 -0
- package/vendor/character-entities/package.json +78 -0
- package/vendor/decode-named-character-reference/index.js +19 -0
- package/vendor/decode-named-character-reference/license +22 -0
- package/vendor/decode-named-character-reference/package.json +90 -0
- package/vendor/devlop/lib/default.js +9 -0
- package/vendor/devlop/license +22 -0
- package/vendor/devlop/package.json +80 -0
- package/vendor/longest-streak/index.js +36 -0
- package/vendor/longest-streak/license +22 -0
- package/vendor/longest-streak/package.json +73 -0
- package/vendor/markdown-table/index.js +393 -0
- package/vendor/markdown-table/license +22 -0
- package/vendor/markdown-table/package.json +77 -0
- package/vendor/mdast-util-from-markdown/index.js +2 -0
- package/vendor/mdast-util-from-markdown/lib/index.js +1270 -0
- package/vendor/mdast-util-from-markdown/license +22 -0
- package/vendor/mdast-util-from-markdown/package.json +98 -0
- package/vendor/mdast-util-gfm-strikethrough/index.js +5 -0
- package/vendor/mdast-util-gfm-strikethrough/lib/index.js +133 -0
- package/vendor/mdast-util-gfm-strikethrough/license +22 -0
- package/vendor/mdast-util-gfm-strikethrough/package.json +84 -0
- package/vendor/mdast-util-gfm-table/index.js +2 -0
- package/vendor/mdast-util-gfm-table/lib/index.js +300 -0
- package/vendor/mdast-util-gfm-table/license +22 -0
- package/vendor/mdast-util-gfm-table/package.json +101 -0
- package/vendor/mdast-util-gfm-task-list-item/index.js +4 -0
- package/vendor/mdast-util-gfm-task-list-item/lib/index.js +141 -0
- package/vendor/mdast-util-gfm-task-list-item/license +22 -0
- package/vendor/mdast-util-gfm-task-list-item/package.json +90 -0
- package/vendor/mdast-util-phrasing/index.js +1 -0
- package/vendor/mdast-util-phrasing/lib/index.js +45 -0
- package/vendor/mdast-util-phrasing/license +23 -0
- package/vendor/mdast-util-phrasing/package.json +78 -0
- package/vendor/mdast-util-to-markdown/index.js +3 -0
- package/vendor/mdast-util-to-markdown/lib/configure.js +98 -0
- package/vendor/mdast-util-to-markdown/lib/handle/blockquote.js +40 -0
- package/vendor/mdast-util-to-markdown/lib/handle/break.js +41 -0
- package/vendor/mdast-util-to-markdown/lib/handle/code.js +86 -0
- package/vendor/mdast-util-to-markdown/lib/handle/definition.js +83 -0
- package/vendor/mdast-util-to-markdown/lib/handle/emphasis.js +67 -0
- package/vendor/mdast-util-to-markdown/lib/handle/heading.js +84 -0
- package/vendor/mdast-util-to-markdown/lib/handle/html.js +27 -0
- package/vendor/mdast-util-to-markdown/lib/handle/image-reference.js +78 -0
- package/vendor/mdast-util-to-markdown/lib/handle/image.js +92 -0
- package/vendor/mdast-util-to-markdown/lib/handle/index.js +45 -0
- package/vendor/mdast-util-to-markdown/lib/handle/inline-code.js +86 -0
- package/vendor/mdast-util-to-markdown/lib/handle/link-reference.js +78 -0
- package/vendor/mdast-util-to-markdown/lib/handle/link.js +129 -0
- package/vendor/mdast-util-to-markdown/lib/handle/list-item.js +73 -0
- package/vendor/mdast-util-to-markdown/lib/handle/list.js +107 -0
- package/vendor/mdast-util-to-markdown/lib/handle/paragraph.js +27 -0
- package/vendor/mdast-util-to-markdown/lib/handle/root.js +34 -0
- package/vendor/mdast-util-to-markdown/lib/handle/strong.js +67 -0
- package/vendor/mdast-util-to-markdown/lib/handle/text.js +30 -0
- package/vendor/mdast-util-to-markdown/lib/handle/thematic-break.js +27 -0
- package/vendor/mdast-util-to-markdown/lib/index.js +213 -0
- package/vendor/mdast-util-to-markdown/lib/join.js +56 -0
- package/vendor/mdast-util-to-markdown/lib/unsafe.js +160 -0
- package/vendor/mdast-util-to-markdown/lib/util/association.js +33 -0
- package/vendor/mdast-util-to-markdown/lib/util/character.js +32 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-bullet-ordered.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-bullet-other.js +42 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-bullet.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-emphasis.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-fence.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-list-item-indent.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-quote.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-rule-repetition.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-rule.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-strong.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/compile-pattern.js +30 -0
- package/vendor/mdast-util-to-markdown/lib/util/container-flow.js +93 -0
- package/vendor/mdast-util-to-markdown/lib/util/container-phrasing.js +704 -0
- package/vendor/mdast-util-to-markdown/lib/util/encode-character-reference.js +11 -0
- package/vendor/mdast-util-to-markdown/lib/util/encode-info.js +82 -0
- package/vendor/mdast-util-to-markdown/lib/util/format-code-as-indented.js +27 -0
- package/vendor/mdast-util-to-markdown/lib/util/format-heading-as-setext.js +39 -0
- package/vendor/mdast-util-to-markdown/lib/util/format-link-as-autolink.js +39 -0
- package/vendor/mdast-util-to-markdown/lib/util/html-kind.js +63 -0
- package/vendor/mdast-util-to-markdown/lib/util/indent-lines.js +40 -0
- package/vendor/mdast-util-to-markdown/lib/util/pattern-in-scope.js +52 -0
- package/vendor/mdast-util-to-markdown/lib/util/safe.js +263 -0
- package/vendor/mdast-util-to-markdown/lib/util/track.js +55 -0
- package/vendor/mdast-util-to-markdown/license +22 -0
- package/vendor/mdast-util-to-markdown/package.json +88 -0
- package/vendor/mdast-util-to-string/index.js +5 -0
- package/vendor/mdast-util-to-string/lib/index.js +108 -0
- package/vendor/mdast-util-to-string/license +22 -0
- package/vendor/mdast-util-to-string/package.json +78 -0
- package/vendor/micromark/index.js +60 -0
- package/vendor/micromark/lib/compile.js +1068 -0
- package/vendor/micromark/lib/constructs.js +85 -0
- package/vendor/micromark/lib/create-tokenizer.js +615 -0
- package/vendor/micromark/lib/initialize/content.js +79 -0
- package/vendor/micromark/lib/initialize/document.js +370 -0
- package/vendor/micromark/lib/initialize/flow.js +58 -0
- package/vendor/micromark/lib/initialize/text.js +216 -0
- package/vendor/micromark/lib/parse.js +56 -0
- package/vendor/micromark/lib/postprocess.js +18 -0
- package/vendor/micromark/lib/preprocess.js +112 -0
- package/vendor/micromark/license +22 -0
- package/vendor/micromark/package.json +87 -0
- package/vendor/micromark-core-commonmark/index.js +22 -0
- package/vendor/micromark-core-commonmark/lib/attention.js +231 -0
- package/vendor/micromark-core-commonmark/lib/autolink.js +233 -0
- package/vendor/micromark-core-commonmark/lib/blank-line.js +61 -0
- package/vendor/micromark-core-commonmark/lib/block-quote.js +143 -0
- package/vendor/micromark-core-commonmark/lib/character-escape.js +64 -0
- package/vendor/micromark-core-commonmark/lib/character-reference.js +149 -0
- package/vendor/micromark-core-commonmark/lib/code-fenced.js +422 -0
- package/vendor/micromark-core-commonmark/lib/code-indented.js +159 -0
- package/vendor/micromark-core-commonmark/lib/code-text.js +225 -0
- package/vendor/micromark-core-commonmark/lib/content.js +163 -0
- package/vendor/micromark-core-commonmark/lib/definition.js +254 -0
- package/vendor/micromark-core-commonmark/lib/hard-break-escape.js +60 -0
- package/vendor/micromark-core-commonmark/lib/heading-atx.js +191 -0
- package/vendor/micromark-core-commonmark/lib/html-flow.js +827 -0
- package/vendor/micromark-core-commonmark/lib/html-text.js +678 -0
- package/vendor/micromark-core-commonmark/lib/label-end.js +561 -0
- package/vendor/micromark-core-commonmark/lib/label-start-image.js +110 -0
- package/vendor/micromark-core-commonmark/lib/label-start-link.js +63 -0
- package/vendor/micromark-core-commonmark/lib/line-ending.js +33 -0
- package/vendor/micromark-core-commonmark/lib/list.js +213 -0
- package/vendor/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
- package/vendor/micromark-core-commonmark/lib/setext-underline.js +187 -0
- package/vendor/micromark-core-commonmark/lib/thematic-break.js +102 -0
- package/vendor/micromark-core-commonmark/license +22 -0
- package/vendor/micromark-core-commonmark/package.json +62 -0
- package/vendor/micromark-extension-gfm-strikethrough/index.js +3 -0
- package/vendor/micromark-extension-gfm-strikethrough/lib/html.js +26 -0
- package/vendor/micromark-extension-gfm-strikethrough/lib/syntax.js +142 -0
- package/vendor/micromark-extension-gfm-strikethrough/license +22 -0
- package/vendor/micromark-extension-gfm-strikethrough/package.json +129 -0
- package/vendor/micromark-extension-gfm-table/index.js +2 -0
- package/vendor/micromark-extension-gfm-table/lib/edit-map.js +222 -0
- package/vendor/micromark-extension-gfm-table/lib/html.js +135 -0
- package/vendor/micromark-extension-gfm-table/lib/infer.js +52 -0
- package/vendor/micromark-extension-gfm-table/lib/syntax.js +846 -0
- package/vendor/micromark-extension-gfm-table/license +22 -0
- package/vendor/micromark-extension-gfm-table/package.json +86 -0
- package/vendor/micromark-extension-gfm-task-list-item/index.js +2 -0
- package/vendor/micromark-extension-gfm-task-list-item/lib/html.js +29 -0
- package/vendor/micromark-extension-gfm-task-list-item/lib/syntax.js +158 -0
- package/vendor/micromark-extension-gfm-task-list-item/license +22 -0
- package/vendor/micromark-extension-gfm-task-list-item/package.json +131 -0
- package/vendor/micromark-factory-destination/index.js +206 -0
- package/vendor/micromark-factory-destination/license +22 -0
- package/vendor/micromark-factory-destination/package.json +57 -0
- package/vendor/micromark-factory-label/index.js +148 -0
- package/vendor/micromark-factory-label/license +22 -0
- package/vendor/micromark-factory-label/package.json +60 -0
- package/vendor/micromark-factory-space/index.js +116 -0
- package/vendor/micromark-factory-space/license +22 -0
- package/vendor/micromark-factory-space/package.json +46 -0
- package/vendor/micromark-factory-title/index.js +158 -0
- package/vendor/micromark-factory-title/license +22 -0
- package/vendor/micromark-factory-title/package.json +58 -0
- package/vendor/micromark-factory-whitespace/index.js +44 -0
- package/vendor/micromark-factory-whitespace/license +22 -0
- package/vendor/micromark-factory-whitespace/package.json +57 -0
- package/vendor/micromark-util-character/index.js +246 -0
- package/vendor/micromark-util-character/license +22 -0
- package/vendor/micromark-util-character/package.json +57 -0
- package/vendor/micromark-util-chunked/index.js +81 -0
- package/vendor/micromark-util-chunked/license +22 -0
- package/vendor/micromark-util-chunked/package.json +57 -0
- package/vendor/micromark-util-classify-character/index.js +27 -0
- package/vendor/micromark-util-classify-character/license +22 -0
- package/vendor/micromark-util-classify-character/package.json +59 -0
- package/vendor/micromark-util-combine-extensions/index.js +143 -0
- package/vendor/micromark-util-combine-extensions/license +22 -0
- package/vendor/micromark-util-combine-extensions/package.json +52 -0
- package/vendor/micromark-util-decode-numeric-character-reference/index.js +32 -0
- package/vendor/micromark-util-decode-numeric-character-reference/license +22 -0
- package/vendor/micromark-util-decode-numeric-character-reference/package.json +59 -0
- package/vendor/micromark-util-decode-string/index.js +45 -0
- package/vendor/micromark-util-decode-string/license +22 -0
- package/vendor/micromark-util-decode-string/package.json +63 -0
- package/vendor/micromark-util-edit-map/index.js +225 -0
- package/vendor/micromark-util-edit-map/license +22 -0
- package/vendor/micromark-util-edit-map/package.json +48 -0
- package/vendor/micromark-util-encode/index.js +33 -0
- package/vendor/micromark-util-encode/license +22 -0
- package/vendor/micromark-util-encode/package.json +47 -0
- package/vendor/micromark-util-html-tag-name/index.js +93 -0
- package/vendor/micromark-util-html-tag-name/license +22 -0
- package/vendor/micromark-util-html-tag-name/package.json +47 -0
- package/vendor/micromark-util-normalize-identifier/index.js +33 -0
- package/vendor/micromark-util-normalize-identifier/license +22 -0
- package/vendor/micromark-util-normalize-identifier/package.json +58 -0
- package/vendor/micromark-util-resolve-all/index.js +32 -0
- package/vendor/micromark-util-resolve-all/license +22 -0
- package/vendor/micromark-util-resolve-all/package.json +48 -0
- package/vendor/micromark-util-sanitize-uri/index.js +107 -0
- package/vendor/micromark-util-sanitize-uri/license +22 -0
- package/vendor/micromark-util-sanitize-uri/package.json +59 -0
- package/vendor/micromark-util-subtokenize/index.js +228 -0
- package/vendor/micromark-util-subtokenize/lib/splice-buffer.js +251 -0
- package/vendor/micromark-util-subtokenize/license +22 -0
- package/vendor/micromark-util-subtokenize/package.json +60 -0
- package/vendor/unist-util-is/index.js +7 -0
- package/vendor/unist-util-is/lib/index.js +296 -0
- package/vendor/unist-util-is/license +22 -0
- package/vendor/unist-util-is/package.json +103 -0
- package/vendor/unist-util-stringify-position/index.js +1 -0
- package/vendor/unist-util-stringify-position/lib/index.js +84 -0
- package/vendor/unist-util-stringify-position/license +22 -0
- package/vendor/unist-util-stringify-position/package.json +80 -0
- package/vendor/unist-util-visit/index.js +2 -0
- package/vendor/unist-util-visit/lib/index.js +312 -0
- package/vendor/unist-util-visit/license +22 -0
- package/vendor/unist-util-visit/package.json +108 -0
- package/vendor/unist-util-visit-parents/index.js +2 -0
- package/vendor/unist-util-visit-parents/lib/color.js +7 -0
- package/vendor/unist-util-visit-parents/lib/index.js +399 -0
- package/vendor/unist-util-visit-parents/license +22 -0
- package/vendor/unist-util-visit-parents/package.json +106 -0
- package/vendor/zwitch/index.js +118 -0
- package/vendor/zwitch/license +22 -0
- package/vendor/zwitch/package.json +72 -0
- 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,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
|
3
|
+
"bugs": "https://github.com/syntax-tree/mdast-util-from-markdown/issues",
|
|
4
|
+
"contributors": [
|
|
5
|
+
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
|
6
|
+
],
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@types/mdast": "^4.0.0",
|
|
9
|
+
"@types/unist": "^3.0.0",
|
|
10
|
+
"decode-named-character-reference": "^1.0.0",
|
|
11
|
+
"devlop": "^1.0.0",
|
|
12
|
+
"mdast-util-to-string": "^4.0.0",
|
|
13
|
+
"micromark": "^4.0.0",
|
|
14
|
+
"micromark-util-decode-numeric-character-reference": "^2.0.0",
|
|
15
|
+
"micromark-util-decode-string": "^2.0.0",
|
|
16
|
+
"micromark-util-normalize-identifier": "^2.0.0",
|
|
17
|
+
"micromark-util-symbol": "^2.0.0",
|
|
18
|
+
"micromark-util-types": "^2.0.0",
|
|
19
|
+
"unist-util-stringify-position": "^4.0.0"
|
|
20
|
+
},
|
|
21
|
+
"description": "mdast utility to parse markdown",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^26.0.0",
|
|
24
|
+
"commonmark.json": "^0.31.0",
|
|
25
|
+
"esbuild": "^0.28.0",
|
|
26
|
+
"gzip-size-cli": "^5.0.0",
|
|
27
|
+
"hast-util-from-html": "^2.0.0",
|
|
28
|
+
"hast-util-to-html": "^9.0.0",
|
|
29
|
+
"mdast-util-to-hast": "^13.0.0",
|
|
30
|
+
"micromark-build": "^2.0.0",
|
|
31
|
+
"prettier": "^3.0.0",
|
|
32
|
+
"remark-cli": "^12.0.0",
|
|
33
|
+
"remark-preset-wooorm": "^11.0.0",
|
|
34
|
+
"terser": "^5.0.0",
|
|
35
|
+
"type-coverage": "^2.0.0",
|
|
36
|
+
"typescript": "^6.0.0",
|
|
37
|
+
"xo": "^5.0.0"
|
|
38
|
+
},
|
|
39
|
+
"exports": {
|
|
40
|
+
"development": "./dev/index.js",
|
|
41
|
+
"default": "./index.js"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dev/",
|
|
45
|
+
"lib/",
|
|
46
|
+
"index.d.ts",
|
|
47
|
+
"index.js"
|
|
48
|
+
],
|
|
49
|
+
"funding": {
|
|
50
|
+
"type": "opencollective",
|
|
51
|
+
"url": "https://opencollective.com/unified"
|
|
52
|
+
},
|
|
53
|
+
"keywords": [
|
|
54
|
+
"ast",
|
|
55
|
+
"markdown",
|
|
56
|
+
"markup",
|
|
57
|
+
"mdast-util",
|
|
58
|
+
"mdast",
|
|
59
|
+
"parse",
|
|
60
|
+
"syntax",
|
|
61
|
+
"tree",
|
|
62
|
+
"unist",
|
|
63
|
+
"utility",
|
|
64
|
+
"util"
|
|
65
|
+
],
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"name": "mdast-util-from-markdown",
|
|
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
|
+
"repository": "syntax-tree/mdast-util-from-markdown",
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "tsc --build --clean && tsc --build && type-coverage && micromark-build && esbuild . --bundle --minify | terser | gzip-size --raw",
|
|
84
|
+
"format": "remark --frail --quiet --output -- . && prettier --log-level warn --write -- . && xo --fix",
|
|
85
|
+
"test-api-dev": "node --conditions development test/index.js",
|
|
86
|
+
"test-api-prod": "node --conditions production test/index.js",
|
|
87
|
+
"test-api": "npm run test-api-dev && npm run test-api-prod",
|
|
88
|
+
"test-coverage": "node --experimental-test-coverage --test-coverage-exclude='test/**' --test-coverage-lines=100 --test-coverage-branches=100 --test-coverage-functions=100 --conditions development test/index.js && node --experimental-test-coverage --test-coverage-exclude='test/**' --test-coverage-lines=100 --test-coverage-branches=100 --test-coverage-functions=100 --conditions production test/index.js",
|
|
89
|
+
"test": "npm run build && npm run format && npm run test-coverage"
|
|
90
|
+
},
|
|
91
|
+
"sideEffects": false,
|
|
92
|
+
"typeCoverage": {
|
|
93
|
+
"atLeast": 100,
|
|
94
|
+
"strict": true
|
|
95
|
+
},
|
|
96
|
+
"type": "module",
|
|
97
|
+
"version": "2.1.0"
|
|
98
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Delete} from 'mdast'
|
|
3
|
+
* @import {
|
|
4
|
+
* CompileContext,
|
|
5
|
+
* Extension as FromMarkdownExtension,
|
|
6
|
+
* Handle as FromMarkdownHandle
|
|
7
|
+
* } from 'mdast-util-from-markdown'
|
|
8
|
+
* @import {
|
|
9
|
+
* Attention,
|
|
10
|
+
* ConstructName,
|
|
11
|
+
* Handle as ToMarkdownHandle,
|
|
12
|
+
* Options as ToMarkdownExtension
|
|
13
|
+
* } from 'mdast-util-to-markdown'
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* List of constructs that occur in phrasing (paragraphs, headings), but cannot
|
|
18
|
+
* contain strikethrough.
|
|
19
|
+
* So they sort of cancel each other out.
|
|
20
|
+
* Note: could use a better name.
|
|
21
|
+
*
|
|
22
|
+
* Note: keep in sync with: <https://github.com/syntax-tree/mdast-util-to-markdown/blob/8ce8dbf/lib/unsafe.js#L14>
|
|
23
|
+
*
|
|
24
|
+
* @type {Array<ConstructName>}
|
|
25
|
+
*/
|
|
26
|
+
const constructsWithoutStrikethrough = [
|
|
27
|
+
'autolink',
|
|
28
|
+
'destinationLiteral',
|
|
29
|
+
'destinationRaw',
|
|
30
|
+
'reference',
|
|
31
|
+
'titleQuote',
|
|
32
|
+
'titleApostrophe'
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
handleDelete.attention = attentionDelete
|
|
36
|
+
handleDelete.peek = peekDelete
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create an extension for `mdast-util-from-markdown` to enable GFM
|
|
40
|
+
* strikethrough in markdown.
|
|
41
|
+
*
|
|
42
|
+
* @returns {FromMarkdownExtension}
|
|
43
|
+
* Extension for `mdast-util-from-markdown` to enable GFM strikethrough.
|
|
44
|
+
*/
|
|
45
|
+
export function gfmStrikethroughFromMarkdown() {
|
|
46
|
+
return {
|
|
47
|
+
canContainEols: ['delete'],
|
|
48
|
+
enter: {strikethrough: enterStrikethrough},
|
|
49
|
+
exit: {strikethrough: exitStrikethrough}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Create an extension for `mdast-util-to-markdown` to enable GFM
|
|
55
|
+
* strikethrough in markdown.
|
|
56
|
+
*
|
|
57
|
+
* @returns {ToMarkdownExtension}
|
|
58
|
+
* Extension for `mdast-util-to-markdown` to enable GFM strikethrough.
|
|
59
|
+
*/
|
|
60
|
+
export function gfmStrikethroughToMarkdown() {
|
|
61
|
+
return {
|
|
62
|
+
handlers: {delete: handleDelete},
|
|
63
|
+
unsafe: [
|
|
64
|
+
{
|
|
65
|
+
character: '~',
|
|
66
|
+
inConstruct: 'phrasing',
|
|
67
|
+
notInConstruct: constructsWithoutStrikethrough
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Enter strikethrough.
|
|
75
|
+
*
|
|
76
|
+
* @this {CompileContext}
|
|
77
|
+
* @type {FromMarkdownHandle}
|
|
78
|
+
*/
|
|
79
|
+
function enterStrikethrough(token) {
|
|
80
|
+
this.enter({type: 'delete', children: [], position: undefined}, token)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Exit strikethrough.
|
|
85
|
+
*
|
|
86
|
+
* @this {CompileContext}
|
|
87
|
+
* @type {FromMarkdownHandle}
|
|
88
|
+
*/
|
|
89
|
+
function exitStrikethrough(token) {
|
|
90
|
+
this.exit(token)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Serialize a delete node.
|
|
95
|
+
*
|
|
96
|
+
* @type {ToMarkdownHandle}
|
|
97
|
+
* @param {Delete} node
|
|
98
|
+
* Node to serialize.
|
|
99
|
+
*/
|
|
100
|
+
function handleDelete(node, _, state, info) {
|
|
101
|
+
// To do: next major: empty this function, like emphasis and strong handlers,
|
|
102
|
+
// this is no longer needed.
|
|
103
|
+
const tracker = state.createTracker(info)
|
|
104
|
+
const sequence = state.stack.includes('strikethrough') ? '~' : '~~'
|
|
105
|
+
const exit = state.enter('strikethrough')
|
|
106
|
+
let value = tracker.move(sequence)
|
|
107
|
+
value += state.containerPhrasing(node, {
|
|
108
|
+
...tracker.current(),
|
|
109
|
+
before: value,
|
|
110
|
+
after: '~'
|
|
111
|
+
})
|
|
112
|
+
value += tracker.move(sequence)
|
|
113
|
+
exit()
|
|
114
|
+
return value
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Serialize a delete node as attention.
|
|
119
|
+
*
|
|
120
|
+
* @type {Attention}
|
|
121
|
+
*/
|
|
122
|
+
function attentionDelete() {
|
|
123
|
+
return {construct: 'strikethrough', markers: ['~'], sizes: [2, 1]}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Peek the first character of a delete node.
|
|
128
|
+
*
|
|
129
|
+
* @type {ToMarkdownHandle}
|
|
130
|
+
*/
|
|
131
|
+
function peekDelete() {
|
|
132
|
+
return '~'
|
|
133
|
+
}
|
|
@@ -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,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bugs": "https://github.com/syntax-tree/mdast-util-gfm-strikethrough/issues",
|
|
3
|
+
"contributors": [
|
|
4
|
+
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
|
5
|
+
],
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@types/mdast": "^4.0.0",
|
|
8
|
+
"mdast-util-from-markdown": "^2.0.0",
|
|
9
|
+
"mdast-util-to-markdown": "^2.0.0"
|
|
10
|
+
},
|
|
11
|
+
"description": "mdast extension to parse and serialize GFM strikethrough",
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@types/node": "^26.0.0",
|
|
14
|
+
"c8": "^12.0.0",
|
|
15
|
+
"micromark-extension-gfm-strikethrough": "^2.0.0",
|
|
16
|
+
"prettier": "^3.0.0",
|
|
17
|
+
"remark-cli": "^12.0.0",
|
|
18
|
+
"remark-preset-wooorm": "^11.0.0",
|
|
19
|
+
"type-coverage": "^2.0.0",
|
|
20
|
+
"typescript": "^6.0.0",
|
|
21
|
+
"unist-util-remove-position": "^5.0.0",
|
|
22
|
+
"xo": "^5.0.0"
|
|
23
|
+
},
|
|
24
|
+
"exports": "./index.js",
|
|
25
|
+
"files": [
|
|
26
|
+
"lib/",
|
|
27
|
+
"index.d.ts",
|
|
28
|
+
"index.js"
|
|
29
|
+
],
|
|
30
|
+
"funding": {
|
|
31
|
+
"type": "opencollective",
|
|
32
|
+
"url": "https://opencollective.com/unified"
|
|
33
|
+
},
|
|
34
|
+
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
|
35
|
+
"keywords": [
|
|
36
|
+
"delete",
|
|
37
|
+
"deletion",
|
|
38
|
+
"del",
|
|
39
|
+
"gfm",
|
|
40
|
+
"markdown",
|
|
41
|
+
"markup",
|
|
42
|
+
"mdast-util",
|
|
43
|
+
"mdast",
|
|
44
|
+
"strikethrough",
|
|
45
|
+
"strike",
|
|
46
|
+
"through",
|
|
47
|
+
"unist",
|
|
48
|
+
"utility",
|
|
49
|
+
"util"
|
|
50
|
+
],
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"name": "mdast-util-gfm-strikethrough",
|
|
53
|
+
"prettier": {
|
|
54
|
+
"bracketSpacing": false,
|
|
55
|
+
"semi": false,
|
|
56
|
+
"singleQuote": true,
|
|
57
|
+
"tabWidth": 2,
|
|
58
|
+
"trailingComma": "none",
|
|
59
|
+
"useTabs": false
|
|
60
|
+
},
|
|
61
|
+
"remarkConfig": {
|
|
62
|
+
"plugins": [
|
|
63
|
+
"remark-preset-wooorm"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"repository": "syntax-tree/mdast-util-gfm-strikethrough",
|
|
67
|
+
"scripts": {
|
|
68
|
+
"build": "tsc --build --clean && tsc --build && type-coverage",
|
|
69
|
+
"format": "remark --frail --output --quiet -- . && prettier --log-level warn --write -- . && xo --fix",
|
|
70
|
+
"prepack": "npm run build && npm run format",
|
|
71
|
+
"test-api-dev": "node --conditions development test.js",
|
|
72
|
+
"test-api-prod": "node --conditions production test.js",
|
|
73
|
+
"test-api": "npm run test-api-dev && npm run test-api-prod",
|
|
74
|
+
"test-coverage": "c8 --100 --reporter lcov -- npm run test-api",
|
|
75
|
+
"test": "npm run build && npm run format && npm run test-coverage"
|
|
76
|
+
},
|
|
77
|
+
"sideEffects": false,
|
|
78
|
+
"typeCoverage": {
|
|
79
|
+
"atLeast": 100,
|
|
80
|
+
"strict": true
|
|
81
|
+
},
|
|
82
|
+
"type": "module",
|
|
83
|
+
"version": "2.0.1"
|
|
84
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('mdast').InlineCode} InlineCode
|
|
3
|
+
* @typedef {import('mdast').Table} Table
|
|
4
|
+
* @typedef {import('mdast').TableCell} TableCell
|
|
5
|
+
* @typedef {import('mdast').TableRow} TableRow
|
|
6
|
+
*
|
|
7
|
+
* @typedef {import('markdown-table').Options} MarkdownTableOptions
|
|
8
|
+
*
|
|
9
|
+
* @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext
|
|
10
|
+
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
|
|
11
|
+
* @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle
|
|
12
|
+
*
|
|
13
|
+
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
|
|
14
|
+
* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle
|
|
15
|
+
* @typedef {import('mdast-util-to-markdown').State} State
|
|
16
|
+
* @typedef {import('mdast-util-to-markdown').Info} Info
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef Options
|
|
21
|
+
* Configuration.
|
|
22
|
+
* @property {boolean | null | undefined} [tableCellPadding=true]
|
|
23
|
+
* Whether to add a space of padding between delimiters and cells (default:
|
|
24
|
+
* `true`).
|
|
25
|
+
* @property {boolean | null | undefined} [tablePipeAlign=true]
|
|
26
|
+
* Whether to align the delimiters (default: `true`).
|
|
27
|
+
* @property {MarkdownTableOptions['stringLength'] | null | undefined} [stringLength]
|
|
28
|
+
* Function to detect the length of table cell content, used when aligning
|
|
29
|
+
* the delimiters between cells (optional).
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import {ok as assert} from 'devlop'
|
|
33
|
+
import {markdownTable} from 'markdown-table'
|
|
34
|
+
import {defaultHandlers} from 'mdast-util-to-markdown'
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create an extension for `mdast-util-from-markdown` to enable GFM tables in
|
|
38
|
+
* markdown.
|
|
39
|
+
*
|
|
40
|
+
* @returns {FromMarkdownExtension}
|
|
41
|
+
* Extension for `mdast-util-from-markdown` to enable GFM tables.
|
|
42
|
+
*/
|
|
43
|
+
export function gfmTableFromMarkdown() {
|
|
44
|
+
return {
|
|
45
|
+
enter: {
|
|
46
|
+
table: enterTable,
|
|
47
|
+
tableData: enterCell,
|
|
48
|
+
tableHeader: enterCell,
|
|
49
|
+
tableRow: enterRow
|
|
50
|
+
},
|
|
51
|
+
exit: {
|
|
52
|
+
codeText: exitCodeText,
|
|
53
|
+
table: exitTable,
|
|
54
|
+
tableData: exit,
|
|
55
|
+
tableHeader: exit,
|
|
56
|
+
tableRow: exit
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @this {CompileContext}
|
|
63
|
+
* @type {FromMarkdownHandle}
|
|
64
|
+
*/
|
|
65
|
+
function enterTable(token) {
|
|
66
|
+
const align = token._align
|
|
67
|
+
assert(align, 'expected `_align` on table')
|
|
68
|
+
this.enter(
|
|
69
|
+
{
|
|
70
|
+
type: 'table',
|
|
71
|
+
align: align.map(function (d) {
|
|
72
|
+
return d === 'none' ? null : d
|
|
73
|
+
}),
|
|
74
|
+
children: []
|
|
75
|
+
},
|
|
76
|
+
token
|
|
77
|
+
)
|
|
78
|
+
this.data.inTable = true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @this {CompileContext}
|
|
83
|
+
* @type {FromMarkdownHandle}
|
|
84
|
+
*/
|
|
85
|
+
function exitTable(token) {
|
|
86
|
+
this.exit(token)
|
|
87
|
+
this.data.inTable = undefined
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @this {CompileContext}
|
|
92
|
+
* @type {FromMarkdownHandle}
|
|
93
|
+
*/
|
|
94
|
+
function enterRow(token) {
|
|
95
|
+
this.enter({type: 'tableRow', children: []}, token)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @this {CompileContext}
|
|
100
|
+
* @type {FromMarkdownHandle}
|
|
101
|
+
*/
|
|
102
|
+
function exit(token) {
|
|
103
|
+
this.exit(token)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @this {CompileContext}
|
|
108
|
+
* @type {FromMarkdownHandle}
|
|
109
|
+
*/
|
|
110
|
+
function enterCell(token) {
|
|
111
|
+
this.enter({type: 'tableCell', children: []}, token)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Overwrite the default code text data handler to unescape escaped pipes when
|
|
115
|
+
// they are in tables.
|
|
116
|
+
/**
|
|
117
|
+
* @this {CompileContext}
|
|
118
|
+
* @type {FromMarkdownHandle}
|
|
119
|
+
*/
|
|
120
|
+
function exitCodeText(token) {
|
|
121
|
+
let value = this.resume()
|
|
122
|
+
|
|
123
|
+
if (this.data.inTable) {
|
|
124
|
+
value = value.replace(/\\([\\|])/g, replace)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const node = this.stack[this.stack.length - 1]
|
|
128
|
+
assert(node.type === 'inlineCode')
|
|
129
|
+
node.value = value
|
|
130
|
+
this.exit(token)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {string} $0
|
|
135
|
+
* @param {string} $1
|
|
136
|
+
* @returns {string}
|
|
137
|
+
*/
|
|
138
|
+
function replace($0, $1) {
|
|
139
|
+
// Pipes work, backslashes don’t (but can’t escape pipes).
|
|
140
|
+
return $1 === '|' ? $1 : $0
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Create an extension for `mdast-util-to-markdown` to enable GFM tables in
|
|
145
|
+
* markdown.
|
|
146
|
+
*
|
|
147
|
+
* @param {Options | null | undefined} [options]
|
|
148
|
+
* Configuration.
|
|
149
|
+
* @returns {ToMarkdownExtension}
|
|
150
|
+
* Extension for `mdast-util-to-markdown` to enable GFM tables.
|
|
151
|
+
*/
|
|
152
|
+
export function gfmTableToMarkdown(options) {
|
|
153
|
+
const settings = options || {}
|
|
154
|
+
const padding = settings.tableCellPadding
|
|
155
|
+
const alignDelimiters = settings.tablePipeAlign
|
|
156
|
+
const stringLength = settings.stringLength
|
|
157
|
+
const around = padding ? ' ' : '|'
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
unsafe: [
|
|
161
|
+
{character: '\r', inConstruct: 'tableCell'},
|
|
162
|
+
{character: '\n', inConstruct: 'tableCell'},
|
|
163
|
+
// A pipe, when followed by a tab or space (padding), or a dash or colon
|
|
164
|
+
// (unpadded delimiter row), could result in a table.
|
|
165
|
+
{atBreak: true, character: '|', after: '[\t :-]'},
|
|
166
|
+
// A pipe in a cell must be encoded.
|
|
167
|
+
{character: '|', inConstruct: 'tableCell'},
|
|
168
|
+
// A colon must be followed by a dash, in which case it could start a
|
|
169
|
+
// delimiter row.
|
|
170
|
+
{atBreak: true, character: ':', after: '-'},
|
|
171
|
+
// A delimiter row can also start with a dash, when followed by more
|
|
172
|
+
// dashes, a colon, or a pipe.
|
|
173
|
+
// This is a stricter version than the built in check for lists, thematic
|
|
174
|
+
// breaks, and setex heading underlines though:
|
|
175
|
+
// <https://github.com/syntax-tree/mdast-util-to-markdown/blob/51a2038/lib/unsafe.js#L57>
|
|
176
|
+
{atBreak: true, character: '-', after: '[:|-]'}
|
|
177
|
+
],
|
|
178
|
+
handlers: {
|
|
179
|
+
inlineCode: inlineCodeWithTable,
|
|
180
|
+
table: handleTable,
|
|
181
|
+
tableCell: handleTableCell,
|
|
182
|
+
tableRow: handleTableRow
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @type {ToMarkdownHandle}
|
|
188
|
+
* @param {Table} node
|
|
189
|
+
*/
|
|
190
|
+
function handleTable(node, _, state, info) {
|
|
191
|
+
return serializeData(handleTableAsData(node, state, info), node.align)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* This function isn’t really used normally, because we handle rows at the
|
|
196
|
+
* table level.
|
|
197
|
+
* But, if someone passes in a table row, this ensures we make somewhat sense.
|
|
198
|
+
*
|
|
199
|
+
* @type {ToMarkdownHandle}
|
|
200
|
+
* @param {TableRow} node
|
|
201
|
+
*/
|
|
202
|
+
function handleTableRow(node, _, state, info) {
|
|
203
|
+
const row = handleTableRowAsData(node, state, info)
|
|
204
|
+
const value = serializeData([row])
|
|
205
|
+
// `markdown-table` will always add an align row
|
|
206
|
+
return value.slice(0, value.indexOf('\n'))
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @type {ToMarkdownHandle}
|
|
211
|
+
* @param {TableCell} node
|
|
212
|
+
*/
|
|
213
|
+
function handleTableCell(node, _, state, info) {
|
|
214
|
+
const exit = state.enter('tableCell')
|
|
215
|
+
const subexit = state.enter('phrasing')
|
|
216
|
+
const value = state.containerPhrasing(node, {
|
|
217
|
+
...info,
|
|
218
|
+
before: around,
|
|
219
|
+
after: around
|
|
220
|
+
})
|
|
221
|
+
subexit()
|
|
222
|
+
exit()
|
|
223
|
+
return value
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @param {Array<Array<string>>} matrix
|
|
228
|
+
* @param {Array<string | null | undefined> | null | undefined} [align]
|
|
229
|
+
*/
|
|
230
|
+
function serializeData(matrix, align) {
|
|
231
|
+
return markdownTable(matrix, {
|
|
232
|
+
align,
|
|
233
|
+
// @ts-expect-error: `markdown-table` types should support `null`.
|
|
234
|
+
alignDelimiters,
|
|
235
|
+
// @ts-expect-error: `markdown-table` types should support `null`.
|
|
236
|
+
padding,
|
|
237
|
+
// @ts-expect-error: `markdown-table` types should support `null`.
|
|
238
|
+
stringLength
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @param {Table} node
|
|
244
|
+
* @param {State} state
|
|
245
|
+
* @param {Info} info
|
|
246
|
+
*/
|
|
247
|
+
function handleTableAsData(node, state, info) {
|
|
248
|
+
const children = node.children
|
|
249
|
+
let index = -1
|
|
250
|
+
/** @type {Array<Array<string>>} */
|
|
251
|
+
const result = []
|
|
252
|
+
const subexit = state.enter('table')
|
|
253
|
+
|
|
254
|
+
while (++index < children.length) {
|
|
255
|
+
result[index] = handleTableRowAsData(children[index], state, info)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
subexit()
|
|
259
|
+
|
|
260
|
+
return result
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @param {TableRow} node
|
|
265
|
+
* @param {State} state
|
|
266
|
+
* @param {Info} info
|
|
267
|
+
*/
|
|
268
|
+
function handleTableRowAsData(node, state, info) {
|
|
269
|
+
const children = node.children
|
|
270
|
+
let index = -1
|
|
271
|
+
/** @type {Array<string>} */
|
|
272
|
+
const result = []
|
|
273
|
+
const subexit = state.enter('tableRow')
|
|
274
|
+
|
|
275
|
+
while (++index < children.length) {
|
|
276
|
+
// Note: the positional info as used here is incorrect.
|
|
277
|
+
// Making it correct would be impossible due to aligning cells?
|
|
278
|
+
// And it would need copy/pasting `markdown-table` into this project.
|
|
279
|
+
result[index] = handleTableCell(children[index], node, state, info)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
subexit()
|
|
283
|
+
|
|
284
|
+
return result
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* @type {ToMarkdownHandle}
|
|
289
|
+
* @param {InlineCode} node
|
|
290
|
+
*/
|
|
291
|
+
function inlineCodeWithTable(node, parent, state) {
|
|
292
|
+
let value = defaultHandlers.inlineCode(node, parent, state)
|
|
293
|
+
|
|
294
|
+
if (state.stack.includes('tableCell')) {
|
|
295
|
+
value = value.replace(/\|/g, '\\$&')
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return value
|
|
299
|
+
}
|
|
300
|
+
}
|
|
@@ -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.
|