@ai-matrx/print 0.8.2 → 0.8.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/CHANGELOG.md +30 -0
- package/dist/document.cjs +235 -36
- package/dist/document.cjs.map +1 -1
- package/dist/document.d.cts +11 -1
- package/dist/document.d.ts +11 -1
- package/dist/document.js +235 -36
- package/dist/document.js.map +1 -1
- package/dist/markdown.cjs +40 -1
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +9 -1
- package/dist/markdown.d.ts +9 -1
- package/dist/markdown.js +40 -1
- package/dist/markdown.js.map +1 -1
- package/package.json +2 -1
package/dist/markdown.d.cts
CHANGED
|
@@ -117,6 +117,14 @@ interface MarkdownToHtmlOptions {
|
|
|
117
117
|
declare function removeThinkingContent(content: string): string;
|
|
118
118
|
/** Does this content carry any reasoning block? */
|
|
119
119
|
declare function hasThinkingContent(content: string): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* `<artifact …>body</artifact>` envelopes as plain markdown — the SAME rules the
|
|
122
|
+
* skins use for their titled panels, for pipelines that parse markdown (the
|
|
123
|
+
* document writer): source-code types and JSON bodies become fenced code;
|
|
124
|
+
* every other body (tables, checklists, notes) is markdown and is kept as is.
|
|
125
|
+
* Fenced code is never touched.
|
|
126
|
+
*/
|
|
127
|
+
declare function unwrapArtifactsToMarkdown(markdown: string): string;
|
|
120
128
|
/**
|
|
121
129
|
* markdown → `.matrx-*`-classed HTML wrapped in `.matrx-content-container`.
|
|
122
130
|
*
|
|
@@ -200,4 +208,4 @@ interface PrintMarkdownOptions extends RenderMarkdownDocumentOptions {
|
|
|
200
208
|
*/
|
|
201
209
|
declare function printMarkdown(markdown: string, options?: PrintMarkdownOptions): PrintOutcome;
|
|
202
210
|
|
|
203
|
-
export { MARKDOWN_ARTICLE_CSS, MARKDOWN_ARTICLE_TOKENS_CSS, MARKDOWN_DOCUMENT_CSS, MARKDOWN_DOCUMENT_TOKENS_CSS, MARKDOWN_PAGE_CSS, MARKDOWN_SHARED_CSS, type MarkdownNotice, type MarkdownSkin, type MarkdownStylesheetOptions, type MarkdownToHtmlOptions, PRINT_ACTIONS_CSS, type PrintMarkdownOptions, type RenderMarkdownDocumentOptions, getMarkdownStylesheet, hasThinkingContent, markdownToArticleHtml, markdownToHtml, markdownToHtmlForSkin, printMarkdown, removeThinkingContent, renderMarkdownDocument };
|
|
211
|
+
export { MARKDOWN_ARTICLE_CSS, MARKDOWN_ARTICLE_TOKENS_CSS, MARKDOWN_DOCUMENT_CSS, MARKDOWN_DOCUMENT_TOKENS_CSS, MARKDOWN_PAGE_CSS, MARKDOWN_SHARED_CSS, type MarkdownNotice, type MarkdownSkin, type MarkdownStylesheetOptions, type MarkdownToHtmlOptions, PRINT_ACTIONS_CSS, type PrintMarkdownOptions, type RenderMarkdownDocumentOptions, getMarkdownStylesheet, hasThinkingContent, markdownToArticleHtml, markdownToHtml, markdownToHtmlForSkin, printMarkdown, removeThinkingContent, renderMarkdownDocument, unwrapArtifactsToMarkdown };
|
package/dist/markdown.d.ts
CHANGED
|
@@ -117,6 +117,14 @@ interface MarkdownToHtmlOptions {
|
|
|
117
117
|
declare function removeThinkingContent(content: string): string;
|
|
118
118
|
/** Does this content carry any reasoning block? */
|
|
119
119
|
declare function hasThinkingContent(content: string): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* `<artifact …>body</artifact>` envelopes as plain markdown — the SAME rules the
|
|
122
|
+
* skins use for their titled panels, for pipelines that parse markdown (the
|
|
123
|
+
* document writer): source-code types and JSON bodies become fenced code;
|
|
124
|
+
* every other body (tables, checklists, notes) is markdown and is kept as is.
|
|
125
|
+
* Fenced code is never touched.
|
|
126
|
+
*/
|
|
127
|
+
declare function unwrapArtifactsToMarkdown(markdown: string): string;
|
|
120
128
|
/**
|
|
121
129
|
* markdown → `.matrx-*`-classed HTML wrapped in `.matrx-content-container`.
|
|
122
130
|
*
|
|
@@ -200,4 +208,4 @@ interface PrintMarkdownOptions extends RenderMarkdownDocumentOptions {
|
|
|
200
208
|
*/
|
|
201
209
|
declare function printMarkdown(markdown: string, options?: PrintMarkdownOptions): PrintOutcome;
|
|
202
210
|
|
|
203
|
-
export { MARKDOWN_ARTICLE_CSS, MARKDOWN_ARTICLE_TOKENS_CSS, MARKDOWN_DOCUMENT_CSS, MARKDOWN_DOCUMENT_TOKENS_CSS, MARKDOWN_PAGE_CSS, MARKDOWN_SHARED_CSS, type MarkdownNotice, type MarkdownSkin, type MarkdownStylesheetOptions, type MarkdownToHtmlOptions, PRINT_ACTIONS_CSS, type PrintMarkdownOptions, type RenderMarkdownDocumentOptions, getMarkdownStylesheet, hasThinkingContent, markdownToArticleHtml, markdownToHtml, markdownToHtmlForSkin, printMarkdown, removeThinkingContent, renderMarkdownDocument };
|
|
211
|
+
export { MARKDOWN_ARTICLE_CSS, MARKDOWN_ARTICLE_TOKENS_CSS, MARKDOWN_DOCUMENT_CSS, MARKDOWN_DOCUMENT_TOKENS_CSS, MARKDOWN_PAGE_CSS, MARKDOWN_SHARED_CSS, type MarkdownNotice, type MarkdownSkin, type MarkdownStylesheetOptions, type MarkdownToHtmlOptions, PRINT_ACTIONS_CSS, type PrintMarkdownOptions, type RenderMarkdownDocumentOptions, getMarkdownStylesheet, hasThinkingContent, markdownToArticleHtml, markdownToHtml, markdownToHtmlForSkin, printMarkdown, removeThinkingContent, renderMarkdownDocument, unwrapArtifactsToMarkdown };
|
package/dist/markdown.js
CHANGED
|
@@ -1162,6 +1162,44 @@ function artifactLabel(type) {
|
|
|
1162
1162
|
if (!type) return "Artifact";
|
|
1163
1163
|
return ARTIFACT_TYPE_LABEL[type] ?? type.replace(/[-_]+/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
1164
1164
|
}
|
|
1165
|
+
function unwrapArtifactsToMarkdown(markdown) {
|
|
1166
|
+
if (!/<artifact\b/i.test(markdown)) return markdown;
|
|
1167
|
+
return markdown.split(/(^[ \t]*(?:`{3,}|~{3,})[\s\S]*?^[ \t]*(?:`{3,}|~{3,})[ \t]*$)/m).map(
|
|
1168
|
+
(part, i) => i % 2 === 1 ? part : part.replace(/<artifact\b((?:[^>"']|"[^"]*"|'[^']*')*?)>([\s\S]*?)<\/artifact>/gi, (_m, tag, body) => {
|
|
1169
|
+
const attrs = parseTagAttributes(tag);
|
|
1170
|
+
const type = (attrs.type ?? "").toLowerCase();
|
|
1171
|
+
const trimmed = body.replace(/^\n+|\n+$/g, "");
|
|
1172
|
+
if (!trimmed.trim()) return "";
|
|
1173
|
+
if (/^\s*(`{3,}|~{3,})/.test(trimmed)) return `
|
|
1174
|
+
|
|
1175
|
+
${trimmed}
|
|
1176
|
+
|
|
1177
|
+
`;
|
|
1178
|
+
if (type in CODE_ARTIFACT_LANGUAGE) {
|
|
1179
|
+
const lang = CODE_ARTIFACT_LANGUAGE[type] || attrs.language || attrs.lang || "";
|
|
1180
|
+
return `
|
|
1181
|
+
|
|
1182
|
+
\`\`\`\`${lang}
|
|
1183
|
+
${trimmed}
|
|
1184
|
+
\`\`\`\`
|
|
1185
|
+
|
|
1186
|
+
`;
|
|
1187
|
+
}
|
|
1188
|
+
if (looksLikeJson(trimmed)) return `
|
|
1189
|
+
|
|
1190
|
+
\`\`\`\`json
|
|
1191
|
+
${JSON.stringify(JSON.parse(trimmed), null, 2)}
|
|
1192
|
+
\`\`\`\`
|
|
1193
|
+
|
|
1194
|
+
`;
|
|
1195
|
+
return `
|
|
1196
|
+
|
|
1197
|
+
${trimmed}
|
|
1198
|
+
|
|
1199
|
+
`;
|
|
1200
|
+
})
|
|
1201
|
+
).join("");
|
|
1202
|
+
}
|
|
1165
1203
|
function looksLikeJson(body) {
|
|
1166
1204
|
const t = body.trim();
|
|
1167
1205
|
if (!/^[[{]/.test(t)) return false;
|
|
@@ -1691,6 +1729,7 @@ export {
|
|
|
1691
1729
|
printMarkdown,
|
|
1692
1730
|
removeThinkingContent,
|
|
1693
1731
|
renderMarkdownDocument,
|
|
1694
|
-
splitAtPageBreaks
|
|
1732
|
+
splitAtPageBreaks,
|
|
1733
|
+
unwrapArtifactsToMarkdown
|
|
1695
1734
|
};
|
|
1696
1735
|
//# sourceMappingURL=markdown.js.map
|