@ai-matrx/print 0.2.1 → 0.3.1
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 +76 -0
- package/README.md +44 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/markdown.cjs +1260 -0
- package/dist/markdown.cjs.map +1 -0
- package/dist/markdown.d.cts +177 -0
- package/dist/markdown.d.ts +177 -0
- package/dist/markdown.js +1237 -0
- package/dist/markdown.js.map +1 -0
- package/dist/pdf.cjs +77 -4
- package/dist/pdf.cjs.map +1 -1
- package/dist/pdf.d.cts +35 -9
- package/dist/pdf.d.ts +35 -9
- package/dist/pdf.js +77 -4
- package/dist/pdf.js.map +1 -1
- package/package.json +12 -2
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { PrintOutcome } from './core.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default print stylesheets for `@ai-matrx/print/markdown`.
|
|
5
|
+
*
|
|
6
|
+
* Two skins, ONE semantic-token vocabulary (C26 — structural CSS ships in the
|
|
7
|
+
* package, the token CONTRACT is enforced, token VALUES are host-overridable):
|
|
8
|
+
*
|
|
9
|
+
* "document" — the `.matrx-*` content sheet. What `markdownToHtml` emits,
|
|
10
|
+
* what the markdown→PDF lane renders, and what pastes straight
|
|
11
|
+
* into a WordPress theme.
|
|
12
|
+
* "article" — the serif AI-response sheet used by the print-window lane.
|
|
13
|
+
*
|
|
14
|
+
* Every colour is `var(--matrx-print-<role>, <default>)`. The inline fallback
|
|
15
|
+
* is what makes the drop-in test pass in a fresh, unthemed app; the `:root`
|
|
16
|
+
* block is the shipped default token-values sheet a host overrides by
|
|
17
|
+
* appending its own `:root` rule (`getMarkdownStylesheet({ tokens })`).
|
|
18
|
+
*
|
|
19
|
+
* Both sheets carry the print hard parts — `@media print`, page-break
|
|
20
|
+
* avoidance, orphans/widows, `print-color-adjust` — so no host re-derives them.
|
|
21
|
+
*
|
|
22
|
+
* THIS FILE IS THE SOURCE OF TRUTH. It was seeded once from the two host
|
|
23
|
+
* stylesheets it replaced (matrx-frontend's WordPress sheet and its serif
|
|
24
|
+
* print sheet, both deleted in the same session); there is no generator to
|
|
25
|
+
* re-run and no upstream to diff against. Edit it here.
|
|
26
|
+
*
|
|
27
|
+
* DO NOT hand-edit colour literals back in: a hardcoded colour in package CSS
|
|
28
|
+
* is a C26 violation. Add a role to the vocabulary instead.
|
|
29
|
+
*/
|
|
30
|
+
/** Default token VALUES for the document skin. */
|
|
31
|
+
declare const MARKDOWN_DOCUMENT_TOKENS_CSS = ":root {\n --matrx-print-accent: #667eea;\n --matrx-print-accent-2: #764ba2;\n --matrx-print-bg: #ffffff;\n --matrx-print-border: #e1e1e1;\n --matrx-print-border-muted: #d1d5db;\n --matrx-print-border-strong: #e5e5e5;\n --matrx-print-code-bg: #f5f5f5;\n --matrx-print-code-block-bg: #f8f8f8;\n --matrx-print-code-block-fg: #333;\n --matrx-print-code-fg: #d73a49;\n --matrx-print-fg: #1a1a1a;\n --matrx-print-fg-muted: #4a4a4a;\n --matrx-print-fg-subtle: #6b7280;\n --matrx-print-heading: #2a2a2a;\n --matrx-print-heading-sub: #3a3a3a;\n --matrx-print-link-fg: #374151;\n --matrx-print-link-hover-fg: #1f2937;\n --matrx-print-link-underline: #9ca3af;\n --matrx-print-quote-fg: #666;\n --matrx-print-shadow: rgba(0, 0, 0, 0.1);\n --matrx-print-shadow-strong: rgba(0, 0, 0, 0.2);\n --matrx-print-success: #2d5016;\n --matrx-print-success-2: #1e3a0f;\n --matrx-print-surface: #f8f9fa;\n --matrx-print-table-fg: #333333;\n}";
|
|
32
|
+
/** Default token VALUES for the article skin. */
|
|
33
|
+
declare const MARKDOWN_ARTICLE_TOKENS_CSS = ":root {\n --matrx-print-accent: #2563eb;\n --matrx-print-bg: #fff;\n --matrx-print-border: #e5e7eb;\n --matrx-print-border-muted: #d1d5db;\n --matrx-print-code-bg: #f1f5f9;\n --matrx-print-fg: #1a1a1a;\n --matrx-print-fg-muted: #374151;\n --matrx-print-fg-subtle: #64748b;\n --matrx-print-heading: #111827;\n --matrx-print-ink: #0f172a;\n --matrx-print-line: #e2e8f0;\n --matrx-print-quote-bg: #f5f3ff;\n --matrx-print-quote-border: #6366f1;\n --matrx-print-surface: #f8fafc;\n --matrx-print-surface-sunken: #f3f4f6;\n --matrx-print-table-head-bg: #1e293b;\n --matrx-print-table-head-border: #334155;\n}";
|
|
34
|
+
/** Structural CSS for the document skin (`.matrx-*` classes). */
|
|
35
|
+
declare const MARKDOWN_DOCUMENT_CSS = "/* \n * MATRX WordPress CSS - Production Ready\n * Use this CSS in your WordPress theme to style MATRX content\n * All styles are scoped to .matrx-content-container to avoid conflicts\n */\n\n/* Content Container */\n.matrx-content-container {\n max-width: 800px;\n margin: 0 auto;\n padding: 2rem;\n line-height: 1.6;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n}\n\n/* Typography */\n.matrx-h1 {\n font-size: 2.5rem;\n font-weight: 700;\n margin: 0 0 1.5rem 0;\n color: var(--matrx-print-fg, #1a1a1a);\n line-height: 1.2;\n}\n\n.matrx-h2 {\n font-size: 1.8rem;\n font-weight: 600;\n margin: 3rem 0 1rem 0 !important;\n color: var(--matrx-print-heading, #2a2a2a);\n line-height: 1.3 !important;\n border-bottom: 2px solid var(--matrx-print-border-strong, #e5e5e5);\n padding-bottom: 0.75rem !important;\n padding-top: 0 !important;\n}\n\n.matrx-h3 {\n font-size: 1.3rem;\n font-weight: 600;\n margin: 2rem 0 1rem 0;\n color: var(--matrx-print-heading-sub, #3a3a3a);\n line-height: 1.4;\n}\n\n.matrx-h4 {\n font-size: 1.1rem;\n font-weight: 600;\n margin: 1.5rem 0 0.75rem 0;\n color: var(--matrx-print-heading-sub, #3a3a3a);\n line-height: 1.4;\n}\n\n.matrx-h5 {\n font-size: 1rem;\n font-weight: 600;\n margin: 1.25rem 0 0.5rem 0;\n color: var(--matrx-print-heading-sub, #3a3a3a);\n line-height: 1.4;\n}\n\n.matrx-h6 {\n font-size: 0.9rem;\n font-weight: 600;\n margin: 1rem 0 0.5rem 0;\n color: var(--matrx-print-heading-sub, #3a3a3a);\n line-height: 1.4;\n}\n\n/* Paragraphs */\n.matrx-intro {\n font-size: 1.1rem;\n color: var(--matrx-print-fg-muted, #4a4a4a);\n margin-bottom: 2rem;\n padding: 1.5rem;\n background: var(--matrx-print-surface, #f8f9fa);\n border-left: 4px solid var(--matrx-print-border-muted, #d1d5db);\n border-radius: 0 8px 8px 0;\n}\n\n.matrx-paragraph {\n font-size: 1rem;\n color: var(--matrx-print-fg-muted, #4a4a4a);\n margin-bottom: 1.5rem;\n text-align: justify;\n}\n\n/* Text Formatting */\n.matrx-em {\n font-style: italic;\n color: var(--matrx-print-heading, #2a2a2a);\n}\n\n.matrx-strong {\n font-weight: 600;\n color: var(--matrx-print-heading, #2a2a2a);\n}\n\n/* Links */\n.matrx-link {\n color: var(--matrx-print-link-fg, #374151);\n text-decoration: underline;\n text-decoration-color: var(--matrx-print-border-muted, #d1d5db);\n text-underline-offset: 3px;\n transition: all 0.2s ease;\n}\n\n.matrx-link:hover {\n color: var(--matrx-print-link-hover-fg, #1f2937);\n text-decoration-color: var(--matrx-print-link-underline, #9ca3af);\n}\n\n/* Images */\n.matrx-image {\n max-width: 100%;\n height: auto;\n display: block;\n margin: 1.5rem auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px var(--matrx-print-shadow, rgba(0, 0, 0, 0.1));\n}\n\n/* Lists */\n.matrx-list {\n margin: 1.5rem 0;\n padding-left: 0;\n}\n\n.matrx-bullet-list {\n list-style: none;\n}\n\n.matrx-list-item {\n margin-bottom: 1rem;\n padding-left: 1.5rem;\n position: relative;\n color: var(--matrx-print-fg-muted, #4a4a4a);\n}\n\n.matrx-list-item::before {\n content: \"\u2022\";\n color: var(--matrx-print-fg-subtle, #6b7280);\n font-weight: bold;\n position: absolute;\n left: 0;\n top: 0;\n font-size: 1.2rem;\n}\n\n/* Numbered Lists */\n.matrx-numbered-list {\n list-style: decimal;\n padding-left: 2rem;\n}\n\n.matrx-numbered-list > .matrx-list-item {\n padding-left: 0.5rem;\n}\n\n.matrx-numbered-list > .matrx-list-item::before {\n content: none;\n /* Remove the bullet */\n}\n\n/* Nested list indentation */\n.matrx-nested-list {\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n padding-left: 1.5rem !important;\n}\n\n/* Ensure nested lists within list items are properly indented */\n.matrx-list-item > .matrx-list {\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n padding-left: 1.5rem;\n}\n\n/* For multiple levels of nesting, increase indentation */\n.matrx-nested-list .matrx-nested-list {\n padding-left: 1.5rem !important;\n}\n\n/* Code */\n.matrx-content-container .matrx-inline-code {\n background-color: var(--matrx-print-code-bg, #f5f5f5);\n padding: 0.125rem 0.25rem;\n border-radius: 0.25rem;\n font-family: \"Monaco\", \"Menlo\", \"Ubuntu Mono\", monospace;\n font-size: 0.875rem;\n color: var(--matrx-print-code-fg, #d73a49);\n}\n\n.matrx-content-container .matrx-code-block {\n background-color: var(--matrx-print-code-block-bg, #f8f8f8);\n border: 1px solid var(--matrx-print-border, #e1e1e1);\n border-radius: 0.375rem;\n padding: 1rem;\n margin: 1.5rem 0;\n overflow-x: auto;\n}\n\n.matrx-content-container .matrx-code {\n font-family: \"Monaco\", \"Menlo\", \"Ubuntu Mono\", monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n color: var(--matrx-print-code-block-fg, #333);\n}\n\n/* Blockquotes */\n.matrx-content-container .matrx-blockquote {\n border-left: 4px solid var(--matrx-print-border, #e1e1e1);\n padding-left: 1rem;\n margin: 1.5rem 0;\n font-style: italic;\n color: var(--matrx-print-quote-fg, #666);\n}\n\n/* Tables */\n.matrx-content-container .matrx-table {\n width: 100%;\n border-collapse: collapse;\n margin: 1.5rem 0;\n border: 1px solid var(--matrx-print-border, #e1e1e1);\n}\n\n.matrx-content-container .matrx-table-header {\n background-color: var(--matrx-print-surface, #f8f9fa);\n font-weight: 600;\n padding: 0.75rem;\n border: 1px solid var(--matrx-print-border, #e1e1e1);\n text-align: left;\n}\n\n.matrx-content-container .matrx-table-cell {\n padding: 0.75rem;\n border: 1px solid var(--matrx-print-border, #e1e1e1);\n}\n\n.matrx-content-container .matrx-table-row:nth-child(even) {\n background-color: var(--matrx-print-surface, #f8f9fa);\n}\n\n/* Images */\n.matrx-content-container .matrx-image {\n max-width: 100%;\n height: auto;\n border-radius: 0.375rem;\n margin: 1rem 0;\n}\n\n/* Horizontal Rules */\n.matrx-content-container .matrx-hr {\n border: none;\n border-top: 1px solid var(--matrx-print-border, #e1e1e1);\n margin: 2rem 0;\n}\n\n/* FAQ Styles - Clean Design */\n.matrx-faq-item {\n margin-bottom: 2rem;\n padding: 1.5rem;\n background: var(--matrx-print-surface, #f8f9fa);\n border-radius: 8px;\n border-left: 4px solid var(--matrx-print-border-muted, #d1d5db);\n}\n\n.matrx-faq-question {\n font-size: 1.2rem;\n font-weight: 600;\n margin: 0 0 0.75rem 0;\n color: var(--matrx-print-heading, #2a2a2a);\n}\n\n.matrx-faq-answer {\n margin: 0;\n color: var(--matrx-print-fg-muted, #4a4a4a);\n line-height: 1.6;\n}\n\n/* Code Blocks */\n.matrx-inline-code {\n background-color: var(--matrx-print-code-bg, #f5f5f5);\n padding: 0.125rem 0.25rem;\n border-radius: 0.25rem;\n font-family: \"Monaco\", \"Menlo\", \"Ubuntu Mono\", monospace;\n font-size: 0.875rem;\n color: var(--matrx-print-code-fg, #d73a49);\n}\n\n.matrx-code-block {\n background-color: var(--matrx-print-code-block-bg, #f8f8f8);\n border: 1px solid var(--matrx-print-border, #e1e1e1);\n border-radius: 0.375rem;\n padding: 1rem;\n margin: 1.5rem 0;\n overflow-x: auto;\n}\n\n.matrx-code {\n font-family: \"Monaco\", \"Menlo\", \"Ubuntu Mono\", monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n color: var(--matrx-print-code-block-fg, #333);\n}\n\n/* Blockquotes */\n.matrx-blockquote {\n border-left: 4px solid var(--matrx-print-border, #e1e1e1);\n padding-left: 1rem;\n margin: 1.5rem 0;\n font-style: italic;\n color: var(--matrx-print-quote-fg, #666);\n}\n\n/* Tables */\n.matrx-table {\n width: 100%;\n border-collapse: collapse;\n margin: 1.5rem 0;\n border: 1px solid var(--matrx-print-border, #e1e1e1);\n color: var(--matrx-print-table-fg, #333333);\n}\n\n.matrx-table-head {\n background-color: var(--matrx-print-surface, #f8f9fa);\n}\n\n.matrx-table-body {\n background-color: var(--matrx-print-bg, #ffffff);\n}\n\n.matrx-table-header {\n background-color: var(--matrx-print-surface, #f8f9fa);\n font-weight: 600;\n padding: 0.75rem;\n border: 1px solid var(--matrx-print-border, #e1e1e1);\n text-align: left;\n color: var(--matrx-print-table-fg, #333333);\n}\n\n.matrx-table-cell {\n padding: 0.75rem;\n border: 1px solid var(--matrx-print-border, #e1e1e1);\n color: var(--matrx-print-table-fg, #333333);\n}\n\n.matrx-table-row {\n color: var(--matrx-print-table-fg, #333333);\n}\n\n.matrx-table-row:nth-child(even) {\n background-color: var(--matrx-print-surface, #f8f9fa);\n}\n\n/* Ensure table content doesn't inherit external colors */\n.matrx-table * {\n color: inherit;\n}\n\n/* Images */\n.matrx-image {\n max-width: 100%;\n height: auto;\n border-radius: 0.375rem;\n margin: 1rem 0;\n}\n\n/* Horizontal Rules */\n.matrx-hr {\n border: none;\n border-top: 1px solid var(--matrx-print-border, #e1e1e1);\n margin: 2rem 0;\n}\n\n/* Utility Classes */\n.matrx-div {\n margin: 0.5rem 0;\n}\n\n.matrx-span {\n /* Inherit parent styling by default */\n}\n\n/* Flashcard Styles */\n.matrx-flashcards-container {\n margin: 2rem 0;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n}\n\n.matrx-flashcard {\n perspective: 1000px;\n perspective-origin: center center;\n height: 200px;\n cursor: pointer;\n position: relative;\n margin-bottom: 0.5rem;\n}\n\n.matrx-flashcard-input {\n display: none;\n}\n\n.matrx-flashcard-inner {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transition: transform 0.6s;\n transform-style: preserve-3d;\n transform-origin: center center;\n}\n\n.matrx-flashcard-input:checked ~ .matrx-flashcard-inner {\n transform: rotateY(180deg);\n}\n\n.matrx-flashcard-front,\n.matrx-flashcard-back {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n backface-visibility: hidden;\n border-radius: 12px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 1.5rem;\n box-shadow: 0 4px 6px var(--matrx-print-shadow, rgba(0, 0, 0, 0.1));\n transition: box-shadow 0.3s ease;\n box-sizing: border-box;\n}\n\n.matrx-flashcard-front {\n background: linear-gradient(135deg, var(--matrx-print-accent, #667eea) 0%, var(--matrx-print-accent-2, #764ba2) 100%);\n color: white;\n}\n\n.matrx-flashcard-back {\n background: linear-gradient(135deg, var(--matrx-print-success, #2d5016) 0%, var(--matrx-print-success-2, #1e3a0f) 100%);\n color: white;\n transform: rotateY(180deg);\n}\n\n.matrx-flashcard:hover .matrx-flashcard-front,\n.matrx-flashcard:hover .matrx-flashcard-back {\n box-shadow: 0 8px 16px var(--matrx-print-shadow-strong, rgba(0, 0, 0, 0.2));\n}\n\n.matrx-flashcard-content {\n text-align: center;\n font-size: 1.3rem;\n line-height: 1.8;\n max-height: 100%;\n width: 100%;\n overflow: hidden;\n}\n\n.matrx-flashcard-label {\n cursor: pointer;\n user-select: none;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10;\n}\n\n.matrx-flashcard-indicator {\n position: absolute;\n bottom: 12px;\n right: 16px;\n font-size: 0.75rem;\n opacity: 0.8;\n font-weight: 500;\n letter-spacing: 0.5px;\n}\n\n/* Responsive adjustments */\n@media (max-width: 768px) {\n .matrx-flashcard {\n height: 180px;\n }\n\n .matrx-flashcard-content {\n font-size: 1rem;\n }\n\n .matrx-flashcard-front,\n .matrx-flashcard-back {\n padding: 1.25rem;\n }\n}\n\n@media (max-width: 480px) {\n .matrx-flashcard {\n height: 160px;\n }\n\n .matrx-flashcard-content {\n font-size: 0.95rem;\n }\n\n .matrx-flashcard-front,\n .matrx-flashcard-back {\n padding: 1rem;\n }\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n .matrx-content-container {\n padding: 1rem;\n }\n\n .matrx-h1 {\n font-size: 2rem;\n }\n\n .matrx-h2 {\n font-size: 1.5rem;\n margin: 2rem 0 1rem 0 !important;\n }\n\n .matrx-h3 {\n font-size: 1.2rem;\n }\n\n .matrx-h4 {\n font-size: 1.05rem;\n }\n\n .matrx-h5 {\n font-size: 0.95rem;\n }\n\n .matrx-h6 {\n font-size: 0.9rem;\n }\n\n .matrx-intro {\n padding: 1rem;\n font-size: 1rem;\n }\n\n .matrx-faq-question {\n font-size: 1.1rem;\n margin: 1.5rem 0 0.75rem 0;\n }\n\n .matrx-paragraph {\n text-align: left;\n }\n\n .matrx-table {\n font-size: 0.875rem;\n }\n\n .matrx-table-header,\n .matrx-table-cell {\n padding: 0.5rem;\n }\n\n .matrx-code-block {\n padding: 0.75rem;\n margin: 1rem 0;\n }\n}\n\n@media (max-width: 480px) {\n .matrx-content-container {\n padding: 0.75rem;\n }\n\n .matrx-h1 {\n font-size: 1.75rem;\n margin-bottom: 1rem;\n }\n\n .matrx-h2 {\n font-size: 1.3rem;\n margin: 1.5rem 0 0.75rem 0 !important;\n }\n\n .matrx-h3 {\n font-size: 1.1rem;\n margin: 1.5rem 0 0.75rem 0;\n }\n\n .matrx-h4 {\n font-size: 1rem;\n margin: 1.25rem 0 0.5rem 0;\n }\n\n .matrx-h5 {\n font-size: 0.9rem;\n margin: 1rem 0 0.5rem 0;\n }\n\n .matrx-h6 {\n font-size: 0.85rem;\n margin: 1rem 0 0.5rem 0;\n }\n\n .matrx-intro {\n padding: 0.75rem;\n margin-bottom: 1.5rem;\n }\n\n .matrx-paragraph {\n margin-bottom: 1.25rem;\n }\n\n .matrx-list-item {\n margin-bottom: 0.75rem;\n }\n\n .matrx-table-header,\n .matrx-table-cell {\n padding: 0.375rem;\n }\n\n .matrx-code-block {\n padding: 0.5rem;\n font-size: 0.8rem;\n }\n\n .matrx-inline-code {\n font-size: 0.8rem;\n }\n}\n/* Print / PDF hard parts \u2014 added by @ai-matrx/print 0.3.0. */\n@media print {\n .matrx-content-container {\n max-width: 100%;\n padding: 0;\n }\n\n .matrx-h1,\n .matrx-h2,\n .matrx-h3,\n .matrx-h4,\n .matrx-h5,\n .matrx-h6 {\n page-break-after: avoid;\n break-after: avoid;\n }\n\n .matrx-paragraph,\n .matrx-intro {\n orphans: 3;\n widows: 3;\n }\n\n .matrx-table,\n .matrx-code-block,\n .matrx-blockquote,\n .matrx-list-item,\n .matrx-image,\n .matrx-faq-item,\n .matrx-flashcard {\n page-break-inside: avoid;\n break-inside: avoid;\n }\n\n .matrx-table-header,\n .matrx-code-block,\n .matrx-blockquote,\n .matrx-flashcard {\n -webkit-print-color-adjust: exact;\n print-color-adjust: exact;\n }\n\n .matrx-link {\n text-decoration: underline;\n }\n}\n";
|
|
36
|
+
/** Structural CSS for the article skin (bare tags + `.print-*` classes). */
|
|
37
|
+
declare const MARKDOWN_ARTICLE_CSS = "*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}body{font-family:Georgia,'Times New Roman',serif;font-size:11pt;line-height:1.7;color:var(--matrx-print-fg, #1a1a1a);background:var(--matrx-print-bg, #fff);max-width:780px;margin:0 auto;padding:32px 40px}.print-actions{display:flex;gap:10px;margin-bottom:28px;padding-bottom:20px;border-bottom:2px solid var(--matrx-print-border, #e5e7eb)}.print-btn{display:inline-flex;align-items:center;gap:6px;padding:8px 20px;border-radius:8px;font-size:13px;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;cursor:pointer;border:none;font-weight:600;transition:opacity .15s}.print-btn:hover{opacity:.85}.print-btn-primary{background:var(--matrx-print-accent, #2563eb);color:var(--matrx-print-bg, #fff)}.print-btn-secondary{background:var(--matrx-print-surface-sunken, #f3f4f6);color:var(--matrx-print-fg-muted, #374151);border:1px solid var(--matrx-print-border-muted, #d1d5db)}h1,h2,h3,h4,h5,h6{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Helvetica Neue',sans-serif;font-weight:700;line-height:1.3;color:var(--matrx-print-heading, #111827);margin-top:1.6em;margin-bottom:.5em;page-break-after:avoid}h1{font-size:24pt;border-bottom:2px solid var(--matrx-print-border, #e5e7eb);padding-bottom:.3em;margin-top:0}h2{font-size:18pt;border-bottom:1px solid var(--matrx-print-border, #e5e7eb);padding-bottom:.2em}h3{font-size:14pt}p{margin-bottom:.9em;orphans:3;widows:3}a{color:var(--matrx-print-accent, #2563eb);text-decoration:underline;word-break:break-word}ul,ol{margin:.6em 0 .9em 0;padding-left:1.8em}li{margin-bottom:.3em;page-break-inside:avoid}blockquote{margin:1em 0;padding:.7em 1em .7em 1.2em;border-left:4px solid var(--matrx-print-quote-border, #6366f1);background:var(--matrx-print-quote-bg, #f5f3ff);border-radius:0 6px 6px 0;color:var(--matrx-print-fg-muted, #374151);font-style:italic;page-break-inside:avoid}.inline-code{font-family:'JetBrains Mono','Fira Code',monospace;font-size:9.5pt;background:var(--matrx-print-code-bg, #f1f5f9);color:var(--matrx-print-ink, #0f172a);padding:1px 5px;border-radius:4px;border:1px solid var(--matrx-print-line, #e2e8f0)}.code-block-wrapper{position:relative;margin:1em 0 1.2em;border-radius:8px;overflow:hidden;border:1px solid var(--matrx-print-line, #e2e8f0);page-break-inside:avoid}.code-lang{display:block;font-family:-apple-system,sans-serif;font-size:9pt;font-weight:600;color:var(--matrx-print-fg-subtle, #64748b);background:var(--matrx-print-surface, #f8fafc);padding:4px 12px;border-bottom:1px solid var(--matrx-print-line, #e2e8f0);text-transform:uppercase;letter-spacing:.05em}.code-block{margin:0;padding:14px 16px;background:var(--matrx-print-ink, #0f172a);color:var(--matrx-print-line, #e2e8f0);font-family:'JetBrains Mono',monospace;font-size:9pt;line-height:1.6;overflow-x:auto;white-space:pre;tab-size:2}.print-table{width:100%;border-collapse:collapse;margin:1em 0 1.2em;font-size:10pt;page-break-inside:avoid}.print-table th{background:var(--matrx-print-table-head-bg, #1e293b);color:var(--matrx-print-surface, #f8fafc);font-family:-apple-system,sans-serif;font-weight:600;font-size:9.5pt;text-align:left;padding:8px 12px;border:1px solid var(--matrx-print-table-head-border, #334155)}.print-table td{padding:7px 12px;border:1px solid var(--matrx-print-line, #e2e8f0);vertical-align:top}.print-table tr:nth-child(even) td{background:var(--matrx-print-surface, #f8fafc)}hr{border:none;border-top:2px solid var(--matrx-print-border, #e5e7eb);margin:1.5em 0}@media print{body{max-width:100%;padding:0;font-size:10.5pt}.print-actions{display:none!important}.code-block,.print-table th,blockquote{color-adjust:exact;-webkit-print-color-adjust:exact;print-color-adjust:exact}a[href]::after{content:\" (\"attr(href)\")\";font-size:9pt;color:var(--matrx-print-fg-subtle, #64748b)}a[href^=\"#\"]::after,a[href^=\"javascript:\"]::after{content:\"\"}h1,h2,h3{page-break-after:avoid}pre,blockquote,table{page-break-inside:avoid}}";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @ai-matrx/print/markdown — the SHIPPED DEFAULT markdown→HTML converter and
|
|
41
|
+
* print stylesheet.
|
|
42
|
+
*
|
|
43
|
+
* Why this entry exists: `markdownToPdfBlob` used to declare its converter and
|
|
44
|
+
* its stylesheet as REQUIRED injected ports ("bring your own converter +
|
|
45
|
+
* stylesheet"). That is the exact failure THE ALL-INCLUSIVE LAW names — every
|
|
46
|
+
* host had to build the hard half itself, and both hosts that tried ended up
|
|
47
|
+
* with a different converter, a different stylesheet, and a different set of
|
|
48
|
+
* bugs. The package now ships a complete, working default for both ports; the
|
|
49
|
+
* injection seam survives as the OVERRIDE path, never as a prerequisite.
|
|
50
|
+
*
|
|
51
|
+
* Two skins, one vocabulary:
|
|
52
|
+
* • "document" — `markdownToHtml` emits `.matrx-*`-classed HTML (tables,
|
|
53
|
+
* nested lists, images, links, code, FAQ blocks, flashcards) and
|
|
54
|
+
* `MARKDOWN_DOCUMENT_CSS` styles it. This is the PDF/publish/WordPress
|
|
55
|
+
* lane.
|
|
56
|
+
* • "article" — `markdownToArticleHtml` emits bare semantic tags and
|
|
57
|
+
* `MARKDOWN_ARTICLE_CSS` gives them the serif AI-response look. This is
|
|
58
|
+
* the print-window lane.
|
|
59
|
+
*
|
|
60
|
+
* Nothing here touches `window`/`document` at import time, and nothing here is
|
|
61
|
+
* heavy — but it IS ~20KB of CSS, so `markdownToPdfBlob` reaches it through a
|
|
62
|
+
* lazy `import("./markdown")` and a consumer that never prints markdown pays
|
|
63
|
+
* nothing.
|
|
64
|
+
*
|
|
65
|
+
* NOTHING FAILS SILENTLY: every case where the converter drops input it cannot
|
|
66
|
+
* represent (a malformed flashcard, an empty document) is reported through the
|
|
67
|
+
* optional `onNotice` sink with a concrete remedy, instead of vanishing.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/** Which shipped look to render markdown in. */
|
|
71
|
+
type MarkdownSkin = "document" | "article";
|
|
72
|
+
/**
|
|
73
|
+
* A thing the converter could not represent, with the remedy. Announced, never
|
|
74
|
+
* swallowed — a dropped card that says nothing is indistinguishable from a card
|
|
75
|
+
* the author never wrote.
|
|
76
|
+
*/
|
|
77
|
+
interface MarkdownNotice {
|
|
78
|
+
code: "flashcard-malformed" | "empty-output" | "html-stripped";
|
|
79
|
+
message: string;
|
|
80
|
+
/** What the caller (or the author of the markdown) should do about it. */
|
|
81
|
+
remedy: string;
|
|
82
|
+
}
|
|
83
|
+
interface MarkdownToHtmlOptions {
|
|
84
|
+
/** Keep `<thinking>` / `<think>` / `<reasoning>` blocks. Default: false. */
|
|
85
|
+
includeThinking?: boolean;
|
|
86
|
+
/** Where dropped/degraded content is announced. */
|
|
87
|
+
onNotice?: (notice: MarkdownNotice) => void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Strip `<thinking>` / `<think>` / `<reasoning>` blocks from model output.
|
|
91
|
+
*
|
|
92
|
+
* All three tags are treated as equivalent — a host that handled only
|
|
93
|
+
* `<thinking>` leaked raw reasoning into printed documents the moment a model
|
|
94
|
+
* switched tag names, which is exactly the bug this package exists to stop
|
|
95
|
+
* being re-solved per app.
|
|
96
|
+
*/
|
|
97
|
+
declare function removeThinkingContent(content: string): string;
|
|
98
|
+
/** Does this content carry any reasoning block? */
|
|
99
|
+
declare function hasThinkingContent(content: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* markdown → `.matrx-*`-classed HTML wrapped in `.matrx-content-container`.
|
|
102
|
+
*
|
|
103
|
+
* The class vocabulary is deliberate and non-configurable: it is what
|
|
104
|
+
* `MARKDOWN_DOCUMENT_CSS` styles, what the PDF lane renders, and what a
|
|
105
|
+
* WordPress theme targets. Handles (in this order, because the order is the
|
|
106
|
+
* whole trick): flashcard blocks → horizontal rules → images → links →
|
|
107
|
+
* headings → emphasis → nested lists → blockquotes → code → tables → block
|
|
108
|
+
* elements → paragraphs → FAQ promotion → placeholder restoration.
|
|
109
|
+
*/
|
|
110
|
+
declare function markdownToHtml(markdown: string, options?: MarkdownToHtmlOptions): string;
|
|
111
|
+
/**
|
|
112
|
+
* markdown → bare semantic HTML (`h1`…`h6`, `p`, `ul`, `blockquote`,
|
|
113
|
+
* `.code-block-wrapper`, `.print-table`) for the article skin.
|
|
114
|
+
*
|
|
115
|
+
* Code fences are HTML-escaped here — the document skin leaves them raw
|
|
116
|
+
* because it targets a CMS that re-escapes; a print window does not, so
|
|
117
|
+
* unescaped code would render as markup.
|
|
118
|
+
*/
|
|
119
|
+
declare function markdownToArticleHtml(markdown: string, options?: MarkdownToHtmlOptions): string;
|
|
120
|
+
/**
|
|
121
|
+
* The Print / Close action bar. The article sheet styles it already; the
|
|
122
|
+
* document sheet is a content stylesheet with no chrome, so this ships beside
|
|
123
|
+
* it — otherwise every host printing document-skin markdown gets two unstyled
|
|
124
|
+
* browser buttons at the top of the page.
|
|
125
|
+
*/
|
|
126
|
+
declare const PRINT_ACTIONS_CSS = "\n.print-actions { display: flex; gap: 10px; margin: 0 auto 28px; max-width: 800px; padding: 0 2rem 20px; border-bottom: 2px solid var(--matrx-print-border, #e1e1e1); }\n.print-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; border-radius: 8px; font-size: 13px; font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif; cursor: pointer; border: none; font-weight: 600; }\n.print-btn-primary { background: var(--matrx-print-accent, #667eea); color: var(--matrx-print-bg, #ffffff); }\n.print-btn-secondary { background: var(--matrx-print-surface, #f8f9fa); color: var(--matrx-print-fg-strong, #374151); border: 1px solid var(--matrx-print-border-muted, #d1d5db); }\n@media print { .print-actions { display: none !important; } }\n";
|
|
127
|
+
interface MarkdownStylesheetOptions {
|
|
128
|
+
/** Which shipped look. Default: `"document"`. */
|
|
129
|
+
skin?: MarkdownSkin;
|
|
130
|
+
/**
|
|
131
|
+
* Host brand overrides — a CSS string appended AFTER the package's default
|
|
132
|
+
* token values, so `:root { --matrx-print-accent: #0f766e; }` wins. Token
|
|
133
|
+
* VALUES are host-owned; the token CONTRACT and the structural CSS are not.
|
|
134
|
+
*/
|
|
135
|
+
tokens?: string;
|
|
136
|
+
/** Extra rules appended after everything else. */
|
|
137
|
+
extraCss?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The complete default stylesheet for a skin: default token values, then the
|
|
141
|
+
* structural sheet, then the host's overrides. Never returns an empty string.
|
|
142
|
+
*/
|
|
143
|
+
declare function getMarkdownStylesheet(options?: MarkdownStylesheetOptions): string;
|
|
144
|
+
/** Convert markdown with the converter that matches a skin. */
|
|
145
|
+
declare function markdownToHtmlForSkin(markdown: string, skin: MarkdownSkin, options?: MarkdownToHtmlOptions): string;
|
|
146
|
+
interface RenderMarkdownDocumentOptions extends MarkdownStylesheetOptions {
|
|
147
|
+
title?: string;
|
|
148
|
+
/** Override the shipped converter. The seam survives; it is no longer required. */
|
|
149
|
+
convertToHtml?: (markdown: string) => string;
|
|
150
|
+
/** Replace the whole stylesheet (not merely the tokens). */
|
|
151
|
+
css?: string;
|
|
152
|
+
onNotice?: (notice: MarkdownNotice) => void;
|
|
153
|
+
/** Include the Print / Close action bar (hidden by `@media print`). */
|
|
154
|
+
withPrintActions?: boolean;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* markdown → a complete, standalone, styled HTML document string.
|
|
158
|
+
*
|
|
159
|
+
* This is the one composition every lane uses — the print window, the PDF
|
|
160
|
+
* capture host, and "copy a full HTML page". A host that builds its own
|
|
161
|
+
* `<!DOCTYPE html>` wrapper around package CSS is re-implementing this.
|
|
162
|
+
*/
|
|
163
|
+
declare function renderMarkdownDocument(markdown: string, options?: RenderMarkdownDocumentOptions): string;
|
|
164
|
+
interface PrintMarkdownOptions extends RenderMarkdownDocumentOptions {
|
|
165
|
+
/** Window features for the print window. */
|
|
166
|
+
windowFeatures?: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Open a print window for a markdown string, in one call.
|
|
170
|
+
*
|
|
171
|
+
* Returns the `PrintOutcome` so the host can tell the user when the popup was
|
|
172
|
+
* blocked and the `.html` download fallback fired instead — a silent fallback
|
|
173
|
+
* is indistinguishable from "print did nothing".
|
|
174
|
+
*/
|
|
175
|
+
declare function printMarkdown(markdown: string, options?: PrintMarkdownOptions): PrintOutcome;
|
|
176
|
+
|
|
177
|
+
export { MARKDOWN_ARTICLE_CSS, MARKDOWN_ARTICLE_TOKENS_CSS, MARKDOWN_DOCUMENT_CSS, MARKDOWN_DOCUMENT_TOKENS_CSS, type MarkdownNotice, type MarkdownSkin, type MarkdownStylesheetOptions, type MarkdownToHtmlOptions, PRINT_ACTIONS_CSS, type PrintMarkdownOptions, type RenderMarkdownDocumentOptions, getMarkdownStylesheet, hasThinkingContent, markdownToArticleHtml, markdownToHtml, markdownToHtmlForSkin, printMarkdown, removeThinkingContent, renderMarkdownDocument };
|