payload-markdown 1.7.2 → 1.8.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/README.md +17 -0
- package/dist/agent/access.d.ts +1 -1
- package/dist/agent/access.js.map +1 -1
- package/dist/agent/guide.d.ts +3 -0
- package/dist/agent/guide.js +28 -2
- package/dist/agent/guide.js.map +1 -1
- package/dist/agent/palettes.d.ts +55 -0
- package/dist/agent/palettes.js +194 -0
- package/dist/agent/palettes.js.map +1 -0
- package/dist/agent/skill.d.ts +2 -2
- package/dist/agent/skill.js +2 -2
- package/dist/agent/skill.js.map +1 -1
- package/dist/agent/validate.d.ts +1 -1
- package/dist/agent/validate.js +3 -0
- package/dist/agent/validate.js.map +1 -1
- package/dist/appearance/PaletteRowLabel.client.d.ts +2 -0
- package/dist/appearance/PaletteRowLabel.client.js +70 -0
- package/dist/appearance/PaletteRowLabel.client.js.map +1 -0
- package/dist/appearance/config.d.ts +8 -0
- package/dist/appearance/config.js +172 -0
- package/dist/appearance/config.js.map +1 -0
- package/dist/appearance/options.d.ts +11 -0
- package/dist/appearance/options.js +15 -0
- package/dist/appearance/options.js.map +1 -0
- package/dist/appearance/runtime.d.ts +25 -0
- package/dist/appearance/runtime.js +126 -0
- package/dist/appearance/runtime.js.map +1 -0
- package/dist/components/MarkdownRenderer/Component.client.js +9 -19
- package/dist/components/MarkdownRenderer/Component.client.js.map +1 -1
- package/dist/components/MarkdownRenderer/Component.js +59 -21
- package/dist/components/MarkdownRenderer/Component.js.map +1 -1
- package/dist/components/MarkdownRenderer/index.css +93 -42
- package/dist/components/MarkdownRenderer/index.scss +128 -57
- package/dist/core/codeToHtml.js +6 -0
- package/dist/core/codeToHtml.js.map +1 -1
- package/dist/core/plugins/directiveBadge.js +2 -0
- package/dist/core/plugins/directiveBadge.js.map +1 -1
- package/dist/core/plugins/directiveButton.d.ts +1 -1
- package/dist/core/plugins/directiveButton.js +26 -6
- package/dist/core/plugins/directiveButton.js.map +1 -1
- package/dist/core/plugins/rehypeContentLayout.d.ts +12 -0
- package/dist/core/plugins/rehypeContentLayout.js +64 -0
- package/dist/core/plugins/rehypeContentLayout.js.map +1 -0
- package/dist/core/plugins/rehypeResolveIcons.js +10 -1
- package/dist/core/plugins/rehypeResolveIcons.js.map +1 -1
- package/dist/core/plugins/remarkHeadingAnchorsAndToc.js +8 -0
- package/dist/core/plugins/remarkHeadingAnchorsAndToc.js.map +1 -1
- package/dist/core/plugins/remarkValidatePalettes.d.ts +9 -0
- package/dist/core/plugins/remarkValidatePalettes.js +51 -0
- package/dist/core/plugins/remarkValidatePalettes.js.map +1 -0
- package/dist/core/renderMarkdown.js +19 -4
- package/dist/core/renderMarkdown.js.map +1 -1
- package/dist/directive-spec.json +60 -0
- package/dist/directives/definitions/button.d.ts +1 -1
- package/dist/directives/definitions/button.js +9 -2
- package/dist/directives/definitions/button.js.map +1 -1
- package/dist/directives/definitions/callout.js +29 -13
- package/dist/directives/definitions/callout.js.map +1 -1
- package/dist/directives/definitions/card.d.ts +2 -2
- package/dist/directives/definitions/card.js +44 -11
- package/dist/directives/definitions/card.js.map +1 -1
- package/dist/directives/definitions/cards.js +19 -6
- package/dist/directives/definitions/cards.js.map +1 -1
- package/dist/directives/definitions/cell.js +4 -2
- package/dist/directives/definitions/cell.js.map +1 -1
- package/dist/directives/definitions/columns.js +2 -1
- package/dist/directives/definitions/columns.js.map +1 -1
- package/dist/directives/definitions/details.js +9 -3
- package/dist/directives/definitions/details.js.map +1 -1
- package/dist/directives/definitions/section.js +5 -1
- package/dist/directives/definitions/section.js.map +1 -1
- package/dist/directives/definitions/steps.js +38 -14
- package/dist/directives/definitions/steps.js.map +1 -1
- package/dist/directives/definitions/tab.js +2 -1
- package/dist/directives/definitions/tab.js.map +1 -1
- package/dist/directives/definitions/tabs.js +13 -6
- package/dist/directives/definitions/tabs.js.map +1 -1
- package/dist/directives/definitions/toc.js +2 -1
- package/dist/directives/definitions/toc.js.map +1 -1
- package/dist/directives/diagnostics.d.ts +5 -0
- package/dist/directives/diagnostics.js +26 -10
- package/dist/directives/diagnostics.js.map +1 -1
- package/dist/directives/iconPlaceholder.d.ts +9 -3
- package/dist/directives/iconPlaceholder.js +8 -1
- package/dist/directives/iconPlaceholder.js.map +1 -1
- package/dist/directives/palette.d.ts +23 -0
- package/dist/directives/palette.js +40 -0
- package/dist/directives/palette.js.map +1 -0
- package/dist/directives/shields.js +16 -3
- package/dist/directives/shields.js.map +1 -1
- package/dist/directives/spec.d.ts +6 -2
- package/dist/directives/spec.js +5 -0
- package/dist/directives/spec.js.map +1 -1
- package/dist/directives/themes.js +13 -13
- package/dist/directives/themes.js.map +1 -1
- package/dist/editor/directiveConfig.d.ts +15 -1
- package/dist/editor/directiveConfig.js +21 -1
- package/dist/editor/directiveConfig.js.map +1 -1
- package/dist/editor/directives/completions.d.ts +4 -2
- package/dist/editor/directives/completions.js +22 -3
- package/dist/editor/directives/completions.js.map +1 -1
- package/dist/editor/directives/diagnostics.d.ts +2 -2
- package/dist/editor/directives/diagnostics.js +10 -3
- package/dist/editor/directives/diagnostics.js.map +1 -1
- package/dist/exports/client.d.ts +4 -1
- package/dist/exports/client.js +5 -2
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/render.d.ts +2 -1
- package/dist/exports/render.js +1 -0
- package/dist/exports/render.js.map +1 -1
- package/dist/field/MarkdownField/Component.js +54 -3
- package/dist/field/MarkdownField/Component.js.map +1 -1
- package/dist/icons/entries.d.ts +22 -0
- package/dist/icons/entries.js +50 -0
- package/dist/icons/entries.js.map +1 -0
- package/dist/icons/resolve.d.ts +2 -1
- package/dist/icons/resolve.js +2 -2
- package/dist/icons/resolve.js.map +1 -1
- package/dist/icons/sanitizeSvg.d.ts +12 -2
- package/dist/icons/sanitizeSvg.js +104 -3
- package/dist/icons/sanitizeSvg.js.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.js +34 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +65 -4
- package/dist/mcp/index.js.map +1 -1
- package/dist/palettes/colors.d.ts +21 -0
- package/dist/palettes/colors.js +43 -0
- package/dist/palettes/colors.js.map +1 -0
- package/dist/palettes/contrast.d.ts +7 -0
- package/dist/palettes/contrast.js +63 -0
- package/dist/palettes/contrast.js.map +1 -0
- package/dist/palettes/defaults.d.ts +8 -0
- package/dist/palettes/defaults.js +275 -0
- package/dist/palettes/defaults.js.map +1 -0
- package/dist/palettes/diagnostics.d.ts +10 -0
- package/dist/palettes/diagnostics.js +38 -0
- package/dist/palettes/diagnostics.js.map +1 -0
- package/dist/palettes/index.d.ts +61 -0
- package/dist/palettes/index.js +246 -0
- package/dist/palettes/index.js.map +1 -0
- package/dist/render/renderMarkdown.d.ts +3 -1
- package/dist/render/renderMarkdown.js +9 -1
- package/dist/render/renderMarkdown.js.map +1 -1
- package/dist/runtime/index.d.ts +12 -1
- package/dist/runtime/index.js +23 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/styles/directiveSurface.d.ts +39 -5
- package/dist/styles/directiveSurface.js +56 -13
- package/dist/styles/directiveSurface.js.map +1 -1
- package/dist/types/core.d.ts +56 -0
- package/dist/types/core.js.map +1 -1
- package/dist/types.d.ts +46 -2
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -1
- package/skills/payload-markdown/claude/SKILL.md +1 -0
- package/skills/payload-markdown/claude/reference/directive-spec.json +60 -0
- package/skills/payload-markdown/claude/reference/mcp-content-workflow.md +7 -0
- package/skills/payload-markdown/claude/reference/payload-markdown-directives.md +22 -2
- package/skills/payload-markdown/claude/skill.json +2 -2
- package/skills/payload-markdown/codex/SKILL.md +1 -0
- package/skills/payload-markdown/codex/reference/directive-spec.json +60 -0
- package/skills/payload-markdown/codex/reference/mcp-content-workflow.md +7 -0
- package/skills/payload-markdown/codex/reference/payload-markdown-directives.md +22 -2
- package/skills/payload-markdown/codex/skill.json +2 -2
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SKIP, visit } from 'unist-util-visit';
|
|
2
|
+
export const TABLE_WRAPPER_CLASS_NAMES = 'pmd-table overflow-x-auto';
|
|
3
|
+
export const INLINE_MEDIA_CLASS_NAME = 'pmd-inline-media';
|
|
4
|
+
function measureParagraph(children, stats = {
|
|
5
|
+
hasText: false,
|
|
6
|
+
images: 0
|
|
7
|
+
}) {
|
|
8
|
+
for (const child of children){
|
|
9
|
+
if (child.type === 'text') {
|
|
10
|
+
if (child.value.trim()) stats.hasText = true;
|
|
11
|
+
} else if (child.type === 'element') {
|
|
12
|
+
if (child.tagName === 'img') stats.images += 1;
|
|
13
|
+
else measureParagraph(child.children, stats);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return stats;
|
|
17
|
+
}
|
|
18
|
+
function addClassName(node, className) {
|
|
19
|
+
const current = node.properties.className;
|
|
20
|
+
const classNames = Array.isArray(current) ? current : typeof current === 'string' ? [
|
|
21
|
+
current
|
|
22
|
+
] : [];
|
|
23
|
+
node.properties.className = [
|
|
24
|
+
...classNames,
|
|
25
|
+
className
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Layout fixes Markdown output needs whatever the styling:
|
|
30
|
+
* - each table is wrapped in a horizontally scrollable container, so a wide
|
|
31
|
+
* table scrolls on its own instead of widening the page on small screens;
|
|
32
|
+
* - a paragraph that mixes images with text, or holds several images (a badge
|
|
33
|
+
* row), is marked so its images stay inline instead of stacking as blocks.
|
|
34
|
+
*/ export const rehypeContentLayout = ()=>{
|
|
35
|
+
return (tree)=>{
|
|
36
|
+
visit(tree, 'element', (node, index, parent)=>{
|
|
37
|
+
if (node.tagName === 'p') {
|
|
38
|
+
const { hasText, images } = measureParagraph(node.children);
|
|
39
|
+
if (images > 1 || images > 0 && hasText) addClassName(node, INLINE_MEDIA_CLASS_NAME);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (node.tagName !== 'table' || !parent || typeof index !== 'number') return;
|
|
43
|
+
const wrapper = {
|
|
44
|
+
type: 'element',
|
|
45
|
+
children: [
|
|
46
|
+
node
|
|
47
|
+
],
|
|
48
|
+
properties: {
|
|
49
|
+
className: [
|
|
50
|
+
TABLE_WRAPPER_CLASS_NAMES
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
tagName: 'div'
|
|
54
|
+
};
|
|
55
|
+
parent.children.splice(index, 1, wrapper);
|
|
56
|
+
return [
|
|
57
|
+
SKIP,
|
|
58
|
+
index + 1
|
|
59
|
+
];
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=rehypeContentLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/plugins/rehypeContentLayout.ts"],"sourcesContent":["import type { Element, ElementContent, Root } from 'hast'\nimport type { Plugin } from 'unified'\n\nimport { SKIP, visit } from 'unist-util-visit'\n\nexport const TABLE_WRAPPER_CLASS_NAMES = 'pmd-table overflow-x-auto'\nexport const INLINE_MEDIA_CLASS_NAME = 'pmd-inline-media'\n\nfunction measureParagraph(children: ElementContent[], stats = { hasText: false, images: 0 }) {\n for (const child of children) {\n if (child.type === 'text') {\n if (child.value.trim()) stats.hasText = true\n } else if (child.type === 'element') {\n if (child.tagName === 'img') stats.images += 1\n else measureParagraph(child.children, stats)\n }\n }\n\n return stats\n}\n\nfunction addClassName(node: Element, className: string) {\n const current = node.properties.className\n const classNames = Array.isArray(current) ? current : typeof current === 'string' ? [current] : []\n\n node.properties.className = [...classNames, className]\n}\n\n/**\n * Layout fixes Markdown output needs whatever the styling:\n * - each table is wrapped in a horizontally scrollable container, so a wide\n * table scrolls on its own instead of widening the page on small screens;\n * - a paragraph that mixes images with text, or holds several images (a badge\n * row), is marked so its images stay inline instead of stacking as blocks.\n */\nexport const rehypeContentLayout: Plugin<[], Root> = () => {\n return (tree) => {\n visit(tree, 'element', (node, index, parent) => {\n if (node.tagName === 'p') {\n const { hasText, images } = measureParagraph(node.children)\n if (images > 1 || (images > 0 && hasText)) addClassName(node, INLINE_MEDIA_CLASS_NAME)\n return\n }\n\n if (node.tagName !== 'table' || !parent || typeof index !== 'number') return\n\n const wrapper: Element = {\n type: 'element',\n children: [node],\n properties: { className: [TABLE_WRAPPER_CLASS_NAMES] },\n tagName: 'div',\n }\n\n parent.children.splice(index, 1, wrapper)\n\n return [SKIP, index + 1]\n })\n }\n}\n"],"names":["SKIP","visit","TABLE_WRAPPER_CLASS_NAMES","INLINE_MEDIA_CLASS_NAME","measureParagraph","children","stats","hasText","images","child","type","value","trim","tagName","addClassName","node","className","current","properties","classNames","Array","isArray","rehypeContentLayout","tree","index","parent","wrapper","splice"],"mappings":"AAGA,SAASA,IAAI,EAAEC,KAAK,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,4BAA4B,4BAA2B;AACpE,OAAO,MAAMC,0BAA0B,mBAAkB;AAEzD,SAASC,iBAAiBC,QAA0B,EAAEC,QAAQ;IAAEC,SAAS;IAAOC,QAAQ;AAAE,CAAC;IACzF,KAAK,MAAMC,SAASJ,SAAU;QAC5B,IAAII,MAAMC,IAAI,KAAK,QAAQ;YACzB,IAAID,MAAME,KAAK,CAACC,IAAI,IAAIN,MAAMC,OAAO,GAAG;QAC1C,OAAO,IAAIE,MAAMC,IAAI,KAAK,WAAW;YACnC,IAAID,MAAMI,OAAO,KAAK,OAAOP,MAAME,MAAM,IAAI;iBACxCJ,iBAAiBK,MAAMJ,QAAQ,EAAEC;QACxC;IACF;IAEA,OAAOA;AACT;AAEA,SAASQ,aAAaC,IAAa,EAAEC,SAAiB;IACpD,MAAMC,UAAUF,KAAKG,UAAU,CAACF,SAAS;IACzC,MAAMG,aAAaC,MAAMC,OAAO,CAACJ,WAAWA,UAAU,OAAOA,YAAY,WAAW;QAACA;KAAQ,GAAG,EAAE;IAElGF,KAAKG,UAAU,CAACF,SAAS,GAAG;WAAIG;QAAYH;KAAU;AACxD;AAEA;;;;;;CAMC,GACD,OAAO,MAAMM,sBAAwC;IACnD,OAAO,CAACC;QACNtB,MAAMsB,MAAM,WAAW,CAACR,MAAMS,OAAOC;YACnC,IAAIV,KAAKF,OAAO,KAAK,KAAK;gBACxB,MAAM,EAAEN,OAAO,EAAEC,MAAM,EAAE,GAAGJ,iBAAiBW,KAAKV,QAAQ;gBAC1D,IAAIG,SAAS,KAAMA,SAAS,KAAKD,SAAUO,aAAaC,MAAMZ;gBAC9D;YACF;YAEA,IAAIY,KAAKF,OAAO,KAAK,WAAW,CAACY,UAAU,OAAOD,UAAU,UAAU;YAEtE,MAAME,UAAmB;gBACvBhB,MAAM;gBACNL,UAAU;oBAACU;iBAAK;gBAChBG,YAAY;oBAAEF,WAAW;wBAACd;qBAA0B;gBAAC;gBACrDW,SAAS;YACX;YAEAY,OAAOpB,QAAQ,CAACsB,MAAM,CAACH,OAAO,GAAGE;YAEjC,OAAO;gBAAC1B;gBAAMwB,QAAQ;aAAE;QAC1B;IACF;AACF,EAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { visit } from 'unist-util-visit';
|
|
2
2
|
import { resolvePayloadMarkdownIcon, validatePayloadMarkdownIconsConfig } from '../../icons/resolve.js';
|
|
3
|
+
import { getPaletteRegistry, iconPaint } from '../../palettes/index.js';
|
|
3
4
|
import { reportDiagnostic } from '../diagnostics.js';
|
|
4
5
|
function isElement(node) {
|
|
5
6
|
return Boolean(node && typeof node === 'object' && 'type' in node && node.type === 'element');
|
|
@@ -14,13 +15,21 @@ export const rehypeResolveIcons = (config = {})=>{
|
|
|
14
15
|
code: 'icon-config',
|
|
15
16
|
source: 'icon'
|
|
16
17
|
});
|
|
18
|
+
const palettes = getPaletteRegistry(config.palettes);
|
|
17
19
|
visit(tree, 'element', (node, index, parent)=>{
|
|
18
20
|
if (!isElement(node)) return;
|
|
19
21
|
if (node.tagName !== 'span') return;
|
|
20
22
|
const iconRef = getStringProperty(node, 'dataPmdIconRef');
|
|
21
23
|
if (!iconRef) return;
|
|
22
24
|
const className = Array.isArray(node.properties.className) ? node.properties.className.join(' ') : typeof node.properties.className === 'string' ? node.properties.className : 'pmd-icon';
|
|
23
|
-
|
|
25
|
+
// Unknown palette names were reported when the directive was validated;
|
|
26
|
+
// the icon then renders unpainted.
|
|
27
|
+
const paletteName = getStringProperty(node, 'dataPmdIconPalette');
|
|
28
|
+
const palette = paletteName ? palettes.get(paletteName) : undefined;
|
|
29
|
+
const resolved = resolvePayloadMarkdownIcon(iconRef, config.icons, className, palette ? {
|
|
30
|
+
name: palette.name,
|
|
31
|
+
...iconPaint(palette)
|
|
32
|
+
} : undefined);
|
|
24
33
|
const start = node.position?.start;
|
|
25
34
|
const place = start ? {
|
|
26
35
|
column: start.column,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/plugins/rehypeResolveIcons.ts"],"sourcesContent":["import type { Element, Root } from 'hast'\nimport type { Plugin } from 'unified'\n\nimport { visit } from 'unist-util-visit'\n\nimport type { MarkdownRenderConfig } from '../../types/core.js'\n\nimport {\n resolvePayloadMarkdownIcon,\n validatePayloadMarkdownIconsConfig,\n} from '../../icons/resolve.js'\nimport { reportDiagnostic } from '../diagnostics.js'\n\nfunction isElement(node: unknown): node is Element {\n return Boolean(\n node && typeof node === 'object' && 'type' in node && (node as Element).type === 'element',\n )\n}\n\nfunction getStringProperty(node: Element, name: string): string | undefined {\n const value = node.properties?.[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nexport const rehypeResolveIcons: Plugin<[MarkdownRenderConfig?], Root> = (\n config: MarkdownRenderConfig = {},\n) => {\n return (tree, file) => {\n for (const warning of validatePayloadMarkdownIconsConfig(config.icons))\n reportDiagnostic(file, warning, { code: 'icon-config', source: 'icon' })\n\n visit(tree, 'element', (node, index, parent) => {\n if (!isElement(node)) return\n if (node.tagName !== 'span') return\n\n const iconRef = getStringProperty(node, 'dataPmdIconRef')\n if (!iconRef) return\n\n const className = Array.isArray(node.properties.className)\n ? node.properties.className.join(' ')\n : typeof node.properties.className === 'string'\n ? node.properties.className\n : 'pmd-icon'\n const resolved = resolvePayloadMarkdownIcon(iconRef
|
|
1
|
+
{"version":3,"sources":["../../../src/core/plugins/rehypeResolveIcons.ts"],"sourcesContent":["import type { Element, Root } from 'hast'\nimport type { Plugin } from 'unified'\n\nimport { visit } from 'unist-util-visit'\n\nimport type { MarkdownRenderConfig } from '../../types/core.js'\n\nimport {\n resolvePayloadMarkdownIcon,\n validatePayloadMarkdownIconsConfig,\n} from '../../icons/resolve.js'\nimport { getPaletteRegistry, iconPaint } from '../../palettes/index.js'\nimport { reportDiagnostic } from '../diagnostics.js'\n\nfunction isElement(node: unknown): node is Element {\n return Boolean(\n node && typeof node === 'object' && 'type' in node && (node as Element).type === 'element',\n )\n}\n\nfunction getStringProperty(node: Element, name: string): string | undefined {\n const value = node.properties?.[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nexport const rehypeResolveIcons: Plugin<[MarkdownRenderConfig?], Root> = (\n config: MarkdownRenderConfig = {},\n) => {\n return (tree, file) => {\n for (const warning of validatePayloadMarkdownIconsConfig(config.icons))\n reportDiagnostic(file, warning, { code: 'icon-config', source: 'icon' })\n\n const palettes = getPaletteRegistry(config.palettes)\n\n visit(tree, 'element', (node, index, parent) => {\n if (!isElement(node)) return\n if (node.tagName !== 'span') return\n\n const iconRef = getStringProperty(node, 'dataPmdIconRef')\n if (!iconRef) return\n\n const className = Array.isArray(node.properties.className)\n ? node.properties.className.join(' ')\n : typeof node.properties.className === 'string'\n ? node.properties.className\n : 'pmd-icon'\n // Unknown palette names were reported when the directive was validated;\n // the icon then renders unpainted.\n const paletteName = getStringProperty(node, 'dataPmdIconPalette')\n const palette = paletteName ? palettes.get(paletteName) : undefined\n const resolved = resolvePayloadMarkdownIcon(\n iconRef,\n config.icons,\n className,\n palette ? { name: palette.name, ...iconPaint(palette) } : undefined,\n )\n\n const start = node.position?.start\n const place = start ? { column: start.column, line: start.line } : undefined\n\n for (const warning of resolved.warnings) reportDiagnostic(file, warning, { place, source: 'icon' })\n\n if (!parent || typeof index !== 'number') return\n\n parent.children.splice(index, 1, ...resolved.nodes)\n })\n }\n}\n"],"names":["visit","resolvePayloadMarkdownIcon","validatePayloadMarkdownIconsConfig","getPaletteRegistry","iconPaint","reportDiagnostic","isElement","node","Boolean","type","getStringProperty","name","value","properties","trim","undefined","rehypeResolveIcons","config","tree","file","warning","icons","code","source","palettes","index","parent","tagName","iconRef","className","Array","isArray","join","paletteName","palette","get","resolved","start","position","place","column","line","warnings","children","splice","nodes"],"mappings":"AAGA,SAASA,KAAK,QAAQ,mBAAkB;AAIxC,SACEC,0BAA0B,EAC1BC,kCAAkC,QAC7B,yBAAwB;AAC/B,SAASC,kBAAkB,EAAEC,SAAS,QAAQ,0BAAyB;AACvE,SAASC,gBAAgB,QAAQ,oBAAmB;AAEpD,SAASC,UAAUC,IAAa;IAC9B,OAAOC,QACLD,QAAQ,OAAOA,SAAS,YAAY,UAAUA,QAAQ,AAACA,KAAiBE,IAAI,KAAK;AAErF;AAEA,SAASC,kBAAkBH,IAAa,EAAEI,IAAY;IACpD,MAAMC,QAAQL,KAAKM,UAAU,EAAE,CAACF,KAAK;IAErC,OAAO,OAAOC,UAAU,YAAYA,MAAME,IAAI,KAAKF,MAAME,IAAI,KAAKC;AACpE;AAEA,OAAO,MAAMC,qBAA4D,CACvEC,SAA+B,CAAC,CAAC;IAEjC,OAAO,CAACC,MAAMC;QACZ,KAAK,MAAMC,WAAWlB,mCAAmCe,OAAOI,KAAK,EACnEhB,iBAAiBc,MAAMC,SAAS;YAAEE,MAAM;YAAeC,QAAQ;QAAO;QAExE,MAAMC,WAAWrB,mBAAmBc,OAAOO,QAAQ;QAEnDxB,MAAMkB,MAAM,WAAW,CAACX,MAAMkB,OAAOC;YACnC,IAAI,CAACpB,UAAUC,OAAO;YACtB,IAAIA,KAAKoB,OAAO,KAAK,QAAQ;YAE7B,MAAMC,UAAUlB,kBAAkBH,MAAM;YACxC,IAAI,CAACqB,SAAS;YAEd,MAAMC,YAAYC,MAAMC,OAAO,CAACxB,KAAKM,UAAU,CAACgB,SAAS,IACrDtB,KAAKM,UAAU,CAACgB,SAAS,CAACG,IAAI,CAAC,OAC/B,OAAOzB,KAAKM,UAAU,CAACgB,SAAS,KAAK,WACnCtB,KAAKM,UAAU,CAACgB,SAAS,GACzB;YACN,wEAAwE;YACxE,mCAAmC;YACnC,MAAMI,cAAcvB,kBAAkBH,MAAM;YAC5C,MAAM2B,UAAUD,cAAcT,SAASW,GAAG,CAACF,eAAelB;YAC1D,MAAMqB,WAAWnC,2BACf2B,SACAX,OAAOI,KAAK,EACZQ,WACAK,UAAU;gBAAEvB,MAAMuB,QAAQvB,IAAI;gBAAE,GAAGP,UAAU8B,QAAQ;YAAC,IAAInB;YAG5D,MAAMsB,QAAQ9B,KAAK+B,QAAQ,EAAED;YAC7B,MAAME,QAAQF,QAAQ;gBAAEG,QAAQH,MAAMG,MAAM;gBAAEC,MAAMJ,MAAMI,IAAI;YAAC,IAAI1B;YAEnE,KAAK,MAAMK,WAAWgB,SAASM,QAAQ,CAAErC,iBAAiBc,MAAMC,SAAS;gBAAEmB;gBAAOhB,QAAQ;YAAO;YAEjG,IAAI,CAACG,UAAU,OAAOD,UAAU,UAAU;YAE1CC,OAAOiB,QAAQ,CAACC,MAAM,CAACnB,OAAO,MAAMW,SAASS,KAAK;QACpD;IACF;AACF,EAAC"}
|
|
@@ -29,6 +29,9 @@ function makeTocLink(heading) {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
function makeTocList(headings) {
|
|
32
|
+
// Each entry carries its level below the shallowest listed heading, so the
|
|
33
|
+
// flat list can be indented into an outline.
|
|
34
|
+
const minDepth = Math.min(...headings.map((heading)=>heading.depth));
|
|
32
35
|
return {
|
|
33
36
|
type: 'list',
|
|
34
37
|
children: headings.map((heading)=>({
|
|
@@ -41,6 +44,11 @@ function makeTocList(headings) {
|
|
|
41
44
|
]
|
|
42
45
|
}
|
|
43
46
|
],
|
|
47
|
+
data: {
|
|
48
|
+
hProperties: {
|
|
49
|
+
dataTocLevel: String(heading.depth - minDepth)
|
|
50
|
+
}
|
|
51
|
+
},
|
|
44
52
|
spread: false
|
|
45
53
|
})),
|
|
46
54
|
ordered: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/plugins/remarkHeadingAnchorsAndToc.ts"],"sourcesContent":["import type { Link, List, ListItem, Paragraph, Root } from 'mdast'\nimport type { ContainerDirective } from 'mdast-util-directive'\nimport type { Plugin } from 'unified'\n\nimport { visit } from 'unist-util-visit'\n\nimport type { HeadingAnchor } from '../../directives/headingAnchors.js'\n\nimport { resolveTocDepth, resolveTocTitle } from '../../directives/definitions/toc.js'\nimport { applyHeadingAnchors } from '../../directives/headingAnchors.js'\nimport { setRenderData } from '../renderData.js'\n\nfunction isContainerDirective(node: unknown): node is ContainerDirective {\n return Boolean(\n node &&\n typeof node === 'object' &&\n 'type' in node &&\n (node as { type?: string }).type === 'containerDirective',\n )\n}\n\nfunction makeParagraph(value: string): Paragraph {\n return {\n type: 'paragraph',\n children: [{ type: 'text', value }],\n }\n}\n\nfunction makeTocLink(heading: HeadingAnchor): Link {\n return {\n type: 'link',\n children: [{ type: 'text', value: heading.text }],\n url: `#${heading.id}`,\n }\n}\n\nfunction makeTocList(headings: HeadingAnchor[]): List {\n return {\n type: 'list',\n children: headings.map(\n (heading): ListItem => ({\n type: 'listItem',\n children: [\n {\n type: 'paragraph',\n children: [makeTocLink(heading)],\n },\n ],\n spread: false,\n }),\n ),\n ordered: true,\n spread: false,\n }\n}\n\nfunction applyTocContent(tree: Root, headings: HeadingAnchor[]) {\n visit(tree, (node) => {\n if (!isContainerDirective(node) || node.name !== 'toc') return\n\n const depth = resolveTocDepth(node)\n const title = resolveTocTitle(node)\n const visibleHeadings = headings.filter((heading) => heading.depth <= depth)\n\n // Authored children are never discarded: they render after the generated\n // list (remarkLayoutDirectives already reported them via validateMdast).\n node.children = [makeParagraph(title), makeTocList(visibleHeadings), ...node.children]\n })\n}\n\nexport const remarkHeadingAnchorsAndToc: Plugin<[], Root> = () => {\n return (tree, file) => {\n const headings = applyHeadingAnchors(tree)\n\n // The ids assigned here are the ids emitted in the HTML.\n setRenderData(file, { headings })\n\n applyTocContent(tree, headings)\n }\n}\n"],"names":["visit","resolveTocDepth","resolveTocTitle","applyHeadingAnchors","setRenderData","isContainerDirective","node","Boolean","type","makeParagraph","value","children","makeTocLink","heading","text","url","id","makeTocList","headings","map","spread","ordered","applyTocContent","tree","name","
|
|
1
|
+
{"version":3,"sources":["../../../src/core/plugins/remarkHeadingAnchorsAndToc.ts"],"sourcesContent":["import type { Link, List, ListItem, Paragraph, Root } from 'mdast'\nimport type { ContainerDirective } from 'mdast-util-directive'\nimport type { Plugin } from 'unified'\n\nimport { visit } from 'unist-util-visit'\n\nimport type { HeadingAnchor } from '../../directives/headingAnchors.js'\n\nimport { resolveTocDepth, resolveTocTitle } from '../../directives/definitions/toc.js'\nimport { applyHeadingAnchors } from '../../directives/headingAnchors.js'\nimport { setRenderData } from '../renderData.js'\n\nfunction isContainerDirective(node: unknown): node is ContainerDirective {\n return Boolean(\n node &&\n typeof node === 'object' &&\n 'type' in node &&\n (node as { type?: string }).type === 'containerDirective',\n )\n}\n\nfunction makeParagraph(value: string): Paragraph {\n return {\n type: 'paragraph',\n children: [{ type: 'text', value }],\n }\n}\n\nfunction makeTocLink(heading: HeadingAnchor): Link {\n return {\n type: 'link',\n children: [{ type: 'text', value: heading.text }],\n url: `#${heading.id}`,\n }\n}\n\nfunction makeTocList(headings: HeadingAnchor[]): List {\n // Each entry carries its level below the shallowest listed heading, so the\n // flat list can be indented into an outline.\n const minDepth = Math.min(...headings.map((heading) => heading.depth))\n\n return {\n type: 'list',\n children: headings.map(\n (heading): ListItem => ({\n type: 'listItem',\n children: [\n {\n type: 'paragraph',\n children: [makeTocLink(heading)],\n },\n ],\n data: { hProperties: { dataTocLevel: String(heading.depth - minDepth) } },\n spread: false,\n }),\n ),\n ordered: true,\n spread: false,\n }\n}\n\nfunction applyTocContent(tree: Root, headings: HeadingAnchor[]) {\n visit(tree, (node) => {\n if (!isContainerDirective(node) || node.name !== 'toc') return\n\n const depth = resolveTocDepth(node)\n const title = resolveTocTitle(node)\n const visibleHeadings = headings.filter((heading) => heading.depth <= depth)\n\n // Authored children are never discarded: they render after the generated\n // list (remarkLayoutDirectives already reported them via validateMdast).\n node.children = [makeParagraph(title), makeTocList(visibleHeadings), ...node.children]\n })\n}\n\nexport const remarkHeadingAnchorsAndToc: Plugin<[], Root> = () => {\n return (tree, file) => {\n const headings = applyHeadingAnchors(tree)\n\n // The ids assigned here are the ids emitted in the HTML.\n setRenderData(file, { headings })\n\n applyTocContent(tree, headings)\n }\n}\n"],"names":["visit","resolveTocDepth","resolveTocTitle","applyHeadingAnchors","setRenderData","isContainerDirective","node","Boolean","type","makeParagraph","value","children","makeTocLink","heading","text","url","id","makeTocList","headings","minDepth","Math","min","map","depth","data","hProperties","dataTocLevel","String","spread","ordered","applyTocContent","tree","name","title","visibleHeadings","filter","remarkHeadingAnchorsAndToc","file"],"mappings":"AAIA,SAASA,KAAK,QAAQ,mBAAkB;AAIxC,SAASC,eAAe,EAAEC,eAAe,QAAQ,sCAAqC;AACtF,SAASC,mBAAmB,QAAQ,qCAAoC;AACxE,SAASC,aAAa,QAAQ,mBAAkB;AAEhD,SAASC,qBAAqBC,IAAa;IACzC,OAAOC,QACLD,QACE,OAAOA,SAAS,YAChB,UAAUA,QACV,AAACA,KAA2BE,IAAI,KAAK;AAE3C;AAEA,SAASC,cAAcC,KAAa;IAClC,OAAO;QACLF,MAAM;QACNG,UAAU;YAAC;gBAAEH,MAAM;gBAAQE;YAAM;SAAE;IACrC;AACF;AAEA,SAASE,YAAYC,OAAsB;IACzC,OAAO;QACLL,MAAM;QACNG,UAAU;YAAC;g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
2
|
+
import type { Plugin } from 'unified';
|
|
3
|
+
import type { MarkdownRenderConfig } from '../../types/core.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reports palette references the render cannot resolve (`palette`,
|
|
6
|
+
* `iconPalette`, and `palette=` on icon entries) and configured palettes that
|
|
7
|
+
* were ignored because they are invalid. Unknown palettes render unpainted.
|
|
8
|
+
*/
|
|
9
|
+
export declare const remarkValidatePalettes: Plugin<[MarkdownRenderConfig?], Root>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
import { layoutDirectiveRegistry } from '../../directives/registry.js';
|
|
3
|
+
import { getExtraIconWarnings, parseIconEntries } from '../../icons/entries.js';
|
|
4
|
+
import { collectPaletteNames, getUnknownPaletteWarning } from '../../palettes/diagnostics.js';
|
|
5
|
+
import { getPaletteRegistry } from '../../palettes/index.js';
|
|
6
|
+
import { reportDiagnostic } from '../diagnostics.js';
|
|
7
|
+
function isContainerDirective(node) {
|
|
8
|
+
return Boolean(node && typeof node === 'object' && 'type' in node && node.type === 'containerDirective');
|
|
9
|
+
}
|
|
10
|
+
function validateDirective(node, file, config) {
|
|
11
|
+
const allowed = layoutDirectiveRegistry.get(node.name)?.allowedAttributes;
|
|
12
|
+
if (!allowed) return;
|
|
13
|
+
const place = node.data?.vlPlace;
|
|
14
|
+
if (allowed.includes('icon')) {
|
|
15
|
+
const icon = node.attributes?.icon;
|
|
16
|
+
const { entries, warnings } = parseIconEntries(typeof icon === 'string' ? icon : undefined);
|
|
17
|
+
for (const warning of [
|
|
18
|
+
...warnings,
|
|
19
|
+
...getExtraIconWarnings(node.name, entries)
|
|
20
|
+
])reportDiagnostic(file, warning, {
|
|
21
|
+
code: 'icon-option',
|
|
22
|
+
place,
|
|
23
|
+
source: 'icon'
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
for (const name of collectPaletteNames(allowed, node.attributes)){
|
|
27
|
+
const warning = getUnknownPaletteWarning(name, node.name, config);
|
|
28
|
+
if (warning) reportDiagnostic(file, warning, {
|
|
29
|
+
code: 'unknown-palette',
|
|
30
|
+
place,
|
|
31
|
+
source: 'theme'
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reports palette references the render cannot resolve (`palette`,
|
|
37
|
+
* `iconPalette`, and `palette=` on icon entries) and configured palettes that
|
|
38
|
+
* were ignored because they are invalid. Unknown palettes render unpainted.
|
|
39
|
+
*/ export const remarkValidatePalettes = (config = {})=>{
|
|
40
|
+
return (tree, file)=>{
|
|
41
|
+
for (const warning of getPaletteRegistry(config.palettes).warnings)reportDiagnostic(file, warning, {
|
|
42
|
+
code: 'palette-config',
|
|
43
|
+
source: 'theme'
|
|
44
|
+
});
|
|
45
|
+
visit(tree, (node)=>{
|
|
46
|
+
if (isContainerDirective(node)) validateDirective(node, file, config);
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=remarkValidatePalettes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/plugins/remarkValidatePalettes.ts"],"sourcesContent":["import type { Root } from 'mdast'\nimport type { ContainerDirective } from 'mdast-util-directive'\nimport type { Plugin } from 'unified'\n\nimport { visit } from 'unist-util-visit'\n\nimport type { MarkdownRenderConfig } from '../../types/core.js'\n\nimport { layoutDirectiveRegistry } from '../../directives/registry.js'\nimport { getExtraIconWarnings, parseIconEntries } from '../../icons/entries.js'\nimport { collectPaletteNames, getUnknownPaletteWarning } from '../../palettes/diagnostics.js'\nimport { getPaletteRegistry } from '../../palettes/index.js'\nimport { type DiagnosticFile, reportDiagnostic } from '../diagnostics.js'\n\nfunction isContainerDirective(node: unknown): node is ContainerDirective {\n return Boolean(\n node &&\n typeof node === 'object' &&\n 'type' in node &&\n (node as { type?: string }).type === 'containerDirective',\n )\n}\n\nfunction validateDirective(node: ContainerDirective, file: DiagnosticFile, config: MarkdownRenderConfig) {\n const allowed = layoutDirectiveRegistry.get(node.name)?.allowedAttributes\n if (!allowed) return\n\n const place = node.data?.vlPlace\n\n if (allowed.includes('icon')) {\n const icon = node.attributes?.icon\n const { entries, warnings } = parseIconEntries(typeof icon === 'string' ? icon : undefined)\n\n for (const warning of [...warnings, ...getExtraIconWarnings(node.name, entries)])\n reportDiagnostic(file, warning, { code: 'icon-option', place, source: 'icon' })\n }\n\n for (const name of collectPaletteNames(allowed, node.attributes)) {\n const warning = getUnknownPaletteWarning(name, node.name, config)\n if (warning) reportDiagnostic(file, warning, { code: 'unknown-palette', place, source: 'theme' })\n }\n}\n\n/**\n * Reports palette references the render cannot resolve (`palette`,\n * `iconPalette`, and `palette=` on icon entries) and configured palettes that\n * were ignored because they are invalid. Unknown palettes render unpainted.\n */\nexport const remarkValidatePalettes: Plugin<[MarkdownRenderConfig?], Root> = (\n config: MarkdownRenderConfig = {},\n) => {\n return (tree, file) => {\n for (const warning of getPaletteRegistry(config.palettes).warnings)\n reportDiagnostic(file, warning, { code: 'palette-config', source: 'theme' })\n\n visit(tree, (node) => {\n if (isContainerDirective(node)) validateDirective(node, file, config)\n })\n }\n}\n"],"names":["visit","layoutDirectiveRegistry","getExtraIconWarnings","parseIconEntries","collectPaletteNames","getUnknownPaletteWarning","getPaletteRegistry","reportDiagnostic","isContainerDirective","node","Boolean","type","validateDirective","file","config","allowed","get","name","allowedAttributes","place","data","vlPlace","includes","icon","attributes","entries","warnings","undefined","warning","code","source","remarkValidatePalettes","tree","palettes"],"mappings":"AAIA,SAASA,KAAK,QAAQ,mBAAkB;AAIxC,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,oBAAoB,EAAEC,gBAAgB,QAAQ,yBAAwB;AAC/E,SAASC,mBAAmB,EAAEC,wBAAwB,QAAQ,gCAA+B;AAC7F,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAA8BC,gBAAgB,QAAQ,oBAAmB;AAEzE,SAASC,qBAAqB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fig.js';
|
|
|
12
12
|
import { highlightCode } from './codeToHtml.js';
|
|
13
13
|
import { reportDiagnostic, toRenderDiagnostic } from './diagnostics.js';
|
|
14
14
|
import { rehypeApplyLayoutClasses } from './plugins/rehypeApplyLayoutClasses.js';
|
|
15
|
+
import { rehypeContentLayout } from './plugins/rehypeContentLayout.js';
|
|
15
16
|
import { rehypeResolveIcons } from './plugins/rehypeResolveIcons.js';
|
|
16
17
|
import { rehypeStripAuthoredInlineStyles } from './plugins/rehypeStripAuthoredInlineStyles.js';
|
|
17
18
|
import { createPipelineNonce, rehypeMarkPipelineElements, rehypeTrustBoundary } from './plugins/rehypeTrustBoundary.js';
|
|
@@ -21,6 +22,7 @@ import { remarkDirectiveLines } from './plugins/remarkDirectiveLines.js';
|
|
|
21
22
|
import { remarkHeadingAnchorsAndToc } from './plugins/remarkHeadingAnchorsAndToc.js';
|
|
22
23
|
import { remarkLayoutDirectives } from './plugins/remarkLayoutDirectives.js';
|
|
23
24
|
import { remarkValidateDirectiveThemes } from './plugins/remarkValidateDirectiveThemes.js';
|
|
25
|
+
import { remarkValidatePalettes } from './plugins/remarkValidatePalettes.js';
|
|
24
26
|
import { getRenderData } from './renderData.js';
|
|
25
27
|
function extractCodeLanguage(className) {
|
|
26
28
|
const classes = typeof className === 'string' ? className.split(/\s+/) : Array.isArray(className) ? className : [];
|
|
@@ -100,6 +102,8 @@ const sanitizeSchema = {
|
|
|
100
102
|
'className',
|
|
101
103
|
'dataButton',
|
|
102
104
|
'dataDirective',
|
|
105
|
+
'dataIconPalette',
|
|
106
|
+
'dataPalette',
|
|
103
107
|
'dataDirectiveLink',
|
|
104
108
|
'dataIconPosition',
|
|
105
109
|
'dataSize',
|
|
@@ -114,6 +118,8 @@ const sanitizeSchema = {
|
|
|
114
118
|
...getAttributeDefinitions(defaultSchema.attributes?.article ?? []),
|
|
115
119
|
'className',
|
|
116
120
|
'dataDirective',
|
|
121
|
+
'dataIconPalette',
|
|
122
|
+
'dataPalette',
|
|
117
123
|
'dataEyebrow',
|
|
118
124
|
'dataHref',
|
|
119
125
|
'dataIcon',
|
|
@@ -145,11 +151,14 @@ const sanitizeSchema = {
|
|
|
145
151
|
],
|
|
146
152
|
code: [
|
|
147
153
|
...getAttributeDefinitions(defaultSchema.attributes?.code ?? []),
|
|
148
|
-
'className'
|
|
154
|
+
'className',
|
|
155
|
+
'tabIndex'
|
|
149
156
|
],
|
|
150
157
|
details: [
|
|
151
158
|
...getAttributeDefinitions(defaultSchema.attributes?.details ?? []),
|
|
152
159
|
'dataDirective',
|
|
160
|
+
'dataIconPalette',
|
|
161
|
+
'dataPalette',
|
|
153
162
|
'dataTheme',
|
|
154
163
|
'dataTitle',
|
|
155
164
|
'dataVlLayout',
|
|
@@ -159,6 +168,8 @@ const sanitizeSchema = {
|
|
|
159
168
|
...getAttributeDefinitions(defaultSchema.attributes?.div ?? []),
|
|
160
169
|
'dataAlign',
|
|
161
170
|
'dataDirective',
|
|
171
|
+
'dataIconPalette',
|
|
172
|
+
'dataPalette',
|
|
162
173
|
'dataDirectiveBody',
|
|
163
174
|
'dataDirectiveTitle',
|
|
164
175
|
'dataEyebrow',
|
|
@@ -227,7 +238,8 @@ const sanitizeSchema = {
|
|
|
227
238
|
],
|
|
228
239
|
li: [
|
|
229
240
|
...getAttributeDefinitions(defaultSchema.attributes?.li ?? []),
|
|
230
|
-
'dataStep'
|
|
241
|
+
'dataStep',
|
|
242
|
+
'dataTocLevel'
|
|
231
243
|
],
|
|
232
244
|
nav: [
|
|
233
245
|
...getAttributeDefinitions(defaultSchema.attributes?.nav ?? []),
|
|
@@ -255,6 +267,8 @@ const sanitizeSchema = {
|
|
|
255
267
|
'dataDefault',
|
|
256
268
|
'dataDisabled',
|
|
257
269
|
'dataDirective',
|
|
270
|
+
'dataIconPalette',
|
|
271
|
+
'dataPalette',
|
|
258
272
|
'dataHref',
|
|
259
273
|
'dataLabel',
|
|
260
274
|
'dataLinkScope',
|
|
@@ -276,6 +290,7 @@ const sanitizeSchema = {
|
|
|
276
290
|
...getAttributeDefinitions(defaultSchema.attributes?.span ?? []),
|
|
277
291
|
'className',
|
|
278
292
|
'dataPmdIcon',
|
|
293
|
+
'dataPmdIconPalette',
|
|
279
294
|
'dataPmdIconRef',
|
|
280
295
|
'dataStepNumber',
|
|
281
296
|
'focusable',
|
|
@@ -312,9 +327,9 @@ const FAILED_RENDER_HTML = '<p>Failed to render markdown.</p>';
|
|
|
312
327
|
*/ export async function renderMarkdownDocument(markdown, config = {}) {
|
|
313
328
|
const pipelineNonce = createPipelineNonce();
|
|
314
329
|
try {
|
|
315
|
-
const file = await unified().use(remarkParse).use(remarkGfm).use(remarkDirectiveLines, config).use(remarkCompileLayouts).use(remarkLayoutDirectives).use(remarkValidateDirectiveThemes, config).use(remarkCollectRenderData).use(remarkHeadingAnchorsAndToc).use(remarkRehype, {
|
|
330
|
+
const file = await unified().use(remarkParse).use(remarkGfm).use(remarkDirectiveLines, config).use(remarkCompileLayouts).use(remarkLayoutDirectives).use(remarkValidateDirectiveThemes, config).use(remarkValidatePalettes, config).use(remarkCollectRenderData).use(remarkHeadingAnchorsAndToc).use(remarkRehype, {
|
|
316
331
|
allowDangerousHtml: true
|
|
317
|
-
}).use(rehypeMarkPipelineElements, pipelineNonce).use(rehypeRaw).use(rehypeTrustBoundary, pipelineNonce).use(rehypeStripAuthoredInlineStyles).use(rehypeShikiCodeBlocks, resolveRenderMarkdownOptions(config)).use(rehypeSanitize, sanitizeSchema).use(rehypeApplyLayoutClasses, config).use(rehypeResolveIcons, config).use(rehypeStringify).process(markdown);
|
|
332
|
+
}).use(rehypeMarkPipelineElements, pipelineNonce).use(rehypeRaw).use(rehypeTrustBoundary, pipelineNonce).use(rehypeStripAuthoredInlineStyles).use(rehypeShikiCodeBlocks, resolveRenderMarkdownOptions(config)).use(rehypeSanitize, sanitizeSchema).use(rehypeApplyLayoutClasses, config).use(rehypeResolveIcons, config).use(rehypeContentLayout).use(rehypeStringify).process(markdown);
|
|
318
333
|
const data = getRenderData(file);
|
|
319
334
|
const diagnostics = file.messages.map(toRenderDiagnostic);
|
|
320
335
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/renderMarkdown.ts"],"sourcesContent":["import type { Element, Parent, Root, RootContent } from 'hast'\nimport type { Schema } from 'hast-util-sanitize'\n\nimport { fromHtml } from 'hast-util-from-html'\nimport { toString } from 'hast-util-to-string'\nimport rehypeRaw from 'rehype-raw'\nimport rehypeSanitize, { defaultSchema } from 'rehype-sanitize'\nimport rehypeStringify from 'rehype-stringify'\nimport remarkGfm from 'remark-gfm'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport { unified } from 'unified'\nimport { visit } from 'unist-util-visit'\n\nimport type { HeadingAnchor } from '../directives/headingAnchors.js'\nimport type { MarkdownRenderConfig, RenderMarkdownOptions, RenderMarkdownResult } from '../types/core.js'\nimport type { DiagnosticFile, DiagnosticPlace, RenderDiagnostic } from './diagnostics.js'\nimport type { MarkdownLink } from './renderData.js'\n\nimport { resolveRenderMarkdownOptions } from './codeConfig.js'\nimport { highlightCode } from './codeToHtml.js'\nimport { reportDiagnostic, toRenderDiagnostic } from './diagnostics.js'\nimport { rehypeApplyLayoutClasses } from './plugins/rehypeApplyLayoutClasses.js'\nimport { rehypeResolveIcons } from './plugins/rehypeResolveIcons.js'\nimport { rehypeStripAuthoredInlineStyles } from './plugins/rehypeStripAuthoredInlineStyles.js'\nimport {\n createPipelineNonce,\n rehypeMarkPipelineElements,\n rehypeTrustBoundary,\n} from './plugins/rehypeTrustBoundary.js'\nimport { remarkCollectRenderData } from './plugins/remarkCollectRenderData.js'\nimport { remarkCompileLayouts } from './plugins/remarkCompileLayouts.js'\nimport { remarkDirectiveLines } from './plugins/remarkDirectiveLines.js'\nimport { remarkHeadingAnchorsAndToc } from './plugins/remarkHeadingAnchorsAndToc.js'\nimport { remarkLayoutDirectives } from './plugins/remarkLayoutDirectives.js'\nimport { remarkValidateDirectiveThemes } from './plugins/remarkValidateDirectiveThemes.js'\nimport { getRenderData } from './renderData.js'\n\nfunction extractCodeLanguage(\n className?: Array<number | string> | boolean | null | number | string ,\n): string | undefined {\n const classes =\n typeof className === 'string'\n ? className.split(/\\s+/)\n : Array.isArray(className)\n ? className\n : []\n\n return classes\n .find((c): c is string => typeof c === 'string' && c.startsWith('language-'))\n ?.slice(9)\n}\n\nfunction isElement(node: RootContent): node is Element {\n return node.type === 'element'\n}\n\nfunction isPreElement(node: RootContent): node is Element {\n return isElement(node) && node.tagName === 'pre'\n}\n\nfunction hasChildren(node: unknown): node is Parent {\n return Boolean(node && typeof node === 'object' && 'children' in node)\n}\n\nfunction findCodeChild(node: Element): Element | undefined {\n return node.children.find(\n (child): child is Element => child.type === 'element' && child.tagName === 'code',\n )\n}\n\nfunction parseHtmlFragment(html: string): RootContent[] {\n const fragment = fromHtml(html, { fragment: true })\n return fragment.children\n}\n\ntype CodeDiagnostic = {\n place?: DiagnosticPlace\n reason: string\n severity: 'info' | 'warning'\n}\n\nfunction rehypeShikiCodeBlocks(options: RenderMarkdownOptions = {}) {\n return async function transformer(tree: Root, file: DiagnosticFile): Promise<void> {\n const work: Array<Promise<CodeDiagnostic[]>> = []\n\n visit(tree, 'element', (node, index, parent) => {\n if (typeof index !== 'number' || !hasChildren(parent) || !isPreElement(node)) return\n\n const codeNode = findCodeChild(node)\n if (!codeNode) return\n\n const code = toString(codeNode)\n const lang = extractCodeLanguage(codeNode.properties?.className)\n const start = node.position?.start\n const place = start ? { column: start.column, line: start.line } : undefined\n\n work.push(\n (async () => {\n const highlighted = await highlightCode(code, {\n ...options,\n lang\n })\n\n const replacementNodes = parseHtmlFragment(highlighted.html)\n parent.children.splice(index, 1, ...replacementNodes)\n\n const info = new Set(highlighted.info ?? [])\n\n return highlighted.warnings.map((reason) => ({\n place,\n reason,\n severity: info.has(reason) ? ('info' as const) : ('warning' as const),\n }))\n })(),\n )\n })\n\n // Report each distinct diagnostic once per render, in document order (the\n // first occurrence's position is kept).\n const seen = new Set<string>()\n\n for (const diagnostic of (await Promise.all(work)).flat()) {\n if (seen.has(diagnostic.reason)) continue\n seen.add(diagnostic.reason)\n\n reportDiagnostic(file, diagnostic.reason, {\n place: diagnostic.place,\n severity: diagnostic.severity,\n source: 'code',\n })\n }\n }\n}\n\ntype SanitizeAttributeValue = boolean | null | number | RegExp | string | undefined\ntype SanitizeAttributeDefinition = [string, ...SanitizeAttributeValue[]] | string\n\nfunction getAttributeDefinitions(\n value: Schema['attributes'] extends infer A\n ? A extends Record<string, infer V>\n ? V\n : never\n : never,\n): SanitizeAttributeDefinition[] {\n return (value as SanitizeAttributeDefinition[] | undefined) ?? []\n}\n\nconst sanitizeSchema: Schema = {\n ...defaultSchema,\n attributes: {\n ...(defaultSchema.attributes ?? {}),\n a: [\n ...getAttributeDefinitions(defaultSchema.attributes?.a ?? []),\n 'ariaLabel',\n 'className',\n 'dataButton',\n 'dataDirective',\n 'dataDirectiveLink',\n 'dataIconPosition',\n 'dataSize',\n 'dataVariant',\n 'dataVlLayout',\n 'href',\n 'target',\n 'rel',\n 'title',\n ],\n article: [\n ...getAttributeDefinitions(defaultSchema.attributes?.article ?? []),\n 'className',\n 'dataDirective',\n 'dataEyebrow',\n 'dataHref',\n 'dataIcon',\n 'dataLinkScope',\n 'dataNewTab',\n 'dataStepCard',\n 'dataTabPanel',\n 'dataTabValue',\n 'dataTheme',\n 'dataTitle',\n 'dataVlLayout',\n 'hidden',\n 'id',\n 'role',\n 'tabIndex',\n ],\n button: [\n ...getAttributeDefinitions(defaultSchema.attributes?.button ?? []),\n 'ariaControls',\n 'ariaSelected',\n 'className',\n 'dataTabTrigger',\n 'dataTabValue',\n 'disabled',\n 'id',\n 'role',\n 'tabIndex',\n 'type',\n ],\n code: [...getAttributeDefinitions(defaultSchema.attributes?.code ?? []), 'className'],\n details: [\n ...getAttributeDefinitions(defaultSchema.attributes?.details ?? []),\n 'dataDirective',\n 'dataTheme',\n 'dataTitle',\n 'dataVlLayout',\n 'open',\n ],\n div: [\n ...getAttributeDefinitions(defaultSchema.attributes?.div ?? []),\n 'dataAlign',\n 'dataDirective',\n 'dataDirectiveBody',\n 'dataDirectiveTitle',\n 'dataEyebrow',\n 'dataHref',\n 'dataGap',\n 'dataCellTheme',\n 'dataIcon',\n 'dataTabsList',\n 'dataTabPanel',\n 'dataTabTrigger',\n 'dataTabValue',\n 'dataTheme',\n 'dataTitle',\n 'dataStack',\n 'dataVariant',\n 'dataVlLayout',\n 'dataWrap',\n 'dataVlCellHeadingDepth',\n 'hidden',\n 'id',\n 'role',\n 'tabIndex',\n ],\n h1: [\n ...getAttributeDefinitions(defaultSchema.attributes?.h1 ?? []),\n 'dataDirectiveTitle',\n 'dataHeadingAnchor',\n 'id',\n ],\n h2: [\n ...getAttributeDefinitions(defaultSchema.attributes?.h2 ?? []),\n 'dataDirectiveTitle',\n 'dataHeadingAnchor',\n 'id',\n ],\n h3: [\n ...getAttributeDefinitions(defaultSchema.attributes?.h3 ?? []),\n 'dataDirectiveTitle',\n 'dataHeadingAnchor',\n 'id',\n ],\n h4: [...getAttributeDefinitions(defaultSchema.attributes?.h4 ?? []), 'dataHeadingAnchor', 'id'],\n h5: [...getAttributeDefinitions(defaultSchema.attributes?.h5 ?? []), 'dataHeadingAnchor', 'id'],\n h6: [...getAttributeDefinitions(defaultSchema.attributes?.h6 ?? []), 'dataHeadingAnchor', 'id'],\n img: [\n ...getAttributeDefinitions(defaultSchema.attributes?.img ?? []),\n 'alt',\n 'className',\n 'dataDirective',\n 'src',\n 'title',\n 'width',\n 'height',\n ],\n li: [...getAttributeDefinitions(defaultSchema.attributes?.li ?? []), 'dataStep'],\n nav: [\n ...getAttributeDefinitions(defaultSchema.attributes?.nav ?? []),\n 'ariaLabel',\n 'dataDirective',\n 'dataTheme',\n 'dataTitle',\n 'dataVlLayout',\n ],\n p: [\n ...getAttributeDefinitions(defaultSchema.attributes?.p ?? []),\n 'className',\n 'dataDirectiveEyebrow',\n ],\n pre: [\n ...getAttributeDefinitions(defaultSchema.attributes?.pre ?? []),\n 'className',\n 'tabindex',\n ],\n section: [\n ...getAttributeDefinitions(defaultSchema.attributes?.section ?? []),\n 'dataColumns',\n 'dataCardTheme',\n 'dataCellTheme',\n 'dataDefault',\n 'dataDisabled',\n 'dataDirective',\n 'dataHref',\n 'dataLabel',\n 'dataLinkScope',\n 'dataLayout',\n 'dataNewTab',\n 'dataStack',\n 'dataNumbered',\n 'dataStepTheme',\n 'dataTabTheme',\n 'dataTabValue',\n 'dataTheme',\n 'dataVariant',\n 'dataValue',\n 'dataVlLayout',\n 'dataVlCellHeadingDepth',\n 'role',\n ],\n span: [\n ...getAttributeDefinitions(defaultSchema.attributes?.span ?? []),\n 'className',\n 'dataPmdIcon',\n 'dataPmdIconRef',\n 'dataStepNumber',\n 'focusable',\n 'style',\n ],\n summary: [...getAttributeDefinitions(defaultSchema.attributes?.summary ?? []), 'className'],\n },\n // Clobber protection for author raw HTML is applied by rehypeTrustBoundary\n // (raw-HTML ids/names get the default `user-content-` prefix there), so the\n // pipeline's own heading, footnote and tab ids stay unprefixed.\n clobberPrefix: '',\n tagNames: [\n ...(defaultSchema.tagNames ?? []),\n 'a',\n 'article',\n 'br',\n 'button',\n 'details',\n 'img',\n 'nav',\n 'section',\n 'span',\n 'summary',\n ],\n}\n\nconst FAILED_RENDER_HTML = '<p>Failed to render markdown.</p>'\n\n/**\n * Structured result of `renderMarkdown`.\n */\nexport type RenderedMarkdown = {\n /** Every diagnostic, in report order, with a source and (when known) a position. */\n diagnostics: RenderDiagnostic[]\n /** Fatal compilation errors; when non-empty, `html` is the failure placeholder. */\n errors: string[]\n /** Heading anchors in document order; `id` is the exact id emitted in `html`. */\n headings: HeadingAnchor[]\n html: string\n /** Authored URLs in document order. */\n links: MarkdownLink[]\n /** Plain text of the document without directive markup or raw HTML. */\n text: string\n /** `diagnostics` messages (kept for compatibility; includes errors). */\n warnings: string[]\n}\n\n/**\n * Headless renderer: compiles markdown to sanitized HTML and returns the\n * structured data the pipeline collects. Pure server code (no CSS, no React);\n * `MarkdownRenderer` is a thin wrapper around it.\n */\nexport async function renderMarkdownDocument(\n markdown: string,\n config: MarkdownRenderConfig = {},\n): Promise<RenderedMarkdown> {\n const pipelineNonce = createPipelineNonce()\n\n try {\n const file = await unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkDirectiveLines, config)\n .use(remarkCompileLayouts)\n .use(remarkLayoutDirectives)\n .use(remarkValidateDirectiveThemes, config)\n .use(remarkCollectRenderData)\n .use(remarkHeadingAnchorsAndToc)\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeMarkPipelineElements, pipelineNonce)\n .use(rehypeRaw)\n .use(rehypeTrustBoundary, pipelineNonce)\n .use(rehypeStripAuthoredInlineStyles)\n .use(rehypeShikiCodeBlocks, resolveRenderMarkdownOptions(config))\n .use(rehypeSanitize, sanitizeSchema)\n .use(rehypeApplyLayoutClasses, config)\n .use(rehypeResolveIcons, config)\n .use(rehypeStringify)\n .process(markdown)\n\n const data = getRenderData(file)\n const diagnostics = file.messages.map(toRenderDiagnostic)\n\n return {\n diagnostics,\n errors: [],\n headings: data.headings ?? [],\n html: String(file),\n links: data.links ?? [],\n text: data.text ?? '',\n warnings: diagnostics.map((diagnostic) => diagnostic.message),\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Failed to render markdown.'\n\n // Real compile failures were previously swallowed; log them server-side.\n // eslint-disable-next-line no-console\n console.error('[payload-markdown] Failed to render markdown:', error)\n\n return {\n diagnostics: [{ code: 'render-failed', message, severity: 'error', source: 'render' }],\n errors: [message],\n headings: [],\n html: FAILED_RENDER_HTML,\n links: [],\n text: '',\n warnings: [message],\n }\n }\n}\n\n/**\n * Compiles markdown to sanitized HTML. Same pipeline as `renderMarkdownDocument`,\n * returning only `{ html, warnings, errors }`.\n */\nexport async function compileMarkdown(\n markdown: string,\n config: MarkdownRenderConfig = {},\n): Promise<RenderMarkdownResult> {\n const { errors, html, warnings } = await renderMarkdownDocument(markdown, config)\n\n return { errors, html, warnings }\n}\n"],"names":["fromHtml","toString","rehypeRaw","rehypeSanitize","defaultSchema","rehypeStringify","remarkGfm","remarkParse","remarkRehype","unified","visit","resolveRenderMarkdownOptions","highlightCode","reportDiagnostic","toRenderDiagnostic","rehypeApplyLayoutClasses","rehypeResolveIcons","rehypeStripAuthoredInlineStyles","createPipelineNonce","rehypeMarkPipelineElements","rehypeTrustBoundary","remarkCollectRenderData","remarkCompileLayouts","remarkDirectiveLines","remarkHeadingAnchorsAndToc","remarkLayoutDirectives","remarkValidateDirectiveThemes","getRenderData","extractCodeLanguage","className","classes","split","Array","isArray","find","c","startsWith","slice","isElement","node","type","isPreElement","tagName","hasChildren","Boolean","findCodeChild","children","child","parseHtmlFragment","html","fragment","rehypeShikiCodeBlocks","options","transformer","tree","file","work","index","parent","codeNode","code","lang","properties","start","position","place","column","line","undefined","push","highlighted","replacementNodes","splice","info","Set","warnings","map","reason","severity","has","seen","diagnostic","Promise","all","flat","add","source","getAttributeDefinitions","value","sanitizeSchema","attributes","a","article","button","details","div","h1","h2","h3","h4","h5","h6","img","li","nav","p","pre","section","span","summary","clobberPrefix","tagNames","FAILED_RENDER_HTML","renderMarkdownDocument","markdown","config","pipelineNonce","use","allowDangerousHtml","process","data","diagnostics","messages","errors","headings","String","links","text","message","error","Error","console","compileMarkdown"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,sBAAqB;AAC9C,SAASC,QAAQ,QAAQ,sBAAqB;AAC9C,OAAOC,eAAe,aAAY;AAClC,OAAOC,kBAAkBC,aAAa,QAAQ,kBAAiB;AAC/D,OAAOC,qBAAqB,mBAAkB;AAC9C,OAAOC,eAAe,aAAY;AAClC,OAAOC,iBAAiB,eAAc;AACtC,OAAOC,kBAAkB,gBAAe;AACxC,SAASC,OAAO,QAAQ,UAAS;AACjC,SAASC,KAAK,QAAQ,mBAAkB;AAOxC,SAASC,4BAA4B,QAAQ,kBAAiB;AAC9D,SAASC,aAAa,QAAQ,kB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,CAAC,iDAAiDA;QAE/D,OAAO;YACLR,aAAa;gBAAC;oBAAE7D,MAAM;oBAAiBoE;oBAASlD,UAAU;oBAASQ,QAAQ;gBAAS;aAAE;YACtFqC,QAAQ;gBAACK;aAAQ;YACjBJ,UAAU,EAAE;YACZ3E,MAAM+D;YACNc,OAAO,EAAE;YACTC,MAAM;YACNpD,UAAU;gBAACqD;aAAQ;QACrB;IACF;AACF;AAEA;;;CAGC,GACD,OAAO,eAAeI,gBACpBlB,QAAgB,EAChBC,SAA+B,CAAC,CAAC;IAEjC,MAAM,EAAEQ,MAAM,EAAE1E,IAAI,EAAE0B,QAAQ,EAAE,GAAG,MAAMsC,uBAAuBC,UAAUC;IAE1E,OAAO;QAAEQ;QAAQ1E;QAAM0B;IAAS;AAClC"}
|
|
1
|
+
{"version":3,"sources":["../../src/core/renderMarkdown.ts"],"sourcesContent":["import type { Element, Parent, Root, RootContent } from 'hast'\nimport type { Schema } from 'hast-util-sanitize'\n\nimport { fromHtml } from 'hast-util-from-html'\nimport { toString } from 'hast-util-to-string'\nimport rehypeRaw from 'rehype-raw'\nimport rehypeSanitize, { defaultSchema } from 'rehype-sanitize'\nimport rehypeStringify from 'rehype-stringify'\nimport remarkGfm from 'remark-gfm'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport { unified } from 'unified'\nimport { visit } from 'unist-util-visit'\n\nimport type { HeadingAnchor } from '../directives/headingAnchors.js'\nimport type { MarkdownRenderConfig, RenderMarkdownOptions, RenderMarkdownResult } from '../types/core.js'\nimport type { DiagnosticFile, DiagnosticPlace, RenderDiagnostic } from './diagnostics.js'\nimport type { MarkdownLink } from './renderData.js'\n\nimport { resolveRenderMarkdownOptions } from './codeConfig.js'\nimport { highlightCode } from './codeToHtml.js'\nimport { reportDiagnostic, toRenderDiagnostic } from './diagnostics.js'\nimport { rehypeApplyLayoutClasses } from './plugins/rehypeApplyLayoutClasses.js'\nimport { rehypeContentLayout } from './plugins/rehypeContentLayout.js'\nimport { rehypeResolveIcons } from './plugins/rehypeResolveIcons.js'\nimport { rehypeStripAuthoredInlineStyles } from './plugins/rehypeStripAuthoredInlineStyles.js'\nimport {\n createPipelineNonce,\n rehypeMarkPipelineElements,\n rehypeTrustBoundary,\n} from './plugins/rehypeTrustBoundary.js'\nimport { remarkCollectRenderData } from './plugins/remarkCollectRenderData.js'\nimport { remarkCompileLayouts } from './plugins/remarkCompileLayouts.js'\nimport { remarkDirectiveLines } from './plugins/remarkDirectiveLines.js'\nimport { remarkHeadingAnchorsAndToc } from './plugins/remarkHeadingAnchorsAndToc.js'\nimport { remarkLayoutDirectives } from './plugins/remarkLayoutDirectives.js'\nimport { remarkValidateDirectiveThemes } from './plugins/remarkValidateDirectiveThemes.js'\nimport { remarkValidatePalettes } from './plugins/remarkValidatePalettes.js'\nimport { getRenderData } from './renderData.js'\n\nfunction extractCodeLanguage(\n className?: Array<number | string> | boolean | null | number | string ,\n): string | undefined {\n const classes =\n typeof className === 'string'\n ? className.split(/\\s+/)\n : Array.isArray(className)\n ? className\n : []\n\n return classes\n .find((c): c is string => typeof c === 'string' && c.startsWith('language-'))\n ?.slice(9)\n}\n\nfunction isElement(node: RootContent): node is Element {\n return node.type === 'element'\n}\n\nfunction isPreElement(node: RootContent): node is Element {\n return isElement(node) && node.tagName === 'pre'\n}\n\nfunction hasChildren(node: unknown): node is Parent {\n return Boolean(node && typeof node === 'object' && 'children' in node)\n}\n\nfunction findCodeChild(node: Element): Element | undefined {\n return node.children.find(\n (child): child is Element => child.type === 'element' && child.tagName === 'code',\n )\n}\n\nfunction parseHtmlFragment(html: string): RootContent[] {\n const fragment = fromHtml(html, { fragment: true })\n return fragment.children\n}\n\ntype CodeDiagnostic = {\n place?: DiagnosticPlace\n reason: string\n severity: 'info' | 'warning'\n}\n\nfunction rehypeShikiCodeBlocks(options: RenderMarkdownOptions = {}) {\n return async function transformer(tree: Root, file: DiagnosticFile): Promise<void> {\n const work: Array<Promise<CodeDiagnostic[]>> = []\n\n visit(tree, 'element', (node, index, parent) => {\n if (typeof index !== 'number' || !hasChildren(parent) || !isPreElement(node)) return\n\n const codeNode = findCodeChild(node)\n if (!codeNode) return\n\n const code = toString(codeNode)\n const lang = extractCodeLanguage(codeNode.properties?.className)\n const start = node.position?.start\n const place = start ? { column: start.column, line: start.line } : undefined\n\n work.push(\n (async () => {\n const highlighted = await highlightCode(code, {\n ...options,\n lang\n })\n\n const replacementNodes = parseHtmlFragment(highlighted.html)\n parent.children.splice(index, 1, ...replacementNodes)\n\n const info = new Set(highlighted.info ?? [])\n\n return highlighted.warnings.map((reason) => ({\n place,\n reason,\n severity: info.has(reason) ? ('info' as const) : ('warning' as const),\n }))\n })(),\n )\n })\n\n // Report each distinct diagnostic once per render, in document order (the\n // first occurrence's position is kept).\n const seen = new Set<string>()\n\n for (const diagnostic of (await Promise.all(work)).flat()) {\n if (seen.has(diagnostic.reason)) continue\n seen.add(diagnostic.reason)\n\n reportDiagnostic(file, diagnostic.reason, {\n place: diagnostic.place,\n severity: diagnostic.severity,\n source: 'code',\n })\n }\n }\n}\n\ntype SanitizeAttributeValue = boolean | null | number | RegExp | string | undefined\ntype SanitizeAttributeDefinition = [string, ...SanitizeAttributeValue[]] | string\n\nfunction getAttributeDefinitions(\n value: Schema['attributes'] extends infer A\n ? A extends Record<string, infer V>\n ? V\n : never\n : never,\n): SanitizeAttributeDefinition[] {\n return (value as SanitizeAttributeDefinition[] | undefined) ?? []\n}\n\nconst sanitizeSchema: Schema = {\n ...defaultSchema,\n attributes: {\n ...(defaultSchema.attributes ?? {}),\n a: [\n ...getAttributeDefinitions(defaultSchema.attributes?.a ?? []),\n 'ariaLabel',\n 'className',\n 'dataButton',\n 'dataDirective',\n 'dataIconPalette',\n 'dataPalette',\n 'dataDirectiveLink',\n 'dataIconPosition',\n 'dataSize',\n 'dataVariant',\n 'dataVlLayout',\n 'href',\n 'target',\n 'rel',\n 'title',\n ],\n article: [\n ...getAttributeDefinitions(defaultSchema.attributes?.article ?? []),\n 'className',\n 'dataDirective',\n 'dataIconPalette',\n 'dataPalette',\n 'dataEyebrow',\n 'dataHref',\n 'dataIcon',\n 'dataLinkScope',\n 'dataNewTab',\n 'dataStepCard',\n 'dataTabPanel',\n 'dataTabValue',\n 'dataTheme',\n 'dataTitle',\n 'dataVlLayout',\n 'hidden',\n 'id',\n 'role',\n 'tabIndex',\n ],\n button: [\n ...getAttributeDefinitions(defaultSchema.attributes?.button ?? []),\n 'ariaControls',\n 'ariaSelected',\n 'className',\n 'dataTabTrigger',\n 'dataTabValue',\n 'disabled',\n 'id',\n 'role',\n 'tabIndex',\n 'type',\n ],\n code: [...getAttributeDefinitions(defaultSchema.attributes?.code ?? []), 'className', 'tabIndex'],\n details: [\n ...getAttributeDefinitions(defaultSchema.attributes?.details ?? []),\n 'dataDirective',\n 'dataIconPalette',\n 'dataPalette',\n 'dataTheme',\n 'dataTitle',\n 'dataVlLayout',\n 'open',\n ],\n div: [\n ...getAttributeDefinitions(defaultSchema.attributes?.div ?? []),\n 'dataAlign',\n 'dataDirective',\n 'dataIconPalette',\n 'dataPalette',\n 'dataDirectiveBody',\n 'dataDirectiveTitle',\n 'dataEyebrow',\n 'dataHref',\n 'dataGap',\n 'dataCellTheme',\n 'dataIcon',\n 'dataTabsList',\n 'dataTabPanel',\n 'dataTabTrigger',\n 'dataTabValue',\n 'dataTheme',\n 'dataTitle',\n 'dataStack',\n 'dataVariant',\n 'dataVlLayout',\n 'dataWrap',\n 'dataVlCellHeadingDepth',\n 'hidden',\n 'id',\n 'role',\n 'tabIndex',\n ],\n h1: [\n ...getAttributeDefinitions(defaultSchema.attributes?.h1 ?? []),\n 'dataDirectiveTitle',\n 'dataHeadingAnchor',\n 'id',\n ],\n h2: [\n ...getAttributeDefinitions(defaultSchema.attributes?.h2 ?? []),\n 'dataDirectiveTitle',\n 'dataHeadingAnchor',\n 'id',\n ],\n h3: [\n ...getAttributeDefinitions(defaultSchema.attributes?.h3 ?? []),\n 'dataDirectiveTitle',\n 'dataHeadingAnchor',\n 'id',\n ],\n h4: [...getAttributeDefinitions(defaultSchema.attributes?.h4 ?? []), 'dataHeadingAnchor', 'id'],\n h5: [...getAttributeDefinitions(defaultSchema.attributes?.h5 ?? []), 'dataHeadingAnchor', 'id'],\n h6: [...getAttributeDefinitions(defaultSchema.attributes?.h6 ?? []), 'dataHeadingAnchor', 'id'],\n img: [\n ...getAttributeDefinitions(defaultSchema.attributes?.img ?? []),\n 'alt',\n 'className',\n 'dataDirective',\n 'src',\n 'title',\n 'width',\n 'height',\n ],\n li: [...getAttributeDefinitions(defaultSchema.attributes?.li ?? []), 'dataStep', 'dataTocLevel'],\n nav: [\n ...getAttributeDefinitions(defaultSchema.attributes?.nav ?? []),\n 'ariaLabel',\n 'dataDirective',\n 'dataTheme',\n 'dataTitle',\n 'dataVlLayout',\n ],\n p: [\n ...getAttributeDefinitions(defaultSchema.attributes?.p ?? []),\n 'className',\n 'dataDirectiveEyebrow',\n ],\n pre: [\n ...getAttributeDefinitions(defaultSchema.attributes?.pre ?? []),\n 'className',\n 'tabindex',\n ],\n section: [\n ...getAttributeDefinitions(defaultSchema.attributes?.section ?? []),\n 'dataColumns',\n 'dataCardTheme',\n 'dataCellTheme',\n 'dataDefault',\n 'dataDisabled',\n 'dataDirective',\n 'dataIconPalette',\n 'dataPalette',\n 'dataHref',\n 'dataLabel',\n 'dataLinkScope',\n 'dataLayout',\n 'dataNewTab',\n 'dataStack',\n 'dataNumbered',\n 'dataStepTheme',\n 'dataTabTheme',\n 'dataTabValue',\n 'dataTheme',\n 'dataVariant',\n 'dataValue',\n 'dataVlLayout',\n 'dataVlCellHeadingDepth',\n 'role',\n ],\n span: [\n ...getAttributeDefinitions(defaultSchema.attributes?.span ?? []),\n 'className',\n 'dataPmdIcon',\n 'dataPmdIconPalette',\n 'dataPmdIconRef',\n 'dataStepNumber',\n 'focusable',\n 'style',\n ],\n summary: [...getAttributeDefinitions(defaultSchema.attributes?.summary ?? []), 'className'],\n },\n // Clobber protection for author raw HTML is applied by rehypeTrustBoundary\n // (raw-HTML ids/names get the default `user-content-` prefix there), so the\n // pipeline's own heading, footnote and tab ids stay unprefixed.\n clobberPrefix: '',\n tagNames: [\n ...(defaultSchema.tagNames ?? []),\n 'a',\n 'article',\n 'br',\n 'button',\n 'details',\n 'img',\n 'nav',\n 'section',\n 'span',\n 'summary',\n ],\n}\n\nconst FAILED_RENDER_HTML = '<p>Failed to render markdown.</p>'\n\n/**\n * Structured result of `renderMarkdown`.\n */\nexport type RenderedMarkdown = {\n /** Every diagnostic, in report order, with a source and (when known) a position. */\n diagnostics: RenderDiagnostic[]\n /** Fatal compilation errors; when non-empty, `html` is the failure placeholder. */\n errors: string[]\n /** Heading anchors in document order; `id` is the exact id emitted in `html`. */\n headings: HeadingAnchor[]\n html: string\n /** Authored URLs in document order. */\n links: MarkdownLink[]\n /** Plain text of the document without directive markup or raw HTML. */\n text: string\n /** `diagnostics` messages (kept for compatibility; includes errors). */\n warnings: string[]\n}\n\n/**\n * Headless renderer: compiles markdown to sanitized HTML and returns the\n * structured data the pipeline collects. Pure server code (no CSS, no React);\n * `MarkdownRenderer` is a thin wrapper around it.\n */\nexport async function renderMarkdownDocument(\n markdown: string,\n config: MarkdownRenderConfig = {},\n): Promise<RenderedMarkdown> {\n const pipelineNonce = createPipelineNonce()\n\n try {\n const file = await unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkDirectiveLines, config)\n .use(remarkCompileLayouts)\n .use(remarkLayoutDirectives)\n .use(remarkValidateDirectiveThemes, config)\n .use(remarkValidatePalettes, config)\n .use(remarkCollectRenderData)\n .use(remarkHeadingAnchorsAndToc)\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeMarkPipelineElements, pipelineNonce)\n .use(rehypeRaw)\n .use(rehypeTrustBoundary, pipelineNonce)\n .use(rehypeStripAuthoredInlineStyles)\n .use(rehypeShikiCodeBlocks, resolveRenderMarkdownOptions(config))\n .use(rehypeSanitize, sanitizeSchema)\n .use(rehypeApplyLayoutClasses, config)\n .use(rehypeResolveIcons, config)\n .use(rehypeContentLayout)\n .use(rehypeStringify)\n .process(markdown)\n\n const data = getRenderData(file)\n const diagnostics = file.messages.map(toRenderDiagnostic)\n\n return {\n diagnostics,\n errors: [],\n headings: data.headings ?? [],\n html: String(file),\n links: data.links ?? [],\n text: data.text ?? '',\n warnings: diagnostics.map((diagnostic) => diagnostic.message),\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Failed to render markdown.'\n\n // Real compile failures were previously swallowed; log them server-side.\n // eslint-disable-next-line no-console\n console.error('[payload-markdown] Failed to render markdown:', error)\n\n return {\n diagnostics: [{ code: 'render-failed', message, severity: 'error', source: 'render' }],\n errors: [message],\n headings: [],\n html: FAILED_RENDER_HTML,\n links: [],\n text: '',\n warnings: [message],\n }\n }\n}\n\n/**\n * Compiles markdown to sanitized HTML. Same pipeline as `renderMarkdownDocument`,\n * returning only `{ html, warnings, errors }`.\n */\nexport async function compileMarkdown(\n markdown: string,\n config: MarkdownRenderConfig = {},\n): Promise<RenderMarkdownResult> {\n const { errors, html, warnings } = await renderMarkdownDocument(markdown, config)\n\n return { errors, html, warnings }\n}\n"],"names":["fromHtml","toString","rehypeRaw","rehypeSanitize","defaultSchema","rehypeStringify","remarkGfm","remarkParse","remarkRehype","unified","visit","resolveRenderMarkdownOptions","highlightCode","reportDiagnostic","toRenderDiagnostic","rehypeApplyLayoutClasses","rehypeContentLayout","rehypeResolveIcons","rehypeStripAuthoredInlineStyles","createPipelineNonce","rehypeMarkPipelineElements","rehypeTrustBoundary","remarkCollectRenderData","remarkCompileLayouts","remarkDirectiveLines","remarkHeadingAnchorsAndToc","remarkLayoutDirectives","remarkValidateDirectiveThemes","remarkValidatePalettes","getRenderData","extractCodeLanguage","className","classes","split","Array","isArray","find","c","startsWith","slice","isElement","node","type","isPreElement","tagName","hasChildren","Boolean","findCodeChild","children","child","parseHtmlFragment","html","fragment","rehypeShikiCodeBlocks","options","transformer","tree","file","work","index","parent","codeNode","code","lang","properties","start","position","place","column","line","undefined","push","highlighted","replacementNodes","splice","info","Set","warnings","map","reason","severity","has","seen","diagnostic","Promise","all","flat","add","source","getAttributeDefinitions","value","sanitizeSchema","attributes","a","article","button","details","div","h1","h2","h3","h4","h5","h6","img","li","nav","p","pre","section","span","summary","clobberPrefix","tagNames","FAILED_RENDER_HTML","renderMarkdownDocument","markdown","config","pipelineNonce","use","allowDangerousHtml","process","data","diagnostics","messages","errors","headings","String","links","text","message","error","Error","console","compileMarkdown"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,sBAAqB;AAC9C,SAASC,QAAQ,QAAQ,sBAAqB;AAC9C,OAAOC,eAAe,aAAY;AAClC,OAAOC,kBAAkBC,aAAa,QAAQ,kBAAiB;AAC/D,OAAOC,qBAAqB,mBAAkB;AAC9C,OAAOC,eAAe,aAAY;AAClC,OAAOC,iBAAiB,eAAc;AACtC,OAAOC,kBAAkB,gBAAe;AACxC,SAASC,OAAO,QAAQ,UAAS;AACjC,SAASC,KAAK,QAAQ,mBAAkB;AAOxC,SAASC,4BAA4B,QAAQ,kBAAiB;AAC9D,SAASC,aAAa,QAAQ,kBAAiB;AAC/C,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,mBAAkB;AACvE,SAASC,wBAAwB,QAAQ,wCAAuC;AAChF,SAASC,mBAAmB,QAAQ,mCAAkC;AACtE,SAASC,kBAAkB,QAAQ,kCAAiC;AACpE,SAASC,+BAA+B,QAAQ,+CAA8C;AAC9F,SACEC,mBAAmB,EACnBC,0BAA0B,EAC1BC,mBAAmB,QACd,mCAAkC;AACzC,SAASC,uBAAuB,QAAQ,uCAAsC;AAC9E,SAASC,oBAAoB,QAAQ,oCAAmC;AACxE,SAASC,oBAAoB,QAAQ,oCAAmC;AACxE,SAASC,0BAA0B,QAAQ,0CAAyC;AACpF,SAASC,sBAAsB,QAAQ,sCAAqC;AAC5E,SAASC,6BAA6B,QAAQ,6CAA4C;AAC1F,SAASC,sBAAsB,QAAQ,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C;IAEjC,MAAM,EAAEQ,MAAM,EAAE1E,IAAI,EAAE0B,QAAQ,EAAE,GAAG,MAAMsC,uBAAuBC,UAAUC;IAE1E,OAAO;QAAEQ;QAAQ1E;QAAM0B;IAAS;AAClC"}
|
package/dist/directive-spec.json
CHANGED
|
@@ -111,6 +111,11 @@
|
|
|
111
111
|
{
|
|
112
112
|
"name": "section",
|
|
113
113
|
"attributes": [
|
|
114
|
+
{
|
|
115
|
+
"name": "palette",
|
|
116
|
+
"type": "string",
|
|
117
|
+
"format": "palette"
|
|
118
|
+
},
|
|
114
119
|
{
|
|
115
120
|
"name": "theme",
|
|
116
121
|
"type": "string",
|
|
@@ -206,6 +211,11 @@
|
|
|
206
211
|
"type": "string",
|
|
207
212
|
"format": "icon"
|
|
208
213
|
},
|
|
214
|
+
{
|
|
215
|
+
"name": "iconPalette",
|
|
216
|
+
"type": "string",
|
|
217
|
+
"format": "palette"
|
|
218
|
+
},
|
|
209
219
|
{
|
|
210
220
|
"name": "iconPosition",
|
|
211
221
|
"default": "left",
|
|
@@ -224,6 +234,11 @@
|
|
|
224
234
|
"false"
|
|
225
235
|
]
|
|
226
236
|
},
|
|
237
|
+
{
|
|
238
|
+
"name": "palette",
|
|
239
|
+
"type": "string",
|
|
240
|
+
"format": "palette"
|
|
241
|
+
},
|
|
227
242
|
{
|
|
228
243
|
"name": "size",
|
|
229
244
|
"default": "md",
|
|
@@ -470,6 +485,16 @@
|
|
|
470
485
|
"type": "string",
|
|
471
486
|
"format": "icon"
|
|
472
487
|
},
|
|
488
|
+
{
|
|
489
|
+
"name": "iconPalette",
|
|
490
|
+
"type": "string",
|
|
491
|
+
"format": "palette"
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
"name": "palette",
|
|
495
|
+
"type": "string",
|
|
496
|
+
"format": "palette"
|
|
497
|
+
},
|
|
473
498
|
{
|
|
474
499
|
"name": "theme",
|
|
475
500
|
"type": "string",
|
|
@@ -514,6 +539,11 @@
|
|
|
514
539
|
"false"
|
|
515
540
|
]
|
|
516
541
|
},
|
|
542
|
+
{
|
|
543
|
+
"name": "palette",
|
|
544
|
+
"type": "string",
|
|
545
|
+
"format": "palette"
|
|
546
|
+
},
|
|
517
547
|
{
|
|
518
548
|
"name": "theme",
|
|
519
549
|
"type": "string",
|
|
@@ -596,6 +626,11 @@
|
|
|
596
626
|
"false"
|
|
597
627
|
]
|
|
598
628
|
},
|
|
629
|
+
{
|
|
630
|
+
"name": "palette",
|
|
631
|
+
"type": "string",
|
|
632
|
+
"format": "palette"
|
|
633
|
+
},
|
|
599
634
|
{
|
|
600
635
|
"name": "stepTheme",
|
|
601
636
|
"type": "string",
|
|
@@ -648,6 +683,11 @@
|
|
|
648
683
|
"name": "href",
|
|
649
684
|
"type": "url"
|
|
650
685
|
},
|
|
686
|
+
{
|
|
687
|
+
"name": "iconPalette",
|
|
688
|
+
"type": "string",
|
|
689
|
+
"format": "palette"
|
|
690
|
+
},
|
|
651
691
|
{
|
|
652
692
|
"name": "linkScope",
|
|
653
693
|
"default": "section",
|
|
@@ -667,6 +707,11 @@
|
|
|
667
707
|
"false"
|
|
668
708
|
]
|
|
669
709
|
},
|
|
710
|
+
{
|
|
711
|
+
"name": "palette",
|
|
712
|
+
"type": "string",
|
|
713
|
+
"format": "palette"
|
|
714
|
+
},
|
|
670
715
|
{
|
|
671
716
|
"name": "theme",
|
|
672
717
|
"type": "string",
|
|
@@ -698,6 +743,11 @@
|
|
|
698
743
|
"type": "string",
|
|
699
744
|
"format": "icon"
|
|
700
745
|
},
|
|
746
|
+
{
|
|
747
|
+
"name": "iconPalette",
|
|
748
|
+
"type": "string",
|
|
749
|
+
"format": "palette"
|
|
750
|
+
},
|
|
701
751
|
{
|
|
702
752
|
"name": "linkScope",
|
|
703
753
|
"default": "full",
|
|
@@ -716,6 +766,11 @@
|
|
|
716
766
|
"false"
|
|
717
767
|
]
|
|
718
768
|
},
|
|
769
|
+
{
|
|
770
|
+
"name": "palette",
|
|
771
|
+
"type": "string",
|
|
772
|
+
"format": "palette"
|
|
773
|
+
},
|
|
719
774
|
{
|
|
720
775
|
"name": "theme",
|
|
721
776
|
"type": "string",
|
|
@@ -743,6 +798,11 @@
|
|
|
743
798
|
"name": "default",
|
|
744
799
|
"type": "string"
|
|
745
800
|
},
|
|
801
|
+
{
|
|
802
|
+
"name": "palette",
|
|
803
|
+
"type": "string",
|
|
804
|
+
"format": "palette"
|
|
805
|
+
},
|
|
746
806
|
{
|
|
747
807
|
"name": "tabTheme",
|
|
748
808
|
"type": "string",
|
|
@@ -2,7 +2,7 @@ import type { LayoutDirectiveDefinition } from '../types.js';
|
|
|
2
2
|
export declare const BUTTON_VARIANTS: readonly ["primary", "secondary", "outline", "ghost", "link"];
|
|
3
3
|
export declare const BUTTON_SIZES: readonly ["sm", "md", "lg"];
|
|
4
4
|
export declare const BUTTON_ICON_POSITIONS: readonly ["left", "right"];
|
|
5
|
-
export declare const BUTTON_ALLOWED_ATTRIBUTES: readonly ["ariaLabel", "href", "icon", "iconPosition", "newTab", "size", "variant"];
|
|
5
|
+
export declare const BUTTON_ALLOWED_ATTRIBUTES: readonly ["ariaLabel", "href", "icon", "iconPalette", "iconPosition", "newTab", "palette", "size", "variant"];
|
|
6
6
|
export declare const DEFAULT_BUTTON_VARIANT = "primary";
|
|
7
7
|
export declare const DEFAULT_BUTTON_SIZE = "md";
|
|
8
8
|
export declare const DEFAULT_BUTTON_ICON_POSITION = "left";
|