@langchain/macaw-components 1.7.2 → 1.7.4
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/dist/catalog.json +730 -713
- package/dist/components/Code/codeLanguages.js +4 -3
- package/dist/components/Code/codeLanguages.js.map +1 -1
- package/dist/components/MarkdownDisplay/MarkdownCodeBlock.d.ts +8 -0
- package/dist/components/MarkdownDisplay/MarkdownCodeBlock.js +25 -0
- package/dist/components/MarkdownDisplay/MarkdownCodeBlock.js.map +1 -0
- package/dist/components/MarkdownDisplay/MarkdownDisplay.d.ts +63 -0
- package/dist/components/MarkdownDisplay/MarkdownDisplay.js +318 -0
- package/dist/components/MarkdownDisplay/MarkdownDisplay.js.map +1 -0
- package/dist/components/MarkdownDisplay/index.d.ts +3 -0
- package/dist/components/MarkdownDisplay/index.js +3 -0
- package/dist/components/MarkdownDisplay/markdownPlugins.d.ts +18 -0
- package/dist/components/MarkdownDisplay/markdownPlugins.js +93 -0
- package/dist/components/MarkdownDisplay/markdownPlugins.js.map +1 -0
- package/dist/components/MarkdownDisplay/prepareMarkdownXml.d.ts +14 -0
- package/dist/components/MarkdownDisplay/prepareMarkdownXml.js +313 -0
- package/dist/components/MarkdownDisplay/prepareMarkdownXml.js.map +1 -0
- package/dist/icons/LongTailPhosphorIcons.js +1 -1
- package/dist/utilities.css +1 -1
- package/dist/utils/cn.js +2 -0
- package/dist/utils/cn.js.map +1 -1
- package/docs/DESIGN.md +73 -0
- package/docs/STYLES.md +5 -2
- package/package.json +13 -2
- package/tailwind.preset.cjs +1 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When the content contains custom XML tags (non-standard HTML), treat ALL
|
|
3
|
+
* block-level tags as XML structure — including standard HTML elements like
|
|
4
|
+
* `<input>` or `<div>` that may appear alongside custom tags.
|
|
5
|
+
*
|
|
6
|
+
* Processes line by line with a tag stack to track nesting depth. Opening
|
|
7
|
+
* tags become bold `**[tagname]**` labels; content lines are prefixed with
|
|
8
|
+
* blockquote markers (`>`) per nesting level. Inline tags are stripped.
|
|
9
|
+
*
|
|
10
|
+
* If no custom XML tags are detected the content is returned unchanged so
|
|
11
|
+
* literal-tag rendering is unaffected. Oversized input is left unchanged for
|
|
12
|
+
* the plain-text fallback. This helper can also prepare text for a search index.
|
|
13
|
+
*/
|
|
14
|
+
export declare function prepareMarkdownXml(content: string): string;
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import "../Code/constants.js";
|
|
2
|
+
//#region packages/components/src/components/MarkdownDisplay/prepareMarkdownXml.ts
|
|
3
|
+
var CDATA_OPEN = "<![CDATA[";
|
|
4
|
+
var CDATA_CLOSE = "]]>";
|
|
5
|
+
var BLOCK_OPEN_TAG = /^<([a-zA-Z][a-zA-Z0-9_-]*)(\s[^>]*)?\s*\/?>(?:<!\[CDATA\[)?$/;
|
|
6
|
+
var BLOCK_SELF_CLOSING_TAG = /\/\s*>$/;
|
|
7
|
+
var BLOCK_CLOSE_TAG = /^(?:\]\]>)?<\/([a-zA-Z][a-zA-Z0-9_-]*)>$/;
|
|
8
|
+
/**
|
|
9
|
+
* Indices of block-level opening tags that have their own matching close tag.
|
|
10
|
+
* A close pairs with the nearest open of the same name; opens left above it are
|
|
11
|
+
* unclosed. Lets void-element names (e.g. <input>...</input>) nest as wrappers.
|
|
12
|
+
*/
|
|
13
|
+
function findClosedOpenTags(lines) {
|
|
14
|
+
const closed = /* @__PURE__ */ new Set();
|
|
15
|
+
const stack = [];
|
|
16
|
+
let inFencedCodeBlock = false;
|
|
17
|
+
let inCdata = false;
|
|
18
|
+
for (const [index, line] of lines.entries()) {
|
|
19
|
+
const trimmed = line.trim();
|
|
20
|
+
if (inCdata) {
|
|
21
|
+
if (!trimmed.startsWith(CDATA_CLOSE)) continue;
|
|
22
|
+
inCdata = false;
|
|
23
|
+
}
|
|
24
|
+
if (trimmed.startsWith("```")) {
|
|
25
|
+
inFencedCodeBlock = !inFencedCodeBlock;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (inFencedCodeBlock) continue;
|
|
29
|
+
const openName = trimmed.match(BLOCK_OPEN_TAG)?.[1];
|
|
30
|
+
if (openName && !BLOCK_SELF_CLOSING_TAG.test(trimmed)) {
|
|
31
|
+
stack.push({
|
|
32
|
+
name: openName.toLowerCase(),
|
|
33
|
+
index
|
|
34
|
+
});
|
|
35
|
+
inCdata = trimmed.endsWith(CDATA_OPEN);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const closeName = trimmed.match(BLOCK_CLOSE_TAG)?.[1].toLowerCase();
|
|
39
|
+
if (!closeName) continue;
|
|
40
|
+
let match = stack.length - 1;
|
|
41
|
+
while (match >= 0 && stack[match].name !== closeName) match--;
|
|
42
|
+
if (match === -1) continue;
|
|
43
|
+
closed.add(stack[match].index);
|
|
44
|
+
stack.length = match;
|
|
45
|
+
}
|
|
46
|
+
return closed;
|
|
47
|
+
}
|
|
48
|
+
var STANDARD_HTML_ELEMENTS = /* @__PURE__ */ new Set([
|
|
49
|
+
"a",
|
|
50
|
+
"abbr",
|
|
51
|
+
"address",
|
|
52
|
+
"article",
|
|
53
|
+
"aside",
|
|
54
|
+
"audio",
|
|
55
|
+
"b",
|
|
56
|
+
"blockquote",
|
|
57
|
+
"body",
|
|
58
|
+
"br",
|
|
59
|
+
"button",
|
|
60
|
+
"canvas",
|
|
61
|
+
"caption",
|
|
62
|
+
"cite",
|
|
63
|
+
"code",
|
|
64
|
+
"col",
|
|
65
|
+
"colgroup",
|
|
66
|
+
"data",
|
|
67
|
+
"datalist",
|
|
68
|
+
"dd",
|
|
69
|
+
"del",
|
|
70
|
+
"details",
|
|
71
|
+
"dfn",
|
|
72
|
+
"dialog",
|
|
73
|
+
"div",
|
|
74
|
+
"dl",
|
|
75
|
+
"dt",
|
|
76
|
+
"em",
|
|
77
|
+
"embed",
|
|
78
|
+
"fieldset",
|
|
79
|
+
"figcaption",
|
|
80
|
+
"figure",
|
|
81
|
+
"footer",
|
|
82
|
+
"form",
|
|
83
|
+
"h1",
|
|
84
|
+
"h2",
|
|
85
|
+
"h3",
|
|
86
|
+
"h4",
|
|
87
|
+
"h5",
|
|
88
|
+
"h6",
|
|
89
|
+
"head",
|
|
90
|
+
"header",
|
|
91
|
+
"hr",
|
|
92
|
+
"html",
|
|
93
|
+
"i",
|
|
94
|
+
"iframe",
|
|
95
|
+
"img",
|
|
96
|
+
"input",
|
|
97
|
+
"ins",
|
|
98
|
+
"kbd",
|
|
99
|
+
"label",
|
|
100
|
+
"legend",
|
|
101
|
+
"li",
|
|
102
|
+
"link",
|
|
103
|
+
"main",
|
|
104
|
+
"map",
|
|
105
|
+
"mark",
|
|
106
|
+
"menu",
|
|
107
|
+
"meta",
|
|
108
|
+
"meter",
|
|
109
|
+
"nav",
|
|
110
|
+
"noscript",
|
|
111
|
+
"object",
|
|
112
|
+
"ol",
|
|
113
|
+
"optgroup",
|
|
114
|
+
"option",
|
|
115
|
+
"output",
|
|
116
|
+
"p",
|
|
117
|
+
"picture",
|
|
118
|
+
"pre",
|
|
119
|
+
"progress",
|
|
120
|
+
"q",
|
|
121
|
+
"s",
|
|
122
|
+
"samp",
|
|
123
|
+
"script",
|
|
124
|
+
"section",
|
|
125
|
+
"select",
|
|
126
|
+
"small",
|
|
127
|
+
"source",
|
|
128
|
+
"span",
|
|
129
|
+
"strong",
|
|
130
|
+
"style",
|
|
131
|
+
"sub",
|
|
132
|
+
"summary",
|
|
133
|
+
"sup",
|
|
134
|
+
"table",
|
|
135
|
+
"tbody",
|
|
136
|
+
"td",
|
|
137
|
+
"template",
|
|
138
|
+
"textarea",
|
|
139
|
+
"tfoot",
|
|
140
|
+
"th",
|
|
141
|
+
"thead",
|
|
142
|
+
"time",
|
|
143
|
+
"title",
|
|
144
|
+
"tr",
|
|
145
|
+
"track",
|
|
146
|
+
"u",
|
|
147
|
+
"ul",
|
|
148
|
+
"var",
|
|
149
|
+
"video",
|
|
150
|
+
"wbr"
|
|
151
|
+
]);
|
|
152
|
+
var INLINE_TAG = /<\/?[a-zA-Z][a-zA-Z0-9_-]*(\s[^>]*)?>/g;
|
|
153
|
+
function transformOutsideCode(text, transform) {
|
|
154
|
+
const delimiters = [...text.matchAll(/`+/g)];
|
|
155
|
+
let result = "";
|
|
156
|
+
let lastIndex = 0;
|
|
157
|
+
for (let index = 0; index < delimiters.length; index++) {
|
|
158
|
+
const open = delimiters[index];
|
|
159
|
+
let escapeStart = open.index;
|
|
160
|
+
while (escapeStart > 0 && text[escapeStart - 1] === "\\") escapeStart--;
|
|
161
|
+
const escaped = (open.index - escapeStart) % 2;
|
|
162
|
+
const start = open.index + escaped;
|
|
163
|
+
const length = open[0].length - escaped;
|
|
164
|
+
if (length === 0) continue;
|
|
165
|
+
let closeIndex = index + 1;
|
|
166
|
+
while (closeIndex < delimiters.length && delimiters[closeIndex][0].length !== length) closeIndex++;
|
|
167
|
+
if (closeIndex === delimiters.length) continue;
|
|
168
|
+
const close = delimiters[closeIndex];
|
|
169
|
+
const end = close.index + close[0].length;
|
|
170
|
+
result += transform(text.slice(lastIndex, start)) + text.slice(start, end);
|
|
171
|
+
lastIndex = end;
|
|
172
|
+
index = closeIndex;
|
|
173
|
+
}
|
|
174
|
+
return result + transform(text.slice(lastIndex));
|
|
175
|
+
}
|
|
176
|
+
function replaceProseTags(line) {
|
|
177
|
+
let result = "";
|
|
178
|
+
let lastIndex = 0;
|
|
179
|
+
for (const match of line.matchAll(INLINE_TAG)) {
|
|
180
|
+
const start = match.index ?? 0;
|
|
181
|
+
result += line.slice(lastIndex, start).replaceAll("<", "<").replaceAll(">", ">");
|
|
182
|
+
if (!match[0].startsWith("</")) {
|
|
183
|
+
const name = match[0].match(/^<([a-zA-Z][a-zA-Z0-9_-]*)/)?.[1];
|
|
184
|
+
if (name) result += `**[${name}]** `;
|
|
185
|
+
}
|
|
186
|
+
lastIndex = start + match[0].length;
|
|
187
|
+
}
|
|
188
|
+
return result + line.slice(lastIndex).replaceAll("<", "<").replaceAll(">", ">");
|
|
189
|
+
}
|
|
190
|
+
function replaceInlineTags(line) {
|
|
191
|
+
const quotePrefix = line.match(/^(?: {0,3}>[\t ]?)+/)?.[0] ?? "";
|
|
192
|
+
return quotePrefix + transformOutsideCode(line.slice(quotePrefix.length), replaceProseTags);
|
|
193
|
+
}
|
|
194
|
+
function escapeOutsideCode(text) {
|
|
195
|
+
return transformOutsideCode(text, (prose) => prose.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">"));
|
|
196
|
+
}
|
|
197
|
+
var HTML_VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
198
|
+
"area",
|
|
199
|
+
"base",
|
|
200
|
+
"br",
|
|
201
|
+
"col",
|
|
202
|
+
"embed",
|
|
203
|
+
"hr",
|
|
204
|
+
"img",
|
|
205
|
+
"input",
|
|
206
|
+
"link",
|
|
207
|
+
"meta",
|
|
208
|
+
"param",
|
|
209
|
+
"source",
|
|
210
|
+
"track",
|
|
211
|
+
"wbr"
|
|
212
|
+
]);
|
|
213
|
+
/** Returns true if the content contains at least one non-standard block-level tag. */
|
|
214
|
+
function hasCustomXmlTags(content) {
|
|
215
|
+
let inFencedCodeBlock = false;
|
|
216
|
+
for (const line of content.split("\n")) {
|
|
217
|
+
const trimmed = line.trim();
|
|
218
|
+
if (trimmed.startsWith("```")) {
|
|
219
|
+
inFencedCodeBlock = !inFencedCodeBlock;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (inFencedCodeBlock) continue;
|
|
223
|
+
const match = trimmed.match(BLOCK_OPEN_TAG);
|
|
224
|
+
if (match && !STANDARD_HTML_ELEMENTS.has(match[1].toLowerCase())) return true;
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* When the content contains custom XML tags (non-standard HTML), treat ALL
|
|
230
|
+
* block-level tags as XML structure — including standard HTML elements like
|
|
231
|
+
* `<input>` or `<div>` that may appear alongside custom tags.
|
|
232
|
+
*
|
|
233
|
+
* Processes line by line with a tag stack to track nesting depth. Opening
|
|
234
|
+
* tags become bold `**[tagname]**` labels; content lines are prefixed with
|
|
235
|
+
* blockquote markers (`>`) per nesting level. Inline tags are stripped.
|
|
236
|
+
*
|
|
237
|
+
* If no custom XML tags are detected the content is returned unchanged so
|
|
238
|
+
* literal-tag rendering is unaffected. Oversized input is left unchanged for
|
|
239
|
+
* the plain-text fallback. This helper can also prepare text for a search index.
|
|
240
|
+
*/
|
|
241
|
+
function prepareMarkdownXml(content) {
|
|
242
|
+
if (content.length > 2e4 || !hasCustomXmlTags(content)) return content;
|
|
243
|
+
const lines = content.split("\n");
|
|
244
|
+
const output = [];
|
|
245
|
+
const tagStack = [];
|
|
246
|
+
let inFencedCodeBlock = false;
|
|
247
|
+
let inCdata = false;
|
|
248
|
+
const closedOpenTags = findClosedOpenTags(lines);
|
|
249
|
+
for (const [index, line] of lines.entries()) {
|
|
250
|
+
const trimmed = line.trim();
|
|
251
|
+
if (inCdata) {
|
|
252
|
+
if (trimmed.startsWith(CDATA_CLOSE)) {
|
|
253
|
+
inCdata = false;
|
|
254
|
+
inFencedCodeBlock = false;
|
|
255
|
+
if (trimmed === CDATA_CLOSE) continue;
|
|
256
|
+
} else {
|
|
257
|
+
const depth = tagStack.length;
|
|
258
|
+
const prefix = "> ".repeat(depth);
|
|
259
|
+
const joined = line.replaceAll(`${CDATA_CLOSE}${CDATA_OPEN}`, "");
|
|
260
|
+
const isFence = joined.trim().startsWith("```");
|
|
261
|
+
const literal = isFence || inFencedCodeBlock ? joined : escapeOutsideCode(joined);
|
|
262
|
+
if (isFence) inFencedCodeBlock = !inFencedCodeBlock;
|
|
263
|
+
output.push(trimmed === "" ? prefix.trimEnd() : `${prefix}${literal}`);
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (trimmed.startsWith("```")) {
|
|
268
|
+
inFencedCodeBlock = !inFencedCodeBlock;
|
|
269
|
+
const depth = tagStack.length;
|
|
270
|
+
output.push(depth > 0 ? `${"> ".repeat(depth)}${line}` : line);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (inFencedCodeBlock) {
|
|
274
|
+
const depth = tagStack.length;
|
|
275
|
+
output.push(depth > 0 ? `${"> ".repeat(depth)}${line}` : line);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
const openMatch = trimmed.match(BLOCK_OPEN_TAG);
|
|
279
|
+
if (openMatch) {
|
|
280
|
+
const tagName = openMatch[1];
|
|
281
|
+
if (BLOCK_SELF_CLOSING_TAG.test(trimmed) || HTML_VOID_ELEMENTS.has(tagName.toLowerCase()) && !closedOpenTags.has(index)) {
|
|
282
|
+
const depth = tagStack.length;
|
|
283
|
+
const prefix = depth > 0 ? "> ".repeat(depth) : "";
|
|
284
|
+
output.push(`${prefix}**[${tagName}]**`);
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
tagStack.push(tagName);
|
|
288
|
+
const depth = tagStack.length;
|
|
289
|
+
const prefix = "> ".repeat(depth);
|
|
290
|
+
if (depth > 1) output.push("> ".repeat(depth - 1).trimEnd());
|
|
291
|
+
output.push(`${prefix}**[${tagName}]**`);
|
|
292
|
+
inCdata = trimmed.endsWith(CDATA_OPEN);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
const closeMatch = trimmed.match(BLOCK_CLOSE_TAG);
|
|
296
|
+
if (closeMatch) {
|
|
297
|
+
if (tagStack.length > 0 && tagStack[tagStack.length - 1].toLowerCase() === closeMatch[1].toLowerCase()) tagStack.pop();
|
|
298
|
+
output.push(tagStack.length > 0 ? "> ".repeat(tagStack.length).trimEnd() : "");
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
const depth = tagStack.length;
|
|
302
|
+
const stripped = replaceInlineTags(line);
|
|
303
|
+
if (depth > 0) {
|
|
304
|
+
const prefix = "> ".repeat(depth);
|
|
305
|
+
output.push(trimmed === "" ? prefix.trimEnd() : `${prefix}${stripped}`);
|
|
306
|
+
} else output.push(stripped);
|
|
307
|
+
}
|
|
308
|
+
return output.join("\n");
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
export { prepareMarkdownXml };
|
|
312
|
+
|
|
313
|
+
//# sourceMappingURL=prepareMarkdownXml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareMarkdownXml.js","names":[],"sources":["../../../src/components/MarkdownDisplay/prepareMarkdownXml.ts"],"sourcesContent":["import { MAX_TEXT_LENGTH } from '../Code/constants';\n\nconst CDATA_OPEN = '<![CDATA[';\nconst CDATA_CLOSE = ']]>';\n\n// Matches a block-level opening tag (the entire trimmed line is just a tag,\n// optionally followed by the CDATA open marker, as in <tag><![CDATA[).\n// Captures self-closing tags (<tag /> or <tag/>) as well as normal opening tags.\nconst BLOCK_OPEN_TAG =\n /^<([a-zA-Z][a-zA-Z0-9_-]*)(\\s[^>]*)?\\s*\\/?>(?:<!\\[CDATA\\[)?$/;\nconst BLOCK_SELF_CLOSING_TAG = /\\/\\s*>$/;\n// A close tag may share its line with the CDATA close marker, as in ]]></tag>.\nconst BLOCK_CLOSE_TAG = /^(?:\\]\\]>)?<\\/([a-zA-Z][a-zA-Z0-9_-]*)>$/;\n\n/**\n * Indices of block-level opening tags that have their own matching close tag.\n * A close pairs with the nearest open of the same name; opens left above it are\n * unclosed. Lets void-element names (e.g. <input>...</input>) nest as wrappers.\n */\nfunction findClosedOpenTags(lines: string[]): Set<number> {\n const closed = new Set<number>();\n const stack: { name: string; index: number }[] = [];\n let inFencedCodeBlock = false;\n let inCdata = false;\n for (const [index, line] of lines.entries()) {\n const trimmed = line.trim();\n // A CDATA body is literal text, so a tag inside it neither opens nor closes.\n if (inCdata) {\n if (!trimmed.startsWith(CDATA_CLOSE)) continue;\n inCdata = false;\n }\n if (trimmed.startsWith('```')) {\n inFencedCodeBlock = !inFencedCodeBlock;\n continue;\n }\n if (inFencedCodeBlock) continue;\n const openName = trimmed.match(BLOCK_OPEN_TAG)?.[1];\n if (openName && !BLOCK_SELF_CLOSING_TAG.test(trimmed)) {\n stack.push({ name: openName.toLowerCase(), index });\n inCdata = trimmed.endsWith(CDATA_OPEN);\n continue;\n }\n const closeName = trimmed.match(BLOCK_CLOSE_TAG)?.[1].toLowerCase();\n if (!closeName) continue;\n let match = stack.length - 1;\n while (match >= 0 && stack[match].name !== closeName) match--;\n if (match === -1) continue;\n closed.add(stack[match].index);\n stack.length = match;\n }\n return closed;\n}\n\n// Standard HTML alone does not activate XML section handling.\n// Non-standard tags (e.g. <example>, <reasoning>) are treated as HTML blocks by the\n// CommonMark parser, which causes remark to swallow the inner content as raw HTML\n// instead of parsing it as markdown. We pre-process them out so the inner text renders\n// with proper styling.\nconst STANDARD_HTML_ELEMENTS = new Set([\n 'a',\n 'abbr',\n 'address',\n 'article',\n 'aside',\n 'audio',\n 'b',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'datalist',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hr',\n 'html',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'link',\n 'main',\n 'map',\n 'mark',\n 'menu',\n 'meta',\n 'meter',\n 'nav',\n 'noscript',\n 'object',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 's',\n 'samp',\n 'script',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n 'strong',\n 'style',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'title',\n 'tr',\n 'track',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n]);\n\nconst INLINE_TAG = /<\\/?[a-zA-Z][a-zA-Z0-9_-]*(\\s[^>]*)?>/g;\n\n// Code spans close with a backtick run of the same length. Shorter runs and\n// backslashes inside the span are literal; only an opening run can be escaped.\nfunction transformOutsideCode(\n text: string,\n transform: (prose: string) => string\n): string {\n const delimiters = [...text.matchAll(/`+/g)];\n let result = '';\n let lastIndex = 0;\n for (let index = 0; index < delimiters.length; index++) {\n const open = delimiters[index];\n let escapeStart = open.index;\n while (escapeStart > 0 && text[escapeStart - 1] === '\\\\') escapeStart--;\n const escaped = (open.index - escapeStart) % 2;\n const start = open.index + escaped;\n const length = open[0].length - escaped;\n // A backslash escapes only the first tick, leaving the rest of the run\n // available as a code delimiter.\n if (length === 0) continue;\n\n let closeIndex = index + 1;\n while (\n closeIndex < delimiters.length &&\n delimiters[closeIndex][0].length !== length\n ) {\n closeIndex++;\n }\n // An unmatched delimiter is ordinary Markdown text.\n if (closeIndex === delimiters.length) continue;\n const close = delimiters[closeIndex];\n const end = close.index + close[0].length;\n result += transform(text.slice(lastIndex, start)) + text.slice(start, end);\n lastIndex = end;\n index = closeIndex;\n }\n return result + transform(text.slice(lastIndex));\n}\n\nfunction replaceProseTags(line: string): string {\n let result = '';\n let lastIndex = 0;\n for (const match of line.matchAll(INLINE_TAG)) {\n const start = match.index ?? 0;\n result += line\n .slice(lastIndex, start)\n .replaceAll('<', '<')\n .replaceAll('>', '>');\n if (!match[0].startsWith('</')) {\n const name = match[0].match(/^<([a-zA-Z][a-zA-Z0-9_-]*)/)?.[1];\n if (name) result += `**[${name}]** `;\n }\n lastIndex = start + match[0].length;\n }\n return (\n result +\n line.slice(lastIndex).replaceAll('<', '<').replaceAll('>', '>')\n );\n}\n\nfunction replaceInlineTags(line: string): string {\n // Preserve native (possibly nested) Markdown blockquotes before escaping\n // prose. XML nesting adds its own markers around this unchanged prefix.\n const quotePrefix = line.match(/^(?: {0,3}>[\\t ]?)+/)?.[0] ?? '';\n return (\n quotePrefix +\n transformOutsideCode(line.slice(quotePrefix.length), replaceProseTags)\n );\n}\n\n// Markdown keeps a code span's characters as typed but decodes entities in\n// prose, so only the text between code spans is escaped.\nfunction escapeOutsideCode(text: string): string {\n return transformOutsideCode(text, (prose) =>\n prose\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n );\n}\n\n// HTML void elements never have a closing tag, so they must not be pushed onto\n// the tag stack — otherwise they would permanently corrupt the nesting depth.\nconst HTML_VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/** Returns true if the content contains at least one non-standard block-level tag. */\nfunction hasCustomXmlTags(content: string): boolean {\n let inFencedCodeBlock = false;\n for (const line of content.split('\\n')) {\n const trimmed = line.trim();\n if (trimmed.startsWith('```')) {\n inFencedCodeBlock = !inFencedCodeBlock;\n continue;\n }\n if (inFencedCodeBlock) continue;\n const match = trimmed.match(BLOCK_OPEN_TAG);\n if (match && !STANDARD_HTML_ELEMENTS.has(match[1].toLowerCase())) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * When the content contains custom XML tags (non-standard HTML), treat ALL\n * block-level tags as XML structure — including standard HTML elements like\n * `<input>` or `<div>` that may appear alongside custom tags.\n *\n * Processes line by line with a tag stack to track nesting depth. Opening\n * tags become bold `**[tagname]**` labels; content lines are prefixed with\n * blockquote markers (`>`) per nesting level. Inline tags are stripped.\n *\n * If no custom XML tags are detected the content is returned unchanged so\n * literal-tag rendering is unaffected. Oversized input is left unchanged for\n * the plain-text fallback. This helper can also prepare text for a search index.\n */\nexport function prepareMarkdownXml(content: string): string {\n if (content.length > MAX_TEXT_LENGTH || !hasCustomXmlTags(content))\n return content;\n\n const lines = content.split('\\n');\n const output: string[] = [];\n const tagStack: string[] = [];\n let inFencedCodeBlock = false;\n let inCdata = false;\n const closedOpenTags = findClosedOpenTags(lines);\n\n for (const [index, line] of lines.entries()) {\n const trimmed = line.trim();\n\n // A CDATA body is literal text: no tag in it becomes a label or a nested\n // section. The producer splits any ']]>' in the text into two CDATA\n // sections, so that seam is joined back before display. Markdown shows a\n // fence's text as typed, so only lines outside a fence are escaped, and a\n // fence left open in the body ends with the body.\n if (inCdata) {\n if (trimmed.startsWith(CDATA_CLOSE)) {\n inCdata = false;\n inFencedCodeBlock = false;\n if (trimmed === CDATA_CLOSE) continue;\n } else {\n const depth = tagStack.length;\n const prefix = '> '.repeat(depth);\n const joined = line.replaceAll(`${CDATA_CLOSE}${CDATA_OPEN}`, '');\n const isFence = joined.trim().startsWith('```');\n const literal =\n isFence || inFencedCodeBlock ? joined : escapeOutsideCode(joined);\n if (isFence) inFencedCodeBlock = !inFencedCodeBlock;\n output.push(trimmed === '' ? prefix.trimEnd() : `${prefix}${literal}`);\n continue;\n }\n }\n\n // Toggle fenced code block state. Lines inside code blocks are passed\n // through unchanged so tags in code examples are not transformed.\n if (trimmed.startsWith('```')) {\n inFencedCodeBlock = !inFencedCodeBlock;\n const depth = tagStack.length;\n output.push(depth > 0 ? `${'> '.repeat(depth)}${line}` : line);\n continue;\n }\n if (inFencedCodeBlock) {\n const depth = tagStack.length;\n output.push(depth > 0 ? `${'> '.repeat(depth)}${line}` : line);\n continue;\n }\n\n const openMatch = trimmed.match(BLOCK_OPEN_TAG);\n if (openMatch) {\n const tagName = openMatch[1];\n const isSelfClosing =\n BLOCK_SELF_CLOSING_TAG.test(trimmed) ||\n (HTML_VOID_ELEMENTS.has(tagName.toLowerCase()) &&\n !closedOpenTags.has(index));\n if (isSelfClosing) {\n // Self-closing and void elements have no closing tag — emit label at\n // current depth without pushing onto the stack.\n const depth = tagStack.length;\n const prefix = depth > 0 ? '> '.repeat(depth) : '';\n output.push(`${prefix}**[${tagName}]**`);\n continue;\n }\n // Push first so the label is at the new depth — inside its own blockquote,\n // visually connected to the content that follows.\n tagStack.push(tagName);\n const depth = tagStack.length;\n const prefix = '> '.repeat(depth);\n // Blank separator at the parent depth before nested labels keeps sections distinct\n if (depth > 1) {\n output.push('> '.repeat(depth - 1).trimEnd());\n }\n output.push(`${prefix}**[${tagName}]**`);\n inCdata = trimmed.endsWith(CDATA_OPEN);\n continue;\n }\n\n const closeMatch = trimmed.match(BLOCK_CLOSE_TAG);\n if (closeMatch) {\n if (\n tagStack.length > 0 &&\n tagStack[tagStack.length - 1].toLowerCase() ===\n closeMatch[1].toLowerCase()\n ) {\n tagStack.pop();\n }\n // Blank line to visually close the section; use parent-depth prefix if still nested\n output.push(\n tagStack.length > 0 ? '> '.repeat(tagStack.length).trimEnd() : ''\n );\n continue;\n }\n\n const depth = tagStack.length;\n // Closing inline tags are dropped; opening inline tags become bold labels.\n // The replacement never returns any portion of the original matched tag —\n // only the extracted tag name wrapped in markdown bold syntax — so no raw\n // HTML can appear in the output from this substitution.\n const stripped = replaceInlineTags(line);\n if (depth > 0) {\n const prefix = '> '.repeat(depth);\n // Blank lines inside blockquotes need the prefix to maintain context\n output.push(trimmed === '' ? prefix.trimEnd() : `${prefix}${stripped}`);\n } else {\n output.push(stripped);\n }\n }\n\n return output.join('\\n');\n}\n"],"mappings":";;AAEA,IAAM,aAAa;AACnB,IAAM,cAAc;AAKpB,IAAM,iBACJ;AACF,IAAM,yBAAyB;AAE/B,IAAM,kBAAkB;;;;;;AAOxB,SAAS,mBAAmB,OAA8B;CACxD,MAAM,yBAAS,IAAI,IAAY;CAC/B,MAAM,QAA2C,CAAC;CAClD,IAAI,oBAAoB;CACxB,IAAI,UAAU;CACd,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GAAG;EAC3C,MAAM,UAAU,KAAK,KAAK;EAE1B,IAAI,SAAS;GACX,IAAI,CAAC,QAAQ,WAAW,WAAW,GAAG;GACtC,UAAU;EACZ;EACA,IAAI,QAAQ,WAAW,KAAK,GAAG;GAC7B,oBAAoB,CAAC;GACrB;EACF;EACA,IAAI,mBAAmB;EACvB,MAAM,WAAW,QAAQ,MAAM,cAAc,CAAC,GAAG;EACjD,IAAI,YAAY,CAAC,uBAAuB,KAAK,OAAO,GAAG;GACrD,MAAM,KAAK;IAAE,MAAM,SAAS,YAAY;IAAG;GAAM,CAAC;GAClD,UAAU,QAAQ,SAAS,UAAU;GACrC;EACF;EACA,MAAM,YAAY,QAAQ,MAAM,eAAe,CAAC,GAAG,EAAE,CAAC,YAAY;EAClE,IAAI,CAAC,WAAW;EAChB,IAAI,QAAQ,MAAM,SAAS;EAC3B,OAAO,SAAS,KAAK,MAAM,MAAM,CAAC,SAAS,WAAW;EACtD,IAAI,UAAU,IAAI;EAClB,OAAO,IAAI,MAAM,MAAM,CAAC,KAAK;EAC7B,MAAM,SAAS;CACjB;CACA,OAAO;AACT;AAOA,IAAM,yCAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,IAAM,aAAa;AAInB,SAAS,qBACP,MACA,WACQ;CACR,MAAM,aAAa,CAAC,GAAG,KAAK,SAAS,KAAK,CAAC;CAC3C,IAAI,SAAS;CACb,IAAI,YAAY;CAChB,KAA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AEA,MAAM,aAAa,QAAQ,MAAM,eAAe;EAChD,IAAI,YAAY;GACd,IACE,SAAS,SAAS,KAClB,SAAS,SAAS,SAAS,EAAE,CAAC,YAAY,MACxC,WAAW,EAAE,CAAC,YAAY,GAE5B,SAAS,IAAI;GAGf,OAAO,KACL,SAAS,SAAS,IAAI,KAAK,OAAO,SAAS,MAAM,CAAC,CAAC,QAAQ,IAAI,EACjE;GACA;EACF;EAEA,MAAM,QAAQ,SAAS;EAKvB,MAAM,WAAW,kBAAkB,IAAI;EACvC,IAAI,QAAQ,GAAG;GACb,MAAM,SAAS,KAAK,OAAO,KAAK;GAEhC,OAAO,KAAK,YAAY,KAAK,OAAO,QAAQ,IAAI,GAAG,SAAS,UAAU;EACxE,OACE,OAAO,KAAK,QAAQ;CAExB;CAEA,OAAO,OAAO,KAAK,IAAI;AACzB"}
|
|
@@ -4,6 +4,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
4
4
|
import { InfoIcon } from "@phosphor-icons/react/dist/ssr/Info";
|
|
5
5
|
import { PushPinIcon } from "@phosphor-icons/react/dist/ssr/PushPin";
|
|
6
6
|
import { WrenchIcon } from "@phosphor-icons/react/dist/ssr/Wrench";
|
|
7
|
+
import { ImageIcon } from "@phosphor-icons/react/dist/ssr/Image";
|
|
7
8
|
import { GearIcon } from "@phosphor-icons/react/dist/ssr/Gear";
|
|
8
9
|
import { StarIcon } from "@phosphor-icons/react/dist/ssr/Star";
|
|
9
10
|
import { BinaryIcon } from "@phosphor-icons/react/dist/ssr/Binary";
|
|
@@ -22,7 +23,6 @@ import { FileMagnifyingGlassIcon } from "@phosphor-icons/react/dist/ssr/FileMagn
|
|
|
22
23
|
import { FlagIcon } from "@phosphor-icons/react/dist/ssr/Flag";
|
|
23
24
|
import { GearSixIcon } from "@phosphor-icons/react/dist/ssr/GearSix";
|
|
24
25
|
import { GlobeIcon } from "@phosphor-icons/react/dist/ssr/Globe";
|
|
25
|
-
import { ImageIcon } from "@phosphor-icons/react/dist/ssr/Image";
|
|
26
26
|
import { InfinityIcon } from "@phosphor-icons/react/dist/ssr/Infinity";
|
|
27
27
|
import { LaptopIcon } from "@phosphor-icons/react/dist/ssr/Laptop";
|
|
28
28
|
import { ListBulletsIcon } from "@phosphor-icons/react/dist/ssr/ListBullets";
|