payload-markdown 1.8.0 → 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 +16 -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.js +4 -0
- package/dist/components/MarkdownRenderer/Component.js.map +1 -1
- package/dist/core/plugins/directiveButton.d.ts +1 -1
- package/dist/core/plugins/directiveButton.js +27 -10
- package/dist/core/plugins/directiveButton.js.map +1 -1
- package/dist/core/plugins/rehypeResolveIcons.js +10 -1
- package/dist/core/plugins/rehypeResolveIcons.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 +13 -1
- 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 +9 -2
- package/dist/directives/definitions/callout.js.map +1 -1
- package/dist/directives/definitions/card.d.ts +0 -2
- package/dist/directives/definitions/card.js +13 -8
- package/dist/directives/definitions/card.js.map +1 -1
- package/dist/directives/definitions/cards.js +9 -0
- package/dist/directives/definitions/cards.js.map +1 -1
- package/dist/directives/definitions/details.js +4 -0
- package/dist/directives/definitions/details.js.map +1 -1
- package/dist/directives/definitions/section.js +4 -0
- package/dist/directives/definitions/section.js.map +1 -1
- package/dist/directives/definitions/steps.js +4 -0
- package/dist/directives/definitions/steps.js.map +1 -1
- package/dist/directives/definitions/tabs.js +4 -0
- package/dist/directives/definitions/tabs.js.map +1 -1
- package/dist/directives/definitions/toc.js +1 -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/spec.d.ts +6 -2
- package/dist/directives/spec.js +5 -0
- package/dist/directives/spec.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/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 +21 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/types/core.d.ts +43 -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 +1 -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
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { parseButtonDirectiveLine } from '../../directives/buttonSyntax.js';
|
|
2
|
-
import { DEFAULT_BUTTON_ICON_POSITION, DEFAULT_BUTTON_SIZE, DEFAULT_BUTTON_VARIANT, isButtonIconPosition, isButtonSize, isButtonVariant } from '../../directives/definitions/button.js';
|
|
2
|
+
import { BUTTON_ALLOWED_ATTRIBUTES, DEFAULT_BUTTON_ICON_POSITION, DEFAULT_BUTTON_SIZE, DEFAULT_BUTTON_VARIANT, isButtonIconPosition, isButtonSize, isButtonVariant } from '../../directives/definitions/button.js';
|
|
3
3
|
import { layoutDirectiveRegistry } from '../../directives/registry.js';
|
|
4
4
|
import { getSafeHref } from '../../directives/urls.js';
|
|
5
|
+
import { getExtraIconWarnings, parseIconEntries } from '../../icons/entries.js';
|
|
5
6
|
import { normalizePayloadMarkdownIconRef } from '../../icons/refs.js';
|
|
7
|
+
import { collectPaletteNames, getUnknownPaletteWarning } from '../../palettes/diagnostics.js';
|
|
6
8
|
function getAttribute(attributes, name) {
|
|
7
9
|
const value = attributes[name];
|
|
8
10
|
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
@@ -13,7 +15,7 @@ function getBooleanAttribute(attributes, name) {
|
|
|
13
15
|
if (typeof value !== 'string') return false;
|
|
14
16
|
return value === 'true';
|
|
15
17
|
}
|
|
16
|
-
function makeIconPlaceholder(icon, iconPosition) {
|
|
18
|
+
function makeIconPlaceholder(icon, iconPosition, palette) {
|
|
17
19
|
const normalized = normalizePayloadMarkdownIconRef(icon);
|
|
18
20
|
const iconKey = normalized.icon?.key ?? icon;
|
|
19
21
|
return {
|
|
@@ -26,13 +28,16 @@ function makeIconPlaceholder(icon, iconPosition) {
|
|
|
26
28
|
`pmd-button__icon--${iconPosition}`
|
|
27
29
|
],
|
|
28
30
|
dataPmdIcon: iconKey,
|
|
31
|
+
...palette ? {
|
|
32
|
+
dataPmdIconPalette: palette
|
|
33
|
+
} : {},
|
|
29
34
|
dataPmdIconRef: icon,
|
|
30
35
|
focusable: 'false'
|
|
31
36
|
},
|
|
32
37
|
tagName: 'span'
|
|
33
38
|
};
|
|
34
39
|
}
|
|
35
|
-
export function makeButtonDirective(line, file,
|
|
40
|
+
export function makeButtonDirective(line, file, config) {
|
|
36
41
|
const parsed = parseButtonDirectiveLine(line);
|
|
37
42
|
if (!parsed) return undefined;
|
|
38
43
|
const definition = layoutDirectiveRegistry.get('button');
|
|
@@ -42,7 +47,12 @@ export function makeButtonDirective(line, file, _config) {
|
|
|
42
47
|
const variant = isButtonVariant(attributes.variant) ? attributes.variant : DEFAULT_BUTTON_VARIANT;
|
|
43
48
|
const size = isButtonSize(attributes.size) ? attributes.size : DEFAULT_BUTTON_SIZE;
|
|
44
49
|
const iconPosition = isButtonIconPosition(attributes.iconPosition) ? attributes.iconPosition : DEFAULT_BUTTON_ICON_POSITION;
|
|
45
|
-
|
|
50
|
+
// A button shows one icon; it may carry its own palette (`@pack/name palette=x`).
|
|
51
|
+
const iconEntries = parseIconEntries(getAttribute(attributes, 'icon'));
|
|
52
|
+
const [iconEntry] = iconEntries.entries;
|
|
53
|
+
const icon = iconEntry?.ref;
|
|
54
|
+
const palette = getAttribute(attributes, 'palette');
|
|
55
|
+
const iconPalette = iconEntry?.palette ?? getAttribute(attributes, 'iconPalette') ?? palette;
|
|
46
56
|
const ariaLabel = getAttribute(attributes, 'ariaLabel');
|
|
47
57
|
const newTab = getBooleanAttribute(attributes, 'newTab');
|
|
48
58
|
for (const warning of parsed.warnings)file.message(warning);
|
|
@@ -54,10 +64,18 @@ export function makeButtonDirective(line, file, _config) {
|
|
|
54
64
|
const normalized = normalizePayloadMarkdownIconRef(icon);
|
|
55
65
|
if (normalized.warning) file.message(normalized.warning);
|
|
56
66
|
}
|
|
67
|
+
for (const warning of [
|
|
68
|
+
...iconEntries.warnings,
|
|
69
|
+
...getExtraIconWarnings('button', iconEntries.entries)
|
|
70
|
+
])file.message(warning);
|
|
71
|
+
for (const name of collectPaletteNames(BUTTON_ALLOWED_ATTRIBUTES, attributes)){
|
|
72
|
+
const warning = getUnknownPaletteWarning(name, 'button', config);
|
|
73
|
+
if (warning) file.message(warning);
|
|
74
|
+
}
|
|
57
75
|
if (!label && !ariaLabel) file.message('Icon-only button requires an ariaLabel attribute.');
|
|
58
76
|
const hChildren = [
|
|
59
77
|
...icon && iconPosition === 'left' ? [
|
|
60
|
-
makeIconPlaceholder(icon, iconPosition)
|
|
78
|
+
makeIconPlaceholder(icon, iconPosition, iconPalette)
|
|
61
79
|
] : [],
|
|
62
80
|
...label ? [
|
|
63
81
|
{
|
|
@@ -66,7 +84,7 @@ export function makeButtonDirective(line, file, _config) {
|
|
|
66
84
|
}
|
|
67
85
|
] : [],
|
|
68
86
|
...icon && iconPosition === 'right' ? [
|
|
69
|
-
makeIconPlaceholder(icon, iconPosition)
|
|
87
|
+
makeIconPlaceholder(icon, iconPosition, iconPalette)
|
|
70
88
|
] : []
|
|
71
89
|
];
|
|
72
90
|
return {
|
|
@@ -92,14 +110,13 @@ export function makeButtonDirective(line, file, _config) {
|
|
|
92
110
|
className: [
|
|
93
111
|
'pmd-button',
|
|
94
112
|
`pmd-button--${variant}`,
|
|
95
|
-
`pmd-button--${size}
|
|
96
|
-
...!label && icon ? [
|
|
97
|
-
'pmd-button--icon-only'
|
|
98
|
-
] : []
|
|
113
|
+
`pmd-button--${size}`
|
|
99
114
|
],
|
|
100
115
|
dataButton: '',
|
|
101
116
|
dataDirective: 'button',
|
|
117
|
+
dataIconPalette: getAttribute(attributes, 'iconPalette'),
|
|
102
118
|
dataIconPosition: icon ? iconPosition : undefined,
|
|
119
|
+
dataPalette: palette,
|
|
103
120
|
dataSize: size,
|
|
104
121
|
dataVariant: variant,
|
|
105
122
|
href,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/plugins/directiveButton.ts"],"sourcesContent":["import type { LeafDirective } from 'mdast-util-directive'\n\nimport type { MarkdownRenderConfig } from '../../types/core.js'\n\nimport { parseButtonDirectiveLine } from '../../directives/buttonSyntax.js'\nimport {\n DEFAULT_BUTTON_ICON_POSITION,\n DEFAULT_BUTTON_SIZE,\n DEFAULT_BUTTON_VARIANT,\n isButtonIconPosition,\n isButtonSize,\n isButtonVariant,\n} from '../../directives/definitions/button.js'\nimport { layoutDirectiveRegistry } from '../../directives/registry.js'\nimport { getSafeHref } from '../../directives/urls.js'\nimport { normalizePayloadMarkdownIconRef } from '../../icons/refs.js'\n\nexport type MessageFile = {\n message: (reason: string) => unknown\n}\n\nfunction getAttribute(attributes: Record<string, boolean | string>, name: string): string | undefined {\n const value = attributes[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nfunction getBooleanAttribute(attributes: Record<string, boolean | string>, name: string): boolean {\n const value = attributes[name]\n\n if (value === true) return true\n if (typeof value !== 'string') return false\n\n return value === 'true'\n}\n\nfunction makeIconPlaceholder(icon: string, iconPosition: 'left' | 'right') {\n const normalized = normalizePayloadMarkdownIconRef(icon)\n const iconKey = normalized.icon?.key ?? icon\n\n return {\n type: 'element' as const,\n children: [],\n properties: {\n ariaHidden: 'true',\n className: [\n 'pmd-button__icon',\n `pmd-button__icon--${iconPosition}`,\n ],\n dataPmdIcon: iconKey,\n dataPmdIconRef: icon,\n focusable: 'false',\n },\n tagName: 'span',\n }\n}\n\nexport function makeButtonDirective(\n line: string,\n file: MessageFile,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/core/plugins/directiveButton.ts"],"sourcesContent":["import type { LeafDirective } from 'mdast-util-directive'\n\nimport type { MarkdownRenderConfig } from '../../types/core.js'\n\nimport { parseButtonDirectiveLine } from '../../directives/buttonSyntax.js'\nimport {\n BUTTON_ALLOWED_ATTRIBUTES,\n DEFAULT_BUTTON_ICON_POSITION,\n DEFAULT_BUTTON_SIZE,\n DEFAULT_BUTTON_VARIANT,\n isButtonIconPosition,\n isButtonSize,\n isButtonVariant,\n} from '../../directives/definitions/button.js'\nimport { layoutDirectiveRegistry } from '../../directives/registry.js'\nimport { getSafeHref } from '../../directives/urls.js'\nimport { getExtraIconWarnings, parseIconEntries } from '../../icons/entries.js'\nimport { normalizePayloadMarkdownIconRef } from '../../icons/refs.js'\nimport { collectPaletteNames, getUnknownPaletteWarning } from '../../palettes/diagnostics.js'\n\nexport type MessageFile = {\n message: (reason: string) => unknown\n}\n\nfunction getAttribute(attributes: Record<string, boolean | string>, name: string): string | undefined {\n const value = attributes[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nfunction getBooleanAttribute(attributes: Record<string, boolean | string>, name: string): boolean {\n const value = attributes[name]\n\n if (value === true) return true\n if (typeof value !== 'string') return false\n\n return value === 'true'\n}\n\nfunction makeIconPlaceholder(icon: string, iconPosition: 'left' | 'right', palette?: string) {\n const normalized = normalizePayloadMarkdownIconRef(icon)\n const iconKey = normalized.icon?.key ?? icon\n\n return {\n type: 'element' as const,\n children: [],\n properties: {\n ariaHidden: 'true',\n className: [\n 'pmd-button__icon',\n `pmd-button__icon--${iconPosition}`,\n ],\n dataPmdIcon: iconKey,\n ...(palette ? { dataPmdIconPalette: palette } : {}),\n dataPmdIconRef: icon,\n focusable: 'false',\n },\n tagName: 'span',\n }\n}\n\nexport function makeButtonDirective(\n line: string,\n file: MessageFile,\n config: MarkdownRenderConfig,\n): LeafDirective | undefined {\n const parsed = parseButtonDirectiveLine(line)\n if (!parsed) return undefined\n\n const definition = layoutDirectiveRegistry.get('button')\n const attributes = parsed.attributes\n const label = parsed.label.trim()\n const href = getSafeHref(getAttribute(attributes, 'href'))\n const variant = isButtonVariant(attributes.variant) ? attributes.variant : DEFAULT_BUTTON_VARIANT\n const size = isButtonSize(attributes.size) ? attributes.size : DEFAULT_BUTTON_SIZE\n const iconPosition = isButtonIconPosition(attributes.iconPosition)\n ? attributes.iconPosition\n : DEFAULT_BUTTON_ICON_POSITION\n // A button shows one icon; it may carry its own palette (`@pack/name palette=x`).\n const iconEntries = parseIconEntries(getAttribute(attributes, 'icon'))\n const [iconEntry] = iconEntries.entries\n const icon = iconEntry?.ref\n const palette = getAttribute(attributes, 'palette')\n const iconPalette = iconEntry?.palette ?? getAttribute(attributes, 'iconPalette') ?? palette\n const ariaLabel = getAttribute(attributes, 'ariaLabel')\n const newTab = getBooleanAttribute(attributes, 'newTab')\n\n for (const warning of parsed.warnings) file.message(warning)\n for (const warning of definition?.validateAttributes?.({ name: 'button', attributes }) ?? [])\n file.message(warning)\n\n if (icon) {\n const normalized = normalizePayloadMarkdownIconRef(icon)\n if (normalized.warning) file.message(normalized.warning)\n }\n\n for (const warning of [...iconEntries.warnings, ...getExtraIconWarnings('button', iconEntries.entries)])\n file.message(warning)\n\n for (const name of collectPaletteNames(BUTTON_ALLOWED_ATTRIBUTES, attributes)) {\n const warning = getUnknownPaletteWarning(name, 'button', config)\n if (warning) file.message(warning)\n }\n\n if (!label && !ariaLabel) file.message('Icon-only button requires an ariaLabel attribute.')\n\n const hChildren = [\n ...(icon && iconPosition === 'left' ? [makeIconPlaceholder(icon, iconPosition, iconPalette)] : []),\n ...(label\n ? [\n {\n type: 'text' as const,\n value: label,\n },\n ]\n : []),\n ...(icon && iconPosition === 'right' ? [makeIconPlaceholder(icon, iconPosition, iconPalette)] : []),\n ]\n\n return {\n name: 'button',\n type: 'leafDirective',\n attributes: Object.fromEntries(\n Object.entries(attributes).map(([key, value]) => [key, String(value)]),\n ),\n children: label ? [{ type: 'text', value: label }] : [],\n data: {\n hChildren,\n hName: 'a',\n hProperties: {\n ...(ariaLabel ? { ariaLabel } : {}),\n className: [\n 'pmd-button',\n `pmd-button--${variant}`,\n `pmd-button--${size}`,\n ],\n dataButton: '',\n dataDirective: 'button',\n dataIconPalette: getAttribute(attributes, 'iconPalette'),\n dataIconPosition: icon ? iconPosition : undefined,\n dataPalette: palette,\n dataSize: size,\n dataVariant: variant,\n href,\n ...(newTab\n ? {\n rel: 'noopener noreferrer',\n target: '_blank',\n }\n : {}),\n },\n },\n }\n}\n"],"names":["parseButtonDirectiveLine","BUTTON_ALLOWED_ATTRIBUTES","DEFAULT_BUTTON_ICON_POSITION","DEFAULT_BUTTON_SIZE","DEFAULT_BUTTON_VARIANT","isButtonIconPosition","isButtonSize","isButtonVariant","layoutDirectiveRegistry","getSafeHref","getExtraIconWarnings","parseIconEntries","normalizePayloadMarkdownIconRef","collectPaletteNames","getUnknownPaletteWarning","getAttribute","attributes","name","value","trim","undefined","getBooleanAttribute","makeIconPlaceholder","icon","iconPosition","palette","normalized","iconKey","key","type","children","properties","ariaHidden","className","dataPmdIcon","dataPmdIconPalette","dataPmdIconRef","focusable","tagName","makeButtonDirective","line","file","config","parsed","definition","get","label","href","variant","size","iconEntries","iconEntry","entries","ref","iconPalette","ariaLabel","newTab","warning","warnings","message","validateAttributes","hChildren","Object","fromEntries","map","String","data","hName","hProperties","dataButton","dataDirective","dataIconPalette","dataIconPosition","dataPalette","dataSize","dataVariant","rel","target"],"mappings":"AAIA,SAASA,wBAAwB,QAAQ,mCAAkC;AAC3E,SACEC,yBAAyB,EACzBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,sBAAsB,EACtBC,oBAAoB,EACpBC,YAAY,EACZC,eAAe,QACV,yCAAwC;AAC/C,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,WAAW,QAAQ,2BAA0B;AACtD,SAASC,oBAAoB,EAAEC,gBAAgB,QAAQ,yBAAwB;AAC/E,SAASC,+B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C,iBAAiB,UAAU;YAACF,oBAAoBC,MAAMC,cAAc8B;SAAa,GAAG,EAAE;KACnG;IAED,OAAO;QACLrC,MAAM;QACNY,MAAM;QACNb,YAAY8C,OAAOC,WAAW,CAC5BD,OAAOV,OAAO,CAACpC,YAAYgD,GAAG,CAAC,CAAC,CAACpC,KAAKV,MAAM,GAAK;gBAACU;gBAAKqC,OAAO/C;aAAO;QAEvEY,UAAUgB,QAAQ;YAAC;gBAAEjB,MAAM;gBAAQX,OAAO4B;YAAM;SAAE,GAAG,EAAE;QACvDoB,MAAM;YACJL;YACAM,OAAO;YACPC,aAAa;gBACX,GAAIb,YAAY;oBAAEA;gBAAU,IAAI,CAAC,CAAC;gBAClCtB,WAAW;oBACT;oBACA,CAAC,YAAY,EAAEe,SAAS;oBACxB,CAAC,YAAY,EAAEC,MAAM;iBACtB;gBACDoB,YAAY;gBACZC,eAAe;gBACfC,iBAAiBxD,aAAaC,YAAY;gBAC1CwD,kBAAkBjD,OAAOC,eAAeJ;gBACxCqD,aAAahD;gBACbiD,UAAUzB;gBACV0B,aAAa3B;gBACbD;gBACA,GAAIS,SACA;oBACEoB,KAAK;oBACLC,QAAQ;gBACV,IACA,CAAC,CAAC;YACR;QACF;IACF;AACF"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Root } from 'mdast';
|
|
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,qBAAqBC,IAAa;IACzC,OAAOC,QACLD,QACE,OAAOA,SAAS,YAChB,UAAUA,QACV,AAACA,KAA2BE,IAAI,KAAK;AAE3C;AAEA,SAASC,kBAAkBH,IAAwB,EAAEI,IAAoB,EAAEC,MAA4B;IACrG,MAAMC,UAAUd,wBAAwBe,GAAG,CAACP,KAAKQ,IAAI,GAAGC;IACxD,IAAI,CAACH,SAAS;IAEd,MAAMI,QAAQV,KAAKW,IAAI,EAAEC;IAEzB,IAAIN,QAAQO,QAAQ,CAAC,SAAS;QAC5B,MAAMC,OAAOd,KAAKe,UAAU,EAAED;QAC9B,MAAM,EAAEE,OAAO,EAAEC,QAAQ,EAAE,GAAGvB,iBAAiB,OAAOoB,SAAS,WAAWA,OAAOI;QAEjF,KAAK,MAAMC,WAAW;eAAIF;eAAaxB,qBAAqBO,KAAKQ,IAAI,EAAEQ;SAAS,CAC9ElB,iBAAiBM,MAAMe,SAAS;YAAEC,MAAM;YAAeV;YAAOW,QAAQ;QAAO;IACjF;IAEA,KAAK,MAAMb,QAAQb,oBAAoBW,SAASN,KAAKe,UAAU,EAAG;QAChE,MAAMI,UAAUvB,yBAAyBY,MAAMR,KAAKQ,IAAI,EAAEH;QAC1D,IAAIc,SAASrB,iBAAiBM,MAAMe,SAAS;YAAEC,MAAM;YAAmBV;YAAOW,QAAQ;QAAQ;IACjG;AACF;AAEA;;;;CAIC,GACD,OAAO,MAAMC,yBAAgE,CAC3EjB,SAA+B,CAAC,CAAC;IAEjC,OAAO,CAACkB,MAAMnB;QACZ,KAAK,MAAMe,WAAWtB,mBAAmBQ,OAAOmB,QAAQ,EAAEP,QAAQ,CAChEnB,iBAAiBM,MAAMe,SAAS;YAAEC,MAAM;YAAkBC,QAAQ;QAAQ;QAE5E9B,MAAMgC,MAAM,CAACvB;YACX,IAAID,qBAAqBC,OAAOG,kBAAkBH,MAAMI,MAAMC;QAChE;IACF;AACF,EAAC"}
|
|
@@ -22,6 +22,7 @@ import { remarkDirectiveLines } from './plugins/remarkDirectiveLines.js';
|
|
|
22
22
|
import { remarkHeadingAnchorsAndToc } from './plugins/remarkHeadingAnchorsAndToc.js';
|
|
23
23
|
import { remarkLayoutDirectives } from './plugins/remarkLayoutDirectives.js';
|
|
24
24
|
import { remarkValidateDirectiveThemes } from './plugins/remarkValidateDirectiveThemes.js';
|
|
25
|
+
import { remarkValidatePalettes } from './plugins/remarkValidatePalettes.js';
|
|
25
26
|
import { getRenderData } from './renderData.js';
|
|
26
27
|
function extractCodeLanguage(className) {
|
|
27
28
|
const classes = typeof className === 'string' ? className.split(/\s+/) : Array.isArray(className) ? className : [];
|
|
@@ -101,6 +102,8 @@ const sanitizeSchema = {
|
|
|
101
102
|
'className',
|
|
102
103
|
'dataButton',
|
|
103
104
|
'dataDirective',
|
|
105
|
+
'dataIconPalette',
|
|
106
|
+
'dataPalette',
|
|
104
107
|
'dataDirectiveLink',
|
|
105
108
|
'dataIconPosition',
|
|
106
109
|
'dataSize',
|
|
@@ -115,6 +118,8 @@ const sanitizeSchema = {
|
|
|
115
118
|
...getAttributeDefinitions(defaultSchema.attributes?.article ?? []),
|
|
116
119
|
'className',
|
|
117
120
|
'dataDirective',
|
|
121
|
+
'dataIconPalette',
|
|
122
|
+
'dataPalette',
|
|
118
123
|
'dataEyebrow',
|
|
119
124
|
'dataHref',
|
|
120
125
|
'dataIcon',
|
|
@@ -152,6 +157,8 @@ const sanitizeSchema = {
|
|
|
152
157
|
details: [
|
|
153
158
|
...getAttributeDefinitions(defaultSchema.attributes?.details ?? []),
|
|
154
159
|
'dataDirective',
|
|
160
|
+
'dataIconPalette',
|
|
161
|
+
'dataPalette',
|
|
155
162
|
'dataTheme',
|
|
156
163
|
'dataTitle',
|
|
157
164
|
'dataVlLayout',
|
|
@@ -161,6 +168,8 @@ const sanitizeSchema = {
|
|
|
161
168
|
...getAttributeDefinitions(defaultSchema.attributes?.div ?? []),
|
|
162
169
|
'dataAlign',
|
|
163
170
|
'dataDirective',
|
|
171
|
+
'dataIconPalette',
|
|
172
|
+
'dataPalette',
|
|
164
173
|
'dataDirectiveBody',
|
|
165
174
|
'dataDirectiveTitle',
|
|
166
175
|
'dataEyebrow',
|
|
@@ -258,6 +267,8 @@ const sanitizeSchema = {
|
|
|
258
267
|
'dataDefault',
|
|
259
268
|
'dataDisabled',
|
|
260
269
|
'dataDirective',
|
|
270
|
+
'dataIconPalette',
|
|
271
|
+
'dataPalette',
|
|
261
272
|
'dataHref',
|
|
262
273
|
'dataLabel',
|
|
263
274
|
'dataLinkScope',
|
|
@@ -279,6 +290,7 @@ const sanitizeSchema = {
|
|
|
279
290
|
...getAttributeDefinitions(defaultSchema.attributes?.span ?? []),
|
|
280
291
|
'className',
|
|
281
292
|
'dataPmdIcon',
|
|
293
|
+
'dataPmdIconPalette',
|
|
282
294
|
'dataPmdIconRef',
|
|
283
295
|
'dataStepNumber',
|
|
284
296
|
'focusable',
|
|
@@ -315,7 +327,7 @@ const FAILED_RENDER_HTML = '<p>Failed to render markdown.</p>';
|
|
|
315
327
|
*/ export async function renderMarkdownDocument(markdown, config = {}) {
|
|
316
328
|
const pipelineNonce = createPipelineNonce();
|
|
317
329
|
try {
|
|
318
|
-
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, {
|
|
319
331
|
allowDangerousHtml: true
|
|
320
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);
|
|
321
333
|
const data = getRenderData(file);
|
|
@@ -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 { 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 { 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', 'tabIndex'],\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', '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 '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(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","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,kBAAi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AAMD,UAAUC,iBAAiBC,QAAQD,MAAMD,OAAO,GAAG;QAEzD,yEAAyE;QACzE,sCAAsC;QACtCG,QAAQF,KAAK,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;AACp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;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,SAAS;eACJL,wBAAwBrF,cAAcwF,UAAU,EAAEE,WAAW,EAAE;YAClE;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,QAAQ;eACHN,wBAAwBrF,cAAcwF,UAAU,EAAEG,UAAU,EAAE;YACjE;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDjC,MAAM;eAAI2B,wBAAwBrF,cAAcwF,UAAU,EAAE9B,QAAQ,EAAE;YAAG;YAAa;SAAW;QACjGkC,SAAS;eACJP,wBAAwBrF,cAAcwF,UAAU,EAAEI,WAAW,EAAE;YAClE;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,KAAK;eACAR,wBAAwBrF,cAAcwF,UAAU,EAAEK,OAAO,EAAE;YAC9D;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,IAAI;eACCT,wBAAwBrF,cAAcwF,UAAU,EAAEM,MAAM,EAAE;YAC7D;YACA;YACA;SACD;QACDC,IAAI;eACCV,wBAAwBrF,cAAcwF,UAAU,EAAEO,MAAM,EAAE;YAC7D;YACA;YACA;SACD;QACDC,IAAI;eACCX,wBAAwBrF,cAAcwF,UAAU,EAAEQ,MAAM,EAAE;YAC7D;YACA;YACA;SACD;QACDC,IAAI;eAAIZ,wBAAwBrF,cAAcwF,UAAU,EAAES,MAAM,EAAE;YAAG;YAAqB;SAAK;QAC/FC,IAAI;eAAIb,wBAAwBrF,cAAcwF,UAAU,EAAEU,MAAM,EAAE;YAAG;YAAqB;SAAK;QAC/FC,IAAI;eAAId,wBAAwBrF,cAAcwF,UAAU,EAAEW,MAAM,EAAE;YAAG;Y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D;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"}
|
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";
|