hermium 0.2.0 → 0.3.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 (157) hide show
  1. package/bin/hermium.mjs +102 -58
  2. package/dist/server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +6 -0
  3. package/dist/server/_chunks/ssr-renderer.mjs +22 -0
  4. package/dist/server/_libs/bail.mjs +8 -0
  5. package/dist/server/_libs/base-ui__react.mjs +9858 -0
  6. package/dist/server/_libs/base-ui__utils.mjs +1106 -0
  7. package/dist/server/_libs/ccount.mjs +16 -0
  8. package/dist/server/_libs/character-entities.mjs +2130 -0
  9. package/dist/server/_libs/class-variance-authority.mjs +44 -0
  10. package/dist/server/_libs/clsx.mjs +16 -0
  11. package/dist/server/_libs/comma-separated-tokens.mjs +10 -0
  12. package/dist/server/_libs/cookie-es.mjs +1 -0
  13. package/dist/server/_libs/croner.mjs +1 -0
  14. package/dist/server/_libs/crossws.mjs +1 -0
  15. package/dist/server/_libs/decode-named-character-reference+[...].mjs +8 -0
  16. package/dist/server/_libs/devlop.mjs +8 -0
  17. package/dist/server/_libs/escape-string-regexp.mjs +9 -0
  18. package/dist/server/_libs/estree-util-is-identifier-name.mjs +11 -0
  19. package/dist/server/_libs/extend.mjs +97 -0
  20. package/dist/server/_libs/floating-ui__core.mjs +663 -0
  21. package/dist/server/_libs/floating-ui__dom.mjs +624 -0
  22. package/dist/server/_libs/floating-ui__react-dom.mjs +279 -0
  23. package/dist/server/_libs/floating-ui__utils.mjs +322 -0
  24. package/dist/server/_libs/h3.mjs +408 -0
  25. package/dist/server/_libs/hast-util-is-element.mjs +75 -0
  26. package/dist/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
  27. package/dist/server/_libs/hast-util-to-text.mjs +305 -0
  28. package/dist/server/_libs/hast-util-whitespace.mjs +10 -0
  29. package/dist/server/_libs/highlight.js.mjs +14756 -0
  30. package/dist/server/_libs/hookable.mjs +1 -0
  31. package/dist/server/_libs/html-url-attributes.mjs +26 -0
  32. package/dist/server/_libs/inline-style-parser.mjs +142 -0
  33. package/dist/server/_libs/is-plain-obj.mjs +10 -0
  34. package/dist/server/_libs/isbot.mjs +21 -0
  35. package/dist/server/_libs/longest-streak.mjs +25 -0
  36. package/dist/server/_libs/lowlight.mjs +262 -0
  37. package/dist/server/_libs/markdown-table.mjs +142 -0
  38. package/dist/server/_libs/mdast-util-find-and-replace.mjs +109 -0
  39. package/dist/server/_libs/mdast-util-from-markdown.mjs +717 -0
  40. package/dist/server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +156 -0
  41. package/dist/server/_libs/mdast-util-gfm-footnote.mjs +117 -0
  42. package/dist/server/_libs/mdast-util-gfm-strikethrough.mjs +54 -0
  43. package/dist/server/_libs/mdast-util-gfm-table.mjs +157 -0
  44. package/dist/server/_libs/mdast-util-gfm-task-list-item.mjs +77 -0
  45. package/dist/server/_libs/mdast-util-gfm.mjs +29 -0
  46. package/dist/server/_libs/mdast-util-phrasing.mjs +30 -0
  47. package/dist/server/_libs/mdast-util-to-hast.mjs +710 -0
  48. package/dist/server/_libs/mdast-util-to-markdown.mjs +798 -0
  49. package/dist/server/_libs/mdast-util-to-string.mjs +38 -0
  50. package/dist/server/_libs/micromark-core-commonmark.mjs +2259 -0
  51. package/dist/server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +344 -0
  52. package/dist/server/_libs/micromark-extension-gfm-footnote+[...].mjs +279 -0
  53. package/dist/server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +98 -0
  54. package/dist/server/_libs/micromark-extension-gfm-table.mjs +491 -0
  55. package/dist/server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +1 -0
  56. package/dist/server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +77 -0
  57. package/dist/server/_libs/micromark-extension-gfm.mjs +18 -0
  58. package/dist/server/_libs/micromark-factory-destination.mjs +94 -0
  59. package/dist/server/_libs/micromark-factory-label.mjs +63 -0
  60. package/dist/server/_libs/micromark-factory-space.mjs +24 -0
  61. package/dist/server/_libs/micromark-factory-title.mjs +65 -0
  62. package/dist/server/_libs/micromark-factory-whitespace.mjs +22 -0
  63. package/dist/server/_libs/micromark-util-character.mjs +44 -0
  64. package/dist/server/_libs/micromark-util-chunked.mjs +36 -0
  65. package/dist/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
  66. package/dist/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
  67. package/dist/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
  68. package/dist/server/_libs/micromark-util-decode-string.mjs +21 -0
  69. package/dist/server/_libs/micromark-util-encode.mjs +1 -0
  70. package/dist/server/_libs/micromark-util-html-tag-name.mjs +69 -0
  71. package/dist/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
  72. package/dist/server/_libs/micromark-util-resolve-all.mjs +15 -0
  73. package/dist/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
  74. package/dist/server/_libs/micromark-util-subtokenize.mjs +346 -0
  75. package/dist/server/_libs/micromark.mjs +906 -0
  76. package/dist/server/_libs/ocache.mjs +1 -0
  77. package/dist/server/_libs/ohash.mjs +1 -0
  78. package/dist/server/_libs/property-information.mjs +1209 -0
  79. package/dist/server/_libs/react-dom.mjs +10779 -0
  80. package/dist/server/_libs/react-markdown.mjs +147 -0
  81. package/dist/server/_libs/react.mjs +513 -0
  82. package/dist/server/_libs/rehype-highlight.mjs +94 -0
  83. package/dist/server/_libs/remark-gfm.mjs +20 -0
  84. package/dist/server/_libs/remark-parse.mjs +19 -0
  85. package/dist/server/_libs/remark-rehype.mjs +21 -0
  86. package/dist/server/_libs/reselect.mjs +1 -0
  87. package/dist/server/_libs/rou3.mjs +8 -0
  88. package/dist/server/_libs/seroval-plugins.mjs +1 -0
  89. package/dist/server/_libs/seroval.mjs +1 -0
  90. package/dist/server/_libs/space-separated-tokens.mjs +6 -0
  91. package/dist/server/_libs/srvx.mjs +781 -0
  92. package/dist/server/_libs/style-to-js.mjs +72 -0
  93. package/dist/server/_libs/style-to-object.mjs +38 -0
  94. package/dist/server/_libs/tabler__icons-react.mjs +140 -0
  95. package/dist/server/_libs/tailwind-merge.mjs +3255 -0
  96. package/dist/server/_libs/tanstack__history.mjs +29 -0
  97. package/dist/server/_libs/tanstack__react-router.mjs +1120 -0
  98. package/dist/server/_libs/tanstack__react-store.mjs +2 -0
  99. package/dist/server/_libs/tanstack__router-core.mjs +3594 -0
  100. package/dist/server/_libs/tanstack__store.mjs +1 -0
  101. package/dist/server/_libs/trim-lines.mjs +41 -0
  102. package/dist/server/_libs/trough.mjs +85 -0
  103. package/dist/server/_libs/ufo.mjs +54 -0
  104. package/dist/server/_libs/unctx.mjs +1 -0
  105. package/dist/server/_libs/ungap__structured-clone.mjs +224 -0
  106. package/dist/server/_libs/unified.mjs +661 -0
  107. package/dist/server/_libs/unist-util-find-after.mjs +41 -0
  108. package/dist/server/_libs/unist-util-is.mjs +100 -0
  109. package/dist/server/_libs/unist-util-position.mjs +27 -0
  110. package/dist/server/_libs/unist-util-stringify-position.mjs +27 -0
  111. package/dist/server/_libs/unist-util-visit-parents.mjs +83 -0
  112. package/dist/server/_libs/unist-util-visit.mjs +24 -0
  113. package/dist/server/_libs/unstorage.mjs +1 -0
  114. package/dist/server/_libs/use-sync-external-store.mjs +139 -0
  115. package/dist/server/_libs/vfile-message.mjs +138 -0
  116. package/dist/server/_libs/vfile.mjs +467 -0
  117. package/dist/server/_libs/zustand.mjs +43 -0
  118. package/dist/server/_libs/zwitch.mjs +1 -0
  119. package/dist/server/_ssr/ChatInputBlock-Bu2-iop_.mjs +220 -0
  120. package/dist/server/_ssr/MarkdownMessage-CNS7OSKN.mjs +68 -0
  121. package/dist/server/_ssr/chat._sessionId-P02iSfut.mjs +477 -0
  122. package/dist/server/_ssr/chat.index-BYB_48NC.mjs +64 -0
  123. package/dist/server/_ssr/index-C1mT_2d8.mjs +4890 -0
  124. package/dist/server/_ssr/index-DFV9_oCk.mjs +43 -0
  125. package/dist/server/_ssr/memory-CW_fSOG9.mjs +257 -0
  126. package/dist/server/_ssr/router-CUAfx91O.mjs +2035 -0
  127. package/dist/server/_ssr/settings-DoXurzvn.mjs +10 -0
  128. package/dist/server/_ssr/skills-Cs7A5ZwO.mjs +422 -0
  129. package/dist/server/_ssr/theme-BK4-7E2h.mjs +42 -0
  130. package/dist/server/_ssr/usage-Bs2-LXGz.mjs +298 -0
  131. package/dist/server/_tanstack-start-manifest_v-C7Upe2TI.mjs +4 -0
  132. package/dist/server/index.mjs +506 -0
  133. package/package.json +4 -3
  134. package/dist/public/assets/css/index-Dfs9RUU9.css +0 -1
  135. package/dist/public/assets/css/styles-B8p6jk5Z.css +0 -1
  136. package/dist/public/assets/js/ChatInputBlock-Bw7AL70H.js +0 -1
  137. package/dist/public/assets/js/MarkdownMessage-8d7Y6VL-.js +0 -1
  138. package/dist/public/assets/js/base-ui-BvQbAt_1.js +0 -1
  139. package/dist/public/assets/js/chat._sessionId-BG6lVraH.js +0 -1
  140. package/dist/public/assets/js/chat.index-D2zdMPTT.js +0 -1
  141. package/dist/public/assets/js/index-C0AK45FU.js +0 -60
  142. package/dist/public/assets/js/index-Cx5En4FK.js +0 -1
  143. package/dist/public/assets/js/memory-CeSRdTkW.js +0 -3
  144. package/dist/public/assets/js/router-8uDKazL-.js +0 -1
  145. package/dist/public/assets/js/settings-Bc3Y5zXO.js +0 -1
  146. package/dist/public/assets/js/skills-DZv7sA_5.js +0 -1
  147. package/dist/public/assets/js/theme-CPkdkpaj.js +0 -1
  148. package/dist/public/assets/js/usage-DXQsT9_b.js +0 -1
  149. package/dist/public/assets/woff2/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  150. package/dist/public/assets/woff2/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  151. package/dist/public/assets/woff2/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  152. package/dist/public/assets/woff2/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  153. package/dist/public/assets/woff2/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  154. package/dist/public/favicon.ico +0 -0
  155. package/dist/public/logo.png +0 -0
  156. package/dist/public/manifest.json +0 -25
  157. package/dist/public/robots.txt +0 -3
@@ -0,0 +1,156 @@
1
+ import { c as ccount } from "./ccount.mjs";
2
+ import { o as ok } from "./devlop.mjs";
3
+ import { j as unicodeWhitespace, u as unicodePunctuation } from "./micromark-util-character.mjs";
4
+ import { f as findAndReplace } from "./mdast-util-find-and-replace.mjs";
5
+ const inConstruct = "phrasing";
6
+ const notInConstruct = ["autolink", "link", "image", "label"];
7
+ function gfmAutolinkLiteralFromMarkdown() {
8
+ return {
9
+ transforms: [transformGfmAutolinkLiterals],
10
+ enter: {
11
+ literalAutolink: enterLiteralAutolink,
12
+ literalAutolinkEmail: enterLiteralAutolinkValue,
13
+ literalAutolinkHttp: enterLiteralAutolinkValue,
14
+ literalAutolinkWww: enterLiteralAutolinkValue
15
+ },
16
+ exit: {
17
+ literalAutolink: exitLiteralAutolink,
18
+ literalAutolinkEmail: exitLiteralAutolinkEmail,
19
+ literalAutolinkHttp: exitLiteralAutolinkHttp,
20
+ literalAutolinkWww: exitLiteralAutolinkWww
21
+ }
22
+ };
23
+ }
24
+ function gfmAutolinkLiteralToMarkdown() {
25
+ return {
26
+ unsafe: [
27
+ {
28
+ character: "@",
29
+ before: "[+\\-.\\w]",
30
+ after: "[\\-.\\w]",
31
+ inConstruct,
32
+ notInConstruct
33
+ },
34
+ {
35
+ character: ".",
36
+ before: "[Ww]",
37
+ after: "[\\-.\\w]",
38
+ inConstruct,
39
+ notInConstruct
40
+ },
41
+ {
42
+ character: ":",
43
+ before: "[ps]",
44
+ after: "\\/",
45
+ inConstruct,
46
+ notInConstruct
47
+ }
48
+ ]
49
+ };
50
+ }
51
+ function enterLiteralAutolink(token) {
52
+ this.enter({ type: "link", title: null, url: "", children: [] }, token);
53
+ }
54
+ function enterLiteralAutolinkValue(token) {
55
+ this.config.enter.autolinkProtocol.call(this, token);
56
+ }
57
+ function exitLiteralAutolinkHttp(token) {
58
+ this.config.exit.autolinkProtocol.call(this, token);
59
+ }
60
+ function exitLiteralAutolinkWww(token) {
61
+ this.config.exit.data.call(this, token);
62
+ const node = this.stack[this.stack.length - 1];
63
+ ok(node.type === "link");
64
+ node.url = "http://" + this.sliceSerialize(token);
65
+ }
66
+ function exitLiteralAutolinkEmail(token) {
67
+ this.config.exit.autolinkEmail.call(this, token);
68
+ }
69
+ function exitLiteralAutolink(token) {
70
+ this.exit(token);
71
+ }
72
+ function transformGfmAutolinkLiterals(tree) {
73
+ findAndReplace(
74
+ tree,
75
+ [
76
+ [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl],
77
+ [/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmail]
78
+ ],
79
+ { ignore: ["link", "linkReference"] }
80
+ );
81
+ }
82
+ function findUrl(_, protocol, domain, path, match) {
83
+ let prefix = "";
84
+ if (!previous(match)) {
85
+ return false;
86
+ }
87
+ if (/^w/i.test(protocol)) {
88
+ domain = protocol + domain;
89
+ protocol = "";
90
+ prefix = "http://";
91
+ }
92
+ if (!isCorrectDomain(domain)) {
93
+ return false;
94
+ }
95
+ const parts = splitUrl(domain + path);
96
+ if (!parts[0]) return false;
97
+ const result = {
98
+ type: "link",
99
+ title: null,
100
+ url: prefix + protocol + parts[0],
101
+ children: [{ type: "text", value: protocol + parts[0] }]
102
+ };
103
+ if (parts[1]) {
104
+ return [result, { type: "text", value: parts[1] }];
105
+ }
106
+ return result;
107
+ }
108
+ function findEmail(_, atext, label, match) {
109
+ if (
110
+ // Not an expected previous character.
111
+ !previous(match, true) || // Label ends in not allowed character.
112
+ /[-\d_]$/.test(label)
113
+ ) {
114
+ return false;
115
+ }
116
+ return {
117
+ type: "link",
118
+ title: null,
119
+ url: "mailto:" + atext + "@" + label,
120
+ children: [{ type: "text", value: atext + "@" + label }]
121
+ };
122
+ }
123
+ function isCorrectDomain(domain) {
124
+ const parts = domain.split(".");
125
+ if (parts.length < 2 || parts[parts.length - 1] && (/_/.test(parts[parts.length - 1]) || !/[a-zA-Z\d]/.test(parts[parts.length - 1])) || parts[parts.length - 2] && (/_/.test(parts[parts.length - 2]) || !/[a-zA-Z\d]/.test(parts[parts.length - 2]))) {
126
+ return false;
127
+ }
128
+ return true;
129
+ }
130
+ function splitUrl(url) {
131
+ const trailExec = /[!"&'),.:;<>?\]}]+$/.exec(url);
132
+ if (!trailExec) {
133
+ return [url, void 0];
134
+ }
135
+ url = url.slice(0, trailExec.index);
136
+ let trail = trailExec[0];
137
+ let closingParenIndex = trail.indexOf(")");
138
+ const openingParens = ccount(url, "(");
139
+ let closingParens = ccount(url, ")");
140
+ while (closingParenIndex !== -1 && openingParens > closingParens) {
141
+ url += trail.slice(0, closingParenIndex + 1);
142
+ trail = trail.slice(closingParenIndex + 1);
143
+ closingParenIndex = trail.indexOf(")");
144
+ closingParens++;
145
+ }
146
+ return [url, trail];
147
+ }
148
+ function previous(match, email) {
149
+ const code = match.input.charCodeAt(match.index - 1);
150
+ return (match.index === 0 || unicodeWhitespace(code) || unicodePunctuation(code)) && // If it’s an email, the previous character should not be a slash.
151
+ (!email || code !== 47);
152
+ }
153
+ export {
154
+ gfmAutolinkLiteralToMarkdown as a,
155
+ gfmAutolinkLiteralFromMarkdown as g
156
+ };
@@ -0,0 +1,117 @@
1
+ import { o as ok } from "./devlop.mjs";
2
+ import { n as normalizeIdentifier } from "./micromark-util-normalize-identifier+[...].mjs";
3
+ footnoteReference.peek = footnoteReferencePeek;
4
+ function enterFootnoteCallString() {
5
+ this.buffer();
6
+ }
7
+ function enterFootnoteCall(token) {
8
+ this.enter({ type: "footnoteReference", identifier: "", label: "" }, token);
9
+ }
10
+ function enterFootnoteDefinitionLabelString() {
11
+ this.buffer();
12
+ }
13
+ function enterFootnoteDefinition(token) {
14
+ this.enter(
15
+ { type: "footnoteDefinition", identifier: "", label: "", children: [] },
16
+ token
17
+ );
18
+ }
19
+ function exitFootnoteCallString(token) {
20
+ const label = this.resume();
21
+ const node = this.stack[this.stack.length - 1];
22
+ ok(node.type === "footnoteReference");
23
+ node.identifier = normalizeIdentifier(
24
+ this.sliceSerialize(token)
25
+ ).toLowerCase();
26
+ node.label = label;
27
+ }
28
+ function exitFootnoteCall(token) {
29
+ this.exit(token);
30
+ }
31
+ function exitFootnoteDefinitionLabelString(token) {
32
+ const label = this.resume();
33
+ const node = this.stack[this.stack.length - 1];
34
+ ok(node.type === "footnoteDefinition");
35
+ node.identifier = normalizeIdentifier(
36
+ this.sliceSerialize(token)
37
+ ).toLowerCase();
38
+ node.label = label;
39
+ }
40
+ function exitFootnoteDefinition(token) {
41
+ this.exit(token);
42
+ }
43
+ function footnoteReferencePeek() {
44
+ return "[";
45
+ }
46
+ function footnoteReference(node, _, state, info) {
47
+ const tracker = state.createTracker(info);
48
+ let value = tracker.move("[^");
49
+ const exit = state.enter("footnoteReference");
50
+ const subexit = state.enter("reference");
51
+ value += tracker.move(
52
+ state.safe(state.associationId(node), { after: "]", before: value })
53
+ );
54
+ subexit();
55
+ exit();
56
+ value += tracker.move("]");
57
+ return value;
58
+ }
59
+ function gfmFootnoteFromMarkdown() {
60
+ return {
61
+ enter: {
62
+ gfmFootnoteCallString: enterFootnoteCallString,
63
+ gfmFootnoteCall: enterFootnoteCall,
64
+ gfmFootnoteDefinitionLabelString: enterFootnoteDefinitionLabelString,
65
+ gfmFootnoteDefinition: enterFootnoteDefinition
66
+ },
67
+ exit: {
68
+ gfmFootnoteCallString: exitFootnoteCallString,
69
+ gfmFootnoteCall: exitFootnoteCall,
70
+ gfmFootnoteDefinitionLabelString: exitFootnoteDefinitionLabelString,
71
+ gfmFootnoteDefinition: exitFootnoteDefinition
72
+ }
73
+ };
74
+ }
75
+ function gfmFootnoteToMarkdown(options) {
76
+ let firstLineBlank = false;
77
+ if (options && options.firstLineBlank) {
78
+ firstLineBlank = true;
79
+ }
80
+ return {
81
+ handlers: { footnoteDefinition, footnoteReference },
82
+ // This is on by default already.
83
+ unsafe: [{ character: "[", inConstruct: ["label", "phrasing", "reference"] }]
84
+ };
85
+ function footnoteDefinition(node, _, state, info) {
86
+ const tracker = state.createTracker(info);
87
+ let value = tracker.move("[^");
88
+ const exit = state.enter("footnoteDefinition");
89
+ const subexit = state.enter("label");
90
+ value += tracker.move(
91
+ state.safe(state.associationId(node), { before: value, after: "]" })
92
+ );
93
+ subexit();
94
+ value += tracker.move("]:");
95
+ if (node.children && node.children.length > 0) {
96
+ tracker.shift(4);
97
+ value += tracker.move(
98
+ (firstLineBlank ? "\n" : " ") + state.indentLines(
99
+ state.containerFlow(node, tracker.current()),
100
+ firstLineBlank ? mapAll : mapExceptFirst
101
+ )
102
+ );
103
+ }
104
+ exit();
105
+ return value;
106
+ }
107
+ }
108
+ function mapExceptFirst(line, index, blank) {
109
+ return index === 0 ? line : mapAll(line, index, blank);
110
+ }
111
+ function mapAll(line, index, blank) {
112
+ return (blank ? "" : " ") + line;
113
+ }
114
+ export {
115
+ gfmFootnoteToMarkdown as a,
116
+ gfmFootnoteFromMarkdown as g
117
+ };
@@ -0,0 +1,54 @@
1
+ const constructsWithoutStrikethrough = [
2
+ "autolink",
3
+ "destinationLiteral",
4
+ "destinationRaw",
5
+ "reference",
6
+ "titleQuote",
7
+ "titleApostrophe"
8
+ ];
9
+ handleDelete.peek = peekDelete;
10
+ function gfmStrikethroughFromMarkdown() {
11
+ return {
12
+ canContainEols: ["delete"],
13
+ enter: { strikethrough: enterStrikethrough },
14
+ exit: { strikethrough: exitStrikethrough }
15
+ };
16
+ }
17
+ function gfmStrikethroughToMarkdown() {
18
+ return {
19
+ unsafe: [
20
+ {
21
+ character: "~",
22
+ inConstruct: "phrasing",
23
+ notInConstruct: constructsWithoutStrikethrough
24
+ }
25
+ ],
26
+ handlers: { delete: handleDelete }
27
+ };
28
+ }
29
+ function enterStrikethrough(token) {
30
+ this.enter({ type: "delete", children: [] }, token);
31
+ }
32
+ function exitStrikethrough(token) {
33
+ this.exit(token);
34
+ }
35
+ function handleDelete(node, _, state, info) {
36
+ const tracker = state.createTracker(info);
37
+ const exit = state.enter("strikethrough");
38
+ let value = tracker.move("~~");
39
+ value += state.containerPhrasing(node, {
40
+ ...tracker.current(),
41
+ before: value,
42
+ after: "~"
43
+ });
44
+ value += tracker.move("~~");
45
+ exit();
46
+ return value;
47
+ }
48
+ function peekDelete() {
49
+ return "~";
50
+ }
51
+ export {
52
+ gfmStrikethroughToMarkdown as a,
53
+ gfmStrikethroughFromMarkdown as g
54
+ };
@@ -0,0 +1,157 @@
1
+ import { o as ok } from "./devlop.mjs";
2
+ import { m as markdownTable } from "./markdown-table.mjs";
3
+ import { h as handle } from "./mdast-util-to-markdown.mjs";
4
+ function gfmTableFromMarkdown() {
5
+ return {
6
+ enter: {
7
+ table: enterTable,
8
+ tableData: enterCell,
9
+ tableHeader: enterCell,
10
+ tableRow: enterRow
11
+ },
12
+ exit: {
13
+ codeText: exitCodeText,
14
+ table: exitTable,
15
+ tableData: exit,
16
+ tableHeader: exit,
17
+ tableRow: exit
18
+ }
19
+ };
20
+ }
21
+ function enterTable(token) {
22
+ const align = token._align;
23
+ this.enter(
24
+ {
25
+ type: "table",
26
+ align: align.map(function(d) {
27
+ return d === "none" ? null : d;
28
+ }),
29
+ children: []
30
+ },
31
+ token
32
+ );
33
+ this.data.inTable = true;
34
+ }
35
+ function exitTable(token) {
36
+ this.exit(token);
37
+ this.data.inTable = void 0;
38
+ }
39
+ function enterRow(token) {
40
+ this.enter({ type: "tableRow", children: [] }, token);
41
+ }
42
+ function exit(token) {
43
+ this.exit(token);
44
+ }
45
+ function enterCell(token) {
46
+ this.enter({ type: "tableCell", children: [] }, token);
47
+ }
48
+ function exitCodeText(token) {
49
+ let value = this.resume();
50
+ if (this.data.inTable) {
51
+ value = value.replace(/\\([\\|])/g, replace);
52
+ }
53
+ const node = this.stack[this.stack.length - 1];
54
+ ok(node.type === "inlineCode");
55
+ node.value = value;
56
+ this.exit(token);
57
+ }
58
+ function replace($0, $1) {
59
+ return $1 === "|" ? $1 : $0;
60
+ }
61
+ function gfmTableToMarkdown(options) {
62
+ const settings = options || {};
63
+ const padding = settings.tableCellPadding;
64
+ const alignDelimiters = settings.tablePipeAlign;
65
+ const stringLength = settings.stringLength;
66
+ const around = padding ? " " : "|";
67
+ return {
68
+ unsafe: [
69
+ { character: "\r", inConstruct: "tableCell" },
70
+ { character: "\n", inConstruct: "tableCell" },
71
+ // A pipe, when followed by a tab or space (padding), or a dash or colon
72
+ // (unpadded delimiter row), could result in a table.
73
+ { atBreak: true, character: "|", after: "[ :-]" },
74
+ // A pipe in a cell must be encoded.
75
+ { character: "|", inConstruct: "tableCell" },
76
+ // A colon must be followed by a dash, in which case it could start a
77
+ // delimiter row.
78
+ { atBreak: true, character: ":", after: "-" },
79
+ // A delimiter row can also start with a dash, when followed by more
80
+ // dashes, a colon, or a pipe.
81
+ // This is a stricter version than the built in check for lists, thematic
82
+ // breaks, and setex heading underlines though:
83
+ // <https://github.com/syntax-tree/mdast-util-to-markdown/blob/51a2038/lib/unsafe.js#L57>
84
+ { atBreak: true, character: "-", after: "[:|-]" }
85
+ ],
86
+ handlers: {
87
+ inlineCode: inlineCodeWithTable,
88
+ table: handleTable,
89
+ tableCell: handleTableCell,
90
+ tableRow: handleTableRow
91
+ }
92
+ };
93
+ function handleTable(node, _, state, info) {
94
+ return serializeData(handleTableAsData(node, state, info), node.align);
95
+ }
96
+ function handleTableRow(node, _, state, info) {
97
+ const row = handleTableRowAsData(node, state, info);
98
+ const value = serializeData([row]);
99
+ return value.slice(0, value.indexOf("\n"));
100
+ }
101
+ function handleTableCell(node, _, state, info) {
102
+ const exit2 = state.enter("tableCell");
103
+ const subexit = state.enter("phrasing");
104
+ const value = state.containerPhrasing(node, {
105
+ ...info,
106
+ before: around,
107
+ after: around
108
+ });
109
+ subexit();
110
+ exit2();
111
+ return value;
112
+ }
113
+ function serializeData(matrix, align) {
114
+ return markdownTable(matrix, {
115
+ align,
116
+ // @ts-expect-error: `markdown-table` types should support `null`.
117
+ alignDelimiters,
118
+ // @ts-expect-error: `markdown-table` types should support `null`.
119
+ padding,
120
+ // @ts-expect-error: `markdown-table` types should support `null`.
121
+ stringLength
122
+ });
123
+ }
124
+ function handleTableAsData(node, state, info) {
125
+ const children = node.children;
126
+ let index = -1;
127
+ const result = [];
128
+ const subexit = state.enter("table");
129
+ while (++index < children.length) {
130
+ result[index] = handleTableRowAsData(children[index], state, info);
131
+ }
132
+ subexit();
133
+ return result;
134
+ }
135
+ function handleTableRowAsData(node, state, info) {
136
+ const children = node.children;
137
+ let index = -1;
138
+ const result = [];
139
+ const subexit = state.enter("tableRow");
140
+ while (++index < children.length) {
141
+ result[index] = handleTableCell(children[index], node, state, info);
142
+ }
143
+ subexit();
144
+ return result;
145
+ }
146
+ function inlineCodeWithTable(node, parent, state) {
147
+ let value = handle.inlineCode(node, parent, state);
148
+ if (state.stack.includes("tableCell")) {
149
+ value = value.replace(/\|/g, "\\$&");
150
+ }
151
+ return value;
152
+ }
153
+ }
154
+ export {
155
+ gfmTableToMarkdown as a,
156
+ gfmTableFromMarkdown as g
157
+ };
@@ -0,0 +1,77 @@
1
+ import { o as ok } from "./devlop.mjs";
2
+ import { h as handle } from "./mdast-util-to-markdown.mjs";
3
+ function gfmTaskListItemFromMarkdown() {
4
+ return {
5
+ exit: {
6
+ taskListCheckValueChecked: exitCheck,
7
+ taskListCheckValueUnchecked: exitCheck,
8
+ paragraph: exitParagraphWithTaskListItem
9
+ }
10
+ };
11
+ }
12
+ function gfmTaskListItemToMarkdown() {
13
+ return {
14
+ unsafe: [{ atBreak: true, character: "-", after: "[:|-]" }],
15
+ handlers: { listItem: listItemWithTaskListItem }
16
+ };
17
+ }
18
+ function exitCheck(token) {
19
+ const node = this.stack[this.stack.length - 2];
20
+ ok(node.type === "listItem");
21
+ node.checked = token.type === "taskListCheckValueChecked";
22
+ }
23
+ function exitParagraphWithTaskListItem(token) {
24
+ const parent = this.stack[this.stack.length - 2];
25
+ if (parent && parent.type === "listItem" && typeof parent.checked === "boolean") {
26
+ const node = this.stack[this.stack.length - 1];
27
+ ok(node.type === "paragraph");
28
+ const head = node.children[0];
29
+ if (head && head.type === "text") {
30
+ const siblings = parent.children;
31
+ let index = -1;
32
+ let firstParaghraph;
33
+ while (++index < siblings.length) {
34
+ const sibling = siblings[index];
35
+ if (sibling.type === "paragraph") {
36
+ firstParaghraph = sibling;
37
+ break;
38
+ }
39
+ }
40
+ if (firstParaghraph === node) {
41
+ head.value = head.value.slice(1);
42
+ if (head.value.length === 0) {
43
+ node.children.shift();
44
+ } else if (node.position && head.position && typeof head.position.start.offset === "number") {
45
+ head.position.start.column++;
46
+ head.position.start.offset++;
47
+ node.position.start = Object.assign({}, head.position.start);
48
+ }
49
+ }
50
+ }
51
+ }
52
+ this.exit(token);
53
+ }
54
+ function listItemWithTaskListItem(node, parent, state, info) {
55
+ const head = node.children[0];
56
+ const checkable = typeof node.checked === "boolean" && head && head.type === "paragraph";
57
+ const checkbox = "[" + (node.checked ? "x" : " ") + "] ";
58
+ const tracker = state.createTracker(info);
59
+ if (checkable) {
60
+ tracker.move(checkbox);
61
+ }
62
+ let value = handle.listItem(node, parent, state, {
63
+ ...info,
64
+ ...tracker.current()
65
+ });
66
+ if (checkable) {
67
+ value = value.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, check);
68
+ }
69
+ return value;
70
+ function check($0) {
71
+ return $0 + checkbox;
72
+ }
73
+ }
74
+ export {
75
+ gfmTaskListItemToMarkdown as a,
76
+ gfmTaskListItemFromMarkdown as g
77
+ };
@@ -0,0 +1,29 @@
1
+ import { g as gfmAutolinkLiteralFromMarkdown, a as gfmAutolinkLiteralToMarkdown } from "./mdast-util-gfm-autolink-literal+[...].mjs";
2
+ import { g as gfmFootnoteFromMarkdown, a as gfmFootnoteToMarkdown } from "./mdast-util-gfm-footnote.mjs";
3
+ import { g as gfmStrikethroughFromMarkdown, a as gfmStrikethroughToMarkdown } from "./mdast-util-gfm-strikethrough.mjs";
4
+ import { g as gfmTableFromMarkdown, a as gfmTableToMarkdown } from "./mdast-util-gfm-table.mjs";
5
+ import { g as gfmTaskListItemFromMarkdown, a as gfmTaskListItemToMarkdown } from "./mdast-util-gfm-task-list-item.mjs";
6
+ function gfmFromMarkdown() {
7
+ return [
8
+ gfmAutolinkLiteralFromMarkdown(),
9
+ gfmFootnoteFromMarkdown(),
10
+ gfmStrikethroughFromMarkdown(),
11
+ gfmTableFromMarkdown(),
12
+ gfmTaskListItemFromMarkdown()
13
+ ];
14
+ }
15
+ function gfmToMarkdown(options) {
16
+ return {
17
+ extensions: [
18
+ gfmAutolinkLiteralToMarkdown(),
19
+ gfmFootnoteToMarkdown(options),
20
+ gfmStrikethroughToMarkdown(),
21
+ gfmTableToMarkdown(options),
22
+ gfmTaskListItemToMarkdown()
23
+ ]
24
+ };
25
+ }
26
+ export {
27
+ gfmToMarkdown as a,
28
+ gfmFromMarkdown as g
29
+ };
@@ -0,0 +1,30 @@
1
+ import { c as convert } from "./unist-util-is.mjs";
2
+ const phrasing = (
3
+ /** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
4
+ convert([
5
+ "break",
6
+ "delete",
7
+ "emphasis",
8
+ // To do: next major: removed since footnotes were added to GFM.
9
+ "footnote",
10
+ "footnoteReference",
11
+ "image",
12
+ "imageReference",
13
+ "inlineCode",
14
+ // Enabled by `mdast-util-math`:
15
+ "inlineMath",
16
+ "link",
17
+ "linkReference",
18
+ // Enabled by `mdast-util-mdx`:
19
+ "mdxJsxTextElement",
20
+ // Enabled by `mdast-util-mdx`:
21
+ "mdxTextExpression",
22
+ "strong",
23
+ "text",
24
+ // Enabled by `mdast-util-directive`:
25
+ "textDirective"
26
+ ])
27
+ );
28
+ export {
29
+ phrasing as p
30
+ };