payload-markdown 1.7.2 → 1.8.0

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.
Files changed (65) hide show
  1. package/README.md +1 -0
  2. package/dist/components/MarkdownRenderer/Component.client.js +9 -19
  3. package/dist/components/MarkdownRenderer/Component.client.js.map +1 -1
  4. package/dist/components/MarkdownRenderer/Component.js +55 -21
  5. package/dist/components/MarkdownRenderer/Component.js.map +1 -1
  6. package/dist/components/MarkdownRenderer/index.css +93 -42
  7. package/dist/components/MarkdownRenderer/index.scss +128 -57
  8. package/dist/core/codeToHtml.js +6 -0
  9. package/dist/core/codeToHtml.js.map +1 -1
  10. package/dist/core/plugins/directiveBadge.js +2 -0
  11. package/dist/core/plugins/directiveBadge.js.map +1 -1
  12. package/dist/core/plugins/directiveButton.js +4 -1
  13. package/dist/core/plugins/directiveButton.js.map +1 -1
  14. package/dist/core/plugins/rehypeContentLayout.d.ts +12 -0
  15. package/dist/core/plugins/rehypeContentLayout.js +64 -0
  16. package/dist/core/plugins/rehypeContentLayout.js.map +1 -0
  17. package/dist/core/plugins/remarkHeadingAnchorsAndToc.js +8 -0
  18. package/dist/core/plugins/remarkHeadingAnchorsAndToc.js.map +1 -1
  19. package/dist/core/renderMarkdown.js +6 -3
  20. package/dist/core/renderMarkdown.js.map +1 -1
  21. package/dist/directives/definitions/callout.js +20 -11
  22. package/dist/directives/definitions/callout.js.map +1 -1
  23. package/dist/directives/definitions/card.d.ts +4 -2
  24. package/dist/directives/definitions/card.js +39 -11
  25. package/dist/directives/definitions/card.js.map +1 -1
  26. package/dist/directives/definitions/cards.js +10 -6
  27. package/dist/directives/definitions/cards.js.map +1 -1
  28. package/dist/directives/definitions/cell.js +4 -2
  29. package/dist/directives/definitions/cell.js.map +1 -1
  30. package/dist/directives/definitions/columns.js +2 -1
  31. package/dist/directives/definitions/columns.js.map +1 -1
  32. package/dist/directives/definitions/details.js +5 -3
  33. package/dist/directives/definitions/details.js.map +1 -1
  34. package/dist/directives/definitions/section.js +1 -1
  35. package/dist/directives/definitions/section.js.map +1 -1
  36. package/dist/directives/definitions/steps.js +34 -14
  37. package/dist/directives/definitions/steps.js.map +1 -1
  38. package/dist/directives/definitions/tab.js +2 -1
  39. package/dist/directives/definitions/tab.js.map +1 -1
  40. package/dist/directives/definitions/tabs.js +9 -6
  41. package/dist/directives/definitions/tabs.js.map +1 -1
  42. package/dist/directives/definitions/toc.js +2 -1
  43. package/dist/directives/definitions/toc.js.map +1 -1
  44. package/dist/directives/shields.js +16 -3
  45. package/dist/directives/shields.js.map +1 -1
  46. package/dist/directives/themes.js +13 -13
  47. package/dist/directives/themes.js.map +1 -1
  48. package/dist/exports/render.d.ts +2 -1
  49. package/dist/exports/render.js +1 -0
  50. package/dist/exports/render.js.map +1 -1
  51. package/dist/index.d.ts +1 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/runtime/index.js +2 -0
  54. package/dist/runtime/index.js.map +1 -1
  55. package/dist/styles/directiveSurface.d.ts +39 -5
  56. package/dist/styles/directiveSurface.js +56 -13
  57. package/dist/styles/directiveSurface.js.map +1 -1
  58. package/dist/types/core.d.ts +13 -0
  59. package/dist/types/core.js.map +1 -1
  60. package/dist/version.d.ts +1 -1
  61. package/dist/version.js +1 -1
  62. package/dist/version.js.map +1 -1
  63. package/package.json +2 -1
  64. package/skills/payload-markdown/claude/skill.json +1 -1
  65. package/skills/payload-markdown/codex/skill.json +1 -1
@@ -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","depth","title","visibleHeadings","filter","remarkHeadingAnchorsAndToc","file"],"mappings":"AAIA,SAASA,KAAK,QAAQ,mBAAkB;AAIxC,SAASC,eAAe,EAAEC,eAAe,QAAQ,sCAAqC;AACtF,SAASC,mBAAmB,QAAQ,qCAAoC;A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AM;YAAEZ;QAAS;QAE/BI,gBAAgBC,MAAML;IACxB;AACF,EAAC"}
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;gBAAEH,MAAM;gBAAQE,OAAOG,QAAQC,IAAI;YAAC;SAAE;QACjDC,KAAK,CAAC,CAAC,EAAEF,QAAQG,EAAE,EAAE;IACvB;AACF;AAEA,SAASC,YAAYC,QAAyB;IAC5C,2EAA2E;IAC3E,6CAA6C;IAC7C,MAAMC,WAAWC,KAAKC,GAAG,IAAIH,SAASI,GAAG,CAAC,CAACT,UAAYA,QAAQU,KAAK;IAEpE,OAAO;QACLf,MAAM;QACNG,UAAUO,SAASI,GAAG,CACpB,CAACT,UAAuB,CAAA;gBACtBL,MAAM;gBACNG,UAAU;oBACR;wBACEH,MAAM;wBACNG,UAAU;4BAACC,YAAYC;yBAAS;oBAClC;iBACD;gBACDW,MAAM;oBAAEC,aAAa;wBAAEC,cAAcC,OAAOd,QAAQU,KAAK,GAAGJ;oBAAU;gBAAE;gBACxES,QAAQ;YACV,CAAA;QAEFC,SAAS;QACTD,QAAQ;IACV;AACF;AAEA,SAASE,gBAAgBC,IAAU,EAAEb,QAAyB;IAC5DlB,MAAM+B,MAAM,CAACzB;QACX,IAAI,CAACD,qBAAqBC,SAASA,KAAK0B,IAAI,KAAK,OAAO;QAExD,MAAMT,QAAQtB,gBAAgBK;QAC9B,MAAM2B,QAAQ/B,gBAAgBI;QAC9B,MAAM4B,kBAAkBhB,SAASiB,MAAM,CAAC,CAACtB,UAAYA,QAAQU,KAAK,IAAIA;QAEtE,yEAAyE;QACzE,yEAAyE;QACzEjB,KAAKK,QAAQ,GAAG;YAACF,cAAcwB;YAAQhB,YAAYiB;eAAqB5B,KAAKK,QAAQ;SAAC;IACxF;AACF;AAEA,OAAO,MAAMyB,6BAA+C;IAC1D,OAAO,CAACL,MAAMM;QACZ,MAAMnB,WAAWf,oBAAoB4B;QAErC,yDAAyD;QACzD3B,cAAciC,MAAM;YAAEnB;QAAS;QAE/BY,gBAAgBC,MAAMb;IACxB;AACF,EAAC"}
@@ -12,6 +12,7 @@ import { resolveRenderMarkdownOptions } from './codeConfig.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';
@@ -145,7 +146,8 @@ const sanitizeSchema = {
145
146
  ],
146
147
  code: [
147
148
  ...getAttributeDefinitions(defaultSchema.attributes?.code ?? []),
148
- 'className'
149
+ 'className',
150
+ 'tabIndex'
149
151
  ],
150
152
  details: [
151
153
  ...getAttributeDefinitions(defaultSchema.attributes?.details ?? []),
@@ -227,7 +229,8 @@ const sanitizeSchema = {
227
229
  ],
228
230
  li: [
229
231
  ...getAttributeDefinitions(defaultSchema.attributes?.li ?? []),
230
- 'dataStep'
232
+ 'dataStep',
233
+ 'dataTocLevel'
231
234
  ],
232
235
  nav: [
233
236
  ...getAttributeDefinitions(defaultSchema.attributes?.nav ?? []),
@@ -314,7 +317,7 @@ const FAILED_RENDER_HTML = '<p>Failed to render markdown.</p>';
314
317
  try {
315
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, {
316
319
  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);
320
+ }).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
321
  const data = getRenderData(file);
319
322
  const diagnostics = file.messages.map(toRenderDiagnostic);
320
323
  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,kBAAiB;AAC/C,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,mBAAkB;AACvE,SAASC,wBAAwB,QAAQ,wCAAuC;AAChF,SAASC,kBAAkB,QAAQ,kCAAiC;AACpE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BAACK;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 { 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,SA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QAAQ,CAAC9C,GAAG,CAAC/D;QAEtC,OAAO;YACL4G;YACAE,QAAQ,EAAE;YACVC,UAAUJ,KAAKI,QAAQ,IAAI,EAAE;YAC7B3E,MAAM4E,OAAOtE;YACbuE,OAAON,KAAKM,KAAK,IAAI,EAAE;YACvBC,MAAMP,KAAKO,IAAI,IAAI;YACnBpD,UAAU8C,YAAY7C,GAAG,CAAC,CAACK,aAAeA,WAAW+C,OAAO;QAC9D;IACF,EAAE,OAAOC,OAAO;QACd,MAAMD,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,3 +1,4 @@
1
+ import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
1
2
  import { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js';
2
3
  import { getDirectiveLabelOrAttribute } from '../labels.js';
3
4
  import { resolveDirectiveTheme } from '../themes.js';
@@ -9,13 +10,17 @@ export const CALLOUT_VARIANTS = [
9
10
  'danger',
10
11
  'success'
11
12
  ];
13
+ // The tint is a background-image so it layers over the theme's background
14
+ // color instead of competing with it, and the ring composes with the theme's
15
+ // shadow. Text, title and ring colours follow the colour scheme through
16
+ // `--pmd-scheme-dark` (see styles/directiveSurface.ts).
12
17
  const calloutVariantClasses = {
13
- danger: 'bg-red-500/10 text-red-50',
14
- info: 'bg-sky-500/10 text-sky-50',
15
- note: 'bg-slate-500/10 text-slate-50',
16
- success: 'bg-emerald-500/10 text-emerald-50',
17
- tip: 'bg-cyan-500/10 text-cyan-50',
18
- warning: 'bg-amber-500/10 text-amber-50'
18
+ danger: 'bg-linear-to-r from-red-500/10 to-red-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(248_113_113/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(220_38_38/0.2))] text-[color:color-mix(in_oklab,rgb(254_242_242)_calc(var(--pmd-scheme-dark,1)*100%),rgb(69_10_10))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(252_165_165)_calc(var(--pmd-scheme-dark,1)*100%),rgb(185_28_28))]',
19
+ info: 'bg-linear-to-r from-sky-500/10 to-sky-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(56_189_248/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(2_132_199/0.2))] text-[color:color-mix(in_oklab,rgb(240_249_255)_calc(var(--pmd-scheme-dark,1)*100%),rgb(8_47_73))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(125_211_252)_calc(var(--pmd-scheme-dark,1)*100%),rgb(3_105_161))]',
20
+ note: 'bg-linear-to-r from-slate-500/10 to-slate-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(148_163_184/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(100_116_139/0.2))] text-[color:color-mix(in_oklab,rgb(248_250_252)_calc(var(--pmd-scheme-dark,1)*100%),rgb(15_23_42))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(203_213_225)_calc(var(--pmd-scheme-dark,1)*100%),rgb(71_85_105))]',
21
+ success: 'bg-linear-to-r from-emerald-500/10 to-emerald-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(52_211_153/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(5_150_105/0.2))] text-[color:color-mix(in_oklab,rgb(236_253_245)_calc(var(--pmd-scheme-dark,1)*100%),rgb(2_44_34))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(110_231_183)_calc(var(--pmd-scheme-dark,1)*100%),rgb(4_120_87))]',
22
+ tip: 'bg-linear-to-r from-violet-500/10 to-violet-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(167_139_250/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(124_58_237/0.2))] text-[color:color-mix(in_oklab,rgb(245_243_255)_calc(var(--pmd-scheme-dark,1)*100%),rgb(46_16_101))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(196_181_253)_calc(var(--pmd-scheme-dark,1)*100%),rgb(109_40_217))]',
23
+ warning: 'bg-linear-to-r from-amber-500/10 to-amber-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(251_191_36/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(217_119_6/0.2))] text-[color:color-mix(in_oklab,rgb(255_251_235)_calc(var(--pmd-scheme-dark,1)*100%),rgb(69_26_3))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(252_211_77)_calc(var(--pmd-scheme-dark,1)*100%),rgb(146_64_14))]'
19
24
  };
20
25
  function isCalloutVariant(value) {
21
26
  return typeof value === 'string' && CALLOUT_VARIANTS.includes(value);
@@ -41,8 +46,10 @@ export const calloutDirective = {
41
46
  const icon = typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined;
42
47
  const theme = resolveDirectiveTheme('callout', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : 'soft', config.themes);
43
48
  const children = node.children;
49
+ // An icon without a title sits beside the body instead of on its own row.
50
+ const iconBesideBody = Boolean(icon && !title);
44
51
  node.properties.dataTheme = theme.name;
45
- node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes, calloutVariantClasses[isCalloutVariant(variant) ? variant : 'note']);
52
+ node.properties.className = mergeClassNames(iconBesideBody ? 'flex items-start gap-3' : undefined, theme.hookClassName, theme.modifierClassName, theme.classes, calloutVariantClasses[isCalloutVariant(variant) ? variant : 'note']);
46
53
  node.children = [
47
54
  ...title || icon ? [
48
55
  {
@@ -50,7 +57,8 @@ export const calloutDirective = {
50
57
  children: [
51
58
  ...icon ? [
52
59
  makeDirectiveIconPlaceholder(icon, [
53
- 'pmd-callout__icon inline-flex size-4 shrink-0 text-current'
60
+ 'pmd-callout__icon inline-flex size-4 shrink-0 text-current',
61
+ iconBesideBody ? 'mt-1.5' : 'mt-0.5'
54
62
  ])
55
63
  ] : [],
56
64
  ...title ? [
@@ -62,7 +70,7 @@ export const calloutDirective = {
62
70
  ],
63
71
  properties: {
64
72
  className: [
65
- 'mb-2 flex items-center gap-2 text-sm font-semibold tracking-wide'
73
+ iconBesideBody ? 'not-prose flex shrink-0' : 'not-prose mb-2 flex items-start gap-2 text-sm font-semibold tracking-wide'
66
74
  ],
67
75
  dataDirectiveTitle: 'callout'
68
76
  },
@@ -74,8 +82,9 @@ export const calloutDirective = {
74
82
  children,
75
83
  properties: {
76
84
  className: [
77
- 'space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0'
78
- ],
85
+ DIRECTIVE_BODY_CLASS,
86
+ iconBesideBody ? 'min-w-0 flex-1' : ''
87
+ ].filter(Boolean),
79
88
  dataDirectiveBody: 'callout'
80
89
  },
81
90
  tagName: 'div'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/directives/definitions/callout.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js'\nimport { getDirectiveLabelOrAttribute } from '../labels.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const CALLOUT_VARIANTS = [\n 'note',\n 'info',\n 'tip',\n 'warning',\n 'danger',\n 'success',\n] as const\n\nexport type CalloutVariant = (typeof CALLOUT_VARIANTS)[number]\n\nconst calloutVariantClasses: Record<CalloutVariant, string> = {\n danger: 'bg-red-500/10 text-red-50',\n info: 'bg-sky-500/10 text-sky-50',\n note: 'bg-slate-500/10 text-slate-50',\n success: 'bg-emerald-500/10 text-emerald-50',\n tip: 'bg-cyan-500/10 text-cyan-50',\n warning: 'bg-amber-500/10 text-amber-50',\n}\n\nfunction isCalloutVariant(value: unknown): value is CalloutVariant {\n return typeof value === 'string' && CALLOUT_VARIANTS.includes(value as CalloutVariant)\n}\n\nexport function resolveCalloutVariant(node: ContainerDirective): CalloutVariant {\n const variant = node.attributes?.variant\n\n return isCalloutVariant(variant) ? variant : 'note'\n}\n\nfunction getTitle(node: ContainerDirective): string | undefined {\n return getDirectiveLabelOrAttribute(node, 'title')\n}\n\nexport const calloutDirective: LayoutDirectiveDefinition = {\n name: 'callout',\n allowedAttributes: ['icon', 'theme', 'title', 'variant'],\n applyHast(node, config, { mergeClassNames }) {\n const variant = typeof node.properties.dataVariant === 'string' ? node.properties.dataVariant : 'note'\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined\n const icon = typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined\n const theme = resolveDirectiveTheme(\n 'callout',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : 'soft',\n config.themes,\n )\n const children = node.children\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n 'not-prose',\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n calloutVariantClasses[isCalloutVariant(variant) ? variant : 'note'],\n )\n\n node.children = [\n ...(title || icon\n ? [\n {\n type: 'element' as const,\n children: [\n ...(icon\n ? [\n makeDirectiveIconPlaceholder(icon, [\n 'pmd-callout__icon inline-flex size-4 shrink-0 text-current',\n ]),\n ]\n : []),\n ...(title ? [{ type: 'text' as const, value: title }] : []),\n ],\n properties: {\n className: ['mb-2 flex items-center gap-2 text-sm font-semibold tracking-wide'],\n dataDirectiveTitle: 'callout',\n },\n tagName: 'div',\n },\n ]\n : []),\n {\n type: 'element',\n children,\n properties: {\n className: ['space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0'],\n dataDirectiveBody: 'callout',\n },\n tagName: 'div',\n },\n ]\n },\n defaultAttributes: {\n variant: 'note',\n },\n description: 'Emphasized content block with note, info, tip, warning, danger, or success variants.',\n editor: {\n detail: 'Static directive',\n label: 'Callout',\n snippet: ':::callout[${Title}]{\\n variant=\"${note}\"\\n}\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'callout',\n dataIcon: typeof node.attributes?.icon === 'string' ? node.attributes.icon : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'soft',\n dataTitle: getTitle(node),\n dataVariant: resolveCalloutVariant(node),\n }\n },\n kind: 'callout',\n openMarker: ':::callout',\n public: true,\n supportsAttributes: true,\n tagName: 'div',\n themeAttributes: {\n theme: 'callout',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = []\n\n if (typeof attributes.variant === 'string' && !isCalloutVariant(attributes.variant))\n warnings.push(\n `Unsupported callout variant \"${attributes.variant}\". Falling back to \"note\".`,\n )\n\n return warnings\n },\n}\n"],"names":["makeDirectiveIconPlaceholder","getDirectiveLabelOrAttribute","resolveDirectiveTheme","CALLOUT_VARIANTS","calloutVariantClasses","danger","info","note","success","tip","warning","isCalloutVariant","value","includes","resolveCalloutVariant","node","variant","attributes","getTitle","calloutDirective","name","allowedAttributes","applyHast","config","mergeClassNames","properties","dataVariant","title","dataTitle","undefined","icon","dataIcon","theme","dataTheme","themes","children","className","hookClassName","modifierClassName","classes","type","dataDirectiveTitle","tagName","dataDirectiveBody","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings","push"],"mappings":"AAIA,SAASA,4BAA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AASC,IAAI,CACX,CAAC,6BAA6B,EAAE1C,WAAWD,OAAO,CAAC,0BAA0B,CAAC;QAGlF,OAAO0C;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/directives/definitions/callout.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js'\nimport { getDirectiveLabelOrAttribute } from '../labels.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const CALLOUT_VARIANTS = [\n 'note',\n 'info',\n 'tip',\n 'warning',\n 'danger',\n 'success',\n] as const\n\nexport type CalloutVariant = (typeof CALLOUT_VARIANTS)[number]\n\n// The tint is a background-image so it layers over the theme's background\n// color instead of competing with it, and the ring composes with the theme's\n// shadow. Text, title and ring colours follow the colour scheme through\n// `--pmd-scheme-dark` (see styles/directiveSurface.ts).\nconst calloutVariantClasses: Record<CalloutVariant, string> = {\n danger:\n 'bg-linear-to-r from-red-500/10 to-red-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(248_113_113/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(220_38_38/0.2))] text-[color:color-mix(in_oklab,rgb(254_242_242)_calc(var(--pmd-scheme-dark,1)*100%),rgb(69_10_10))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(252_165_165)_calc(var(--pmd-scheme-dark,1)*100%),rgb(185_28_28))]',\n info:\n 'bg-linear-to-r from-sky-500/10 to-sky-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(56_189_248/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(2_132_199/0.2))] text-[color:color-mix(in_oklab,rgb(240_249_255)_calc(var(--pmd-scheme-dark,1)*100%),rgb(8_47_73))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(125_211_252)_calc(var(--pmd-scheme-dark,1)*100%),rgb(3_105_161))]',\n note:\n 'bg-linear-to-r from-slate-500/10 to-slate-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(148_163_184/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(100_116_139/0.2))] text-[color:color-mix(in_oklab,rgb(248_250_252)_calc(var(--pmd-scheme-dark,1)*100%),rgb(15_23_42))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(203_213_225)_calc(var(--pmd-scheme-dark,1)*100%),rgb(71_85_105))]',\n success:\n 'bg-linear-to-r from-emerald-500/10 to-emerald-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(52_211_153/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(5_150_105/0.2))] text-[color:color-mix(in_oklab,rgb(236_253_245)_calc(var(--pmd-scheme-dark,1)*100%),rgb(2_44_34))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(110_231_183)_calc(var(--pmd-scheme-dark,1)*100%),rgb(4_120_87))]',\n tip:\n 'bg-linear-to-r from-violet-500/10 to-violet-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(167_139_250/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(124_58_237/0.2))] text-[color:color-mix(in_oklab,rgb(245_243_255)_calc(var(--pmd-scheme-dark,1)*100%),rgb(46_16_101))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(196_181_253)_calc(var(--pmd-scheme-dark,1)*100%),rgb(109_40_217))]',\n warning:\n 'bg-linear-to-r from-amber-500/10 to-amber-500/10 inset-ring inset-ring-[color:color-mix(in_oklab,rgb(251_191_36/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(217_119_6/0.2))] text-[color:color-mix(in_oklab,rgb(255_251_235)_calc(var(--pmd-scheme-dark,1)*100%),rgb(69_26_3))] [&>[data-directive-title]]:text-[color:color-mix(in_oklab,rgb(252_211_77)_calc(var(--pmd-scheme-dark,1)*100%),rgb(146_64_14))]',\n}\n\nfunction isCalloutVariant(value: unknown): value is CalloutVariant {\n return typeof value === 'string' && CALLOUT_VARIANTS.includes(value as CalloutVariant)\n}\n\nexport function resolveCalloutVariant(node: ContainerDirective): CalloutVariant {\n const variant = node.attributes?.variant\n\n return isCalloutVariant(variant) ? variant : 'note'\n}\n\nfunction getTitle(node: ContainerDirective): string | undefined {\n return getDirectiveLabelOrAttribute(node, 'title')\n}\n\nexport const calloutDirective: LayoutDirectiveDefinition = {\n name: 'callout',\n allowedAttributes: ['icon', 'theme', 'title', 'variant'],\n applyHast(node, config, { mergeClassNames }) {\n const variant = typeof node.properties.dataVariant === 'string' ? node.properties.dataVariant : 'note'\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined\n const icon = typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined\n const theme = resolveDirectiveTheme(\n 'callout',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : 'soft',\n config.themes,\n )\n const children = node.children\n // An icon without a title sits beside the body instead of on its own row.\n const iconBesideBody = Boolean(icon && !title)\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n iconBesideBody ? 'flex items-start gap-3' : undefined,\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n calloutVariantClasses[isCalloutVariant(variant) ? variant : 'note'],\n )\n\n node.children = [\n ...(title || icon\n ? [\n {\n type: 'element' as const,\n children: [\n ...(icon\n ? [\n makeDirectiveIconPlaceholder(icon, [\n 'pmd-callout__icon inline-flex size-4 shrink-0 text-current',\n iconBesideBody ? 'mt-1.5' : 'mt-0.5',\n ]),\n ]\n : []),\n ...(title ? [{ type: 'text' as const, value: title }] : []),\n ],\n properties: {\n className: [\n iconBesideBody\n ? 'not-prose flex shrink-0'\n : 'not-prose mb-2 flex items-start gap-2 text-sm font-semibold tracking-wide',\n ],\n dataDirectiveTitle: 'callout',\n },\n tagName: 'div',\n },\n ]\n : []),\n {\n type: 'element',\n children,\n properties: {\n className: [DIRECTIVE_BODY_CLASS, iconBesideBody ? 'min-w-0 flex-1' : ''].filter(Boolean),\n dataDirectiveBody: 'callout',\n },\n tagName: 'div',\n },\n ]\n },\n defaultAttributes: {\n variant: 'note',\n },\n description: 'Emphasized content block with note, info, tip, warning, danger, or success variants.',\n editor: {\n detail: 'Static directive',\n label: 'Callout',\n snippet: ':::callout[${Title}]{\\n variant=\"${note}\"\\n}\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'callout',\n dataIcon: typeof node.attributes?.icon === 'string' ? node.attributes.icon : undefined,\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'soft',\n dataTitle: getTitle(node),\n dataVariant: resolveCalloutVariant(node),\n }\n },\n kind: 'callout',\n openMarker: ':::callout',\n public: true,\n supportsAttributes: true,\n tagName: 'div',\n themeAttributes: {\n theme: 'callout',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = []\n\n if (typeof attributes.variant === 'string' && !isCalloutVariant(attributes.variant))\n warnings.push(\n `Unsupported callout variant \"${attributes.variant}\". Falling back to \"note\".`,\n )\n\n return warnings\n },\n}\n"],"names":["DIRECTIVE_BODY_CLASS","makeDirectiveIconPlaceholder","getDirectiveLabelOrAttribute","resolveDirectiveTheme","CALLOUT_VARIANTS","calloutVariantClasses","danger","info","note","success","tip","warning","isCalloutVariant","value","includes","resolveCalloutVariant","node","variant","attributes","getTitle","calloutDirective","name","allowedAttributes","applyHast","config","mergeClassNames","properties","dataVariant","title","dataTitle","undefined","icon","dataIcon","theme","dataTheme","themes","children","iconBesideBody","Boolean","className","hookClassName","modifierClassName","classes","type","dataDirectiveTitle","tagName","filter","dataDirectiveBody","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings","push"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,4BAA4B,QAAQ,wBAAuB;AACpE,SAASC,4BAA4B,Q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;QACf3B,OAAO;IACT;IACA4B,oBAAmB,EAAE3C,UAAU,EAAE;QAC/B,MAAM4C,WAAqB,EAAE;QAE7B,IAAI,OAAO5C,WAAWD,OAAO,KAAK,YAAY,CAACL,iBAAiBM,WAAWD,OAAO,GAChF6C,SAASC,IAAI,CACX,CAAC,6BAA6B,EAAE7C,WAAWD,OAAO,CAAC,0BAA0B,CAAC;QAGlF,OAAO6C;IACT;AACF,EAAC"}
@@ -1,8 +1,10 @@
1
1
  import type { LayoutDirectiveDefinition } from '../types.js';
2
- export declare const CARD_BODY_CLASS_NAMES = "space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0";
3
- export declare const CARD_TITLE_CLASS_NAMES = "mb-3 text-lg font-semibold tracking-tight";
2
+ export declare const CARD_BODY_CLASS_NAMES: string;
3
+ export declare const CARD_TITLE_CLASS_NAMES = "not-prose mb-3 text-lg font-semibold tracking-tight text-(--tw-prose-headings)";
4
4
  export declare const CARD_LINK_SCOPES: readonly ["full", "title"];
5
5
  export declare const DEFAULT_CARD_LINK_SCOPE = "full";
6
6
  export type CardLinkScope = (typeof CARD_LINK_SCOPES)[number];
7
7
  export declare function isCardLinkScope(value: unknown): value is CardLinkScope;
8
+ /** `icon` takes one icon ref or a comma-separated list (`@fa/debian, @fa/ubuntu`). */
9
+ export declare function parseCardIcons(value: string | undefined): string[];
8
10
  export declare const cardDirective: LayoutDirectiveDefinition;
@@ -1,9 +1,11 @@
1
+ import { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js';
1
2
  import { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js';
2
3
  import { getDirectiveLabelOrAttribute } from '../labels.js';
3
4
  import { resolveDirectiveTheme } from '../themes.js';
4
5
  import { getSafeHref, getUnsafeHrefWarnings } from '../urls.js';
5
- export const CARD_BODY_CLASS_NAMES = 'space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0';
6
- export const CARD_TITLE_CLASS_NAMES = 'mb-3 text-lg font-semibold tracking-tight';
6
+ export const CARD_BODY_CLASS_NAMES = DIRECTIVE_BODY_CLASS;
7
+ export const CARD_TITLE_CLASS_NAMES = 'not-prose mb-3 text-lg font-semibold tracking-tight text-(--tw-prose-headings)';
8
+ const CARD_TITLE_LINK_CLASS_NAMES = 'rounded-sm transition-colors hover:text-[color:var(--pmd-accent-hover,color-mix(in_oklab,#67e8f9_calc(var(--pmd-scheme-dark,1)*100%),#155e75))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--pmd-accent,color-mix(in_oklab,#22d3ee_calc(var(--pmd-scheme-dark,1)*100%),#0e7490))]';
7
9
  export const CARD_LINK_SCOPES = [
8
10
  'full',
9
11
  'title'
@@ -50,7 +52,12 @@ function makeTitle(title, href, newTab = false) {
50
52
  value: title
51
53
  }
52
54
  ],
53
- properties: getLinkProperties(href, newTab),
55
+ properties: {
56
+ ...getLinkProperties(href, newTab),
57
+ className: [
58
+ CARD_TITLE_LINK_CLASS_NAMES
59
+ ]
60
+ },
54
61
  tagName: 'a'
55
62
  }
56
63
  ] : [
@@ -79,13 +86,34 @@ function makeFullCardLink(href, title, newTab) {
79
86
  ...getLinkProperties(href, newTab),
80
87
  ariaLabel: title ? `Open ${title}` : 'Open card',
81
88
  className: [
82
- 'absolute inset-0 z-10 rounded-[inherit] focus:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300'
89
+ 'not-prose absolute inset-0 z-10 rounded-[inherit] focus:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--pmd-accent,color-mix(in_oklab,#22d3ee_calc(var(--pmd-scheme-dark,1)*100%),#0e7490))]'
83
90
  ],
84
91
  dataDirectiveLink: 'card'
85
92
  },
86
93
  tagName: 'a'
87
94
  };
88
95
  }
96
+ /** `icon` takes one icon ref or a comma-separated list (`@fa/debian, @fa/ubuntu`). */ export function parseCardIcons(value) {
97
+ return value?.split(',').map((icon)=>icon.trim()).filter(Boolean) ?? [];
98
+ }
99
+ function makeIcons(icons, hasEyebrow) {
100
+ return {
101
+ type: 'element',
102
+ children: icons.map((icon)=>makeDirectiveIconPlaceholder(icon, [
103
+ 'pmd-card__icon inline-flex size-5 text-current'
104
+ ])),
105
+ properties: {
106
+ className: [
107
+ 'not-prose pmd-card__icons mb-3 flex flex-wrap items-center gap-2',
108
+ // Clear of the eyebrow; its mb-2 collapses into this margin.
109
+ ...hasEyebrow ? [
110
+ 'mt-4'
111
+ ] : []
112
+ ]
113
+ },
114
+ tagName: 'div'
115
+ };
116
+ }
89
117
  function makeEyebrow(eyebrow) {
90
118
  return {
91
119
  type: 'element',
@@ -96,8 +124,10 @@ function makeEyebrow(eyebrow) {
96
124
  }
97
125
  ],
98
126
  properties: {
127
+ // Muted relative to the body text rather than a fixed grey, so small
128
+ // uppercase labels keep AA contrast on tinted or custom surfaces.
99
129
  className: [
100
- 'mb-2 text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground'
130
+ 'not-prose mb-2 text-xs font-semibold uppercase tracking-[0.18em] text-(--tw-prose-body)/80'
101
131
  ],
102
132
  dataDirectiveEyebrow: 'card'
103
133
  },
@@ -123,7 +153,7 @@ export const cardDirective = {
123
153
  const linkScope = typeof node.properties.dataLinkScope === 'string' && isCardLinkScope(node.properties.dataLinkScope) ? node.properties.dataLinkScope : DEFAULT_CARD_LINK_SCOPE;
124
154
  const newTab = node.properties.dataNewTab === 'true';
125
155
  const eyebrow = typeof node.properties.dataEyebrow === 'string' ? node.properties.dataEyebrow : undefined;
126
- const icon = typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined;
156
+ const icons = parseCardIcons(typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined);
127
157
  const theme = resolveDirectiveTheme('card', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
128
158
  const children = node.children;
129
159
  node.properties.dataTheme = theme.name;
@@ -131,7 +161,7 @@ export const cardDirective = {
131
161
  node.properties.dataLinkScope = linkScope;
132
162
  node.properties.dataNewTab = newTab ? 'true' : 'false';
133
163
  }
134
- node.properties.className = mergeClassNames('not-prose', href && linkScope === 'full' ? 'relative cursor-pointer [&_a:not([data-directive-link])]:relative [&_a:not([data-directive-link])]:z-20' : undefined, theme.hookClassName, theme.modifierClassName, theme.classes);
164
+ node.properties.className = mergeClassNames('my-6', href && linkScope === 'full' ? 'relative cursor-pointer transition-colors hover:border-[color:color-mix(in_oklab,rgb(255_255_255/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.2))] [&>[data-directive-title]]:transition-colors hover:[&>[data-directive-title]]:text-[color:var(--pmd-accent-hover,color-mix(in_oklab,#67e8f9_calc(var(--pmd-scheme-dark,1)*100%),#155e75))] [&_a:not([data-directive-link])]:relative [&_a:not([data-directive-link])]:z-20' : undefined, theme.hookClassName, theme.modifierClassName, theme.classes);
135
165
  node.children = [
136
166
  ...href && linkScope === 'full' ? [
137
167
  makeFullCardLink(href, title, newTab)
@@ -139,10 +169,8 @@ export const cardDirective = {
139
169
  ...eyebrow ? [
140
170
  makeEyebrow(eyebrow)
141
171
  ] : [],
142
- ...icon ? [
143
- makeDirectiveIconPlaceholder(icon, [
144
- 'pmd-card__icon mb-3 inline-flex size-5 text-current'
145
- ])
172
+ ...icons.length > 0 ? [
173
+ makeIcons(icons, Boolean(eyebrow))
146
174
  ] : [],
147
175
  ...title ? [
148
176
  makeTitle(title, href && linkScope === 'title' ? href : undefined, newTab)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/directives/definitions/card.ts"],"sourcesContent":["import type { Element, ElementContent } from 'hast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js'\nimport { getDirectiveLabelOrAttribute } from '../labels.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { getSafeHref, getUnsafeHrefWarnings } from '../urls.js'\n\nexport const CARD_BODY_CLASS_NAMES = 'space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0'\nexport const CARD_TITLE_CLASS_NAMES = 'mb-3 text-lg font-semibold tracking-tight'\nexport const CARD_LINK_SCOPES = ['full', 'title'] as const\nexport const DEFAULT_CARD_LINK_SCOPE = 'full'\n\nexport type CardLinkScope = (typeof CARD_LINK_SCOPES)[number]\n\nexport function isCardLinkScope(value: unknown): value is CardLinkScope {\n return typeof value === 'string' && CARD_LINK_SCOPES.includes(value as CardLinkScope)\n}\n\nfunction getAttribute(node: ContainerDirective, name: string): string | undefined {\n const value = node.attributes?.[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nfunction getBooleanAttribute(node: ContainerDirective, name: string): boolean {\n const attributes = node.attributes as\n | null\n | Record<string, boolean | null | string | undefined>\n | undefined\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 getLinkScope(node: ContainerDirective): CardLinkScope | undefined {\n const value = node.attributes?.linkScope\n\n if (typeof value !== 'string') return undefined\n\n return isCardLinkScope(value) ? value : DEFAULT_CARD_LINK_SCOPE\n}\n\nfunction getLinkProperties(href: string, newTab: boolean): Element['properties'] {\n return {\n href,\n ...(newTab\n ? {\n rel: ['noopener', 'noreferrer'],\n target: '_blank',\n }\n : {}),\n }\n}\n\nfunction makeTitle(title: string, href?: string, newTab = false): Element {\n const children: ElementContent[] = href\n ? [\n {\n type: 'element',\n children: [{ type: 'text', value: title }],\n properties: getLinkProperties(href, newTab),\n tagName: 'a',\n },\n ]\n : [{ type: 'text', value: title }]\n\n return {\n type: 'element',\n children,\n properties: {\n className: [CARD_TITLE_CLASS_NAMES],\n dataDirectiveTitle: 'card',\n },\n tagName: 'h3',\n }\n}\n\nfunction makeFullCardLink(href: string, title: string | undefined, newTab: boolean): Element {\n return {\n type: 'element',\n children: [],\n properties: {\n ...getLinkProperties(href, newTab),\n ariaLabel: title ? `Open ${title}` : 'Open card',\n className: [\n 'absolute inset-0 z-10 rounded-[inherit] focus:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300',\n ],\n dataDirectiveLink: 'card',\n },\n tagName: 'a',\n }\n}\n\nfunction makeEyebrow(eyebrow: string): Element {\n return {\n type: 'element',\n children: [{ type: 'text', value: eyebrow }],\n properties: {\n className: ['mb-2 text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground'],\n dataDirectiveEyebrow: 'card',\n },\n tagName: 'p',\n }\n}\n\nexport const cardDirective: LayoutDirectiveDefinition = {\n name: 'card',\n allowedAttributes: ['eyebrow', 'href', 'icon', 'linkScope', 'newTab', 'theme', 'title'],\n applyHast(node, config, { mergeClassNames }) {\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined\n // Re-validate at the hast stage: this is where the live <a href> is built.\n const href = getSafeHref(node.properties.dataHref)\n if (!href) delete node.properties.dataHref\n const linkScope =\n typeof node.properties.dataLinkScope === 'string' && isCardLinkScope(node.properties.dataLinkScope)\n ? node.properties.dataLinkScope\n : DEFAULT_CARD_LINK_SCOPE\n const newTab = node.properties.dataNewTab === 'true'\n const eyebrow =\n typeof node.properties.dataEyebrow === 'string' ? node.properties.dataEyebrow : undefined\n const icon = typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined\n const theme = resolveDirectiveTheme(\n 'card',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const children = node.children\n\n node.properties.dataTheme = theme.name\n if (href) {\n node.properties.dataLinkScope = linkScope\n node.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n node.properties.className = mergeClassNames(\n 'not-prose',\n href && linkScope === 'full' ? 'relative cursor-pointer [&_a:not([data-directive-link])]:relative [&_a:not([data-directive-link])]:z-20' : undefined,\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n )\n node.children = [\n ...(href && linkScope === 'full' ? [makeFullCardLink(href, title, newTab)] : []),\n ...(eyebrow ? [makeEyebrow(eyebrow)] : []),\n ...(icon\n ? [\n makeDirectiveIconPlaceholder(icon, [\n 'pmd-card__icon mb-3 inline-flex size-5 text-current',\n ]),\n ]\n : []),\n ...(title ? [makeTitle(title, href && linkScope === 'title' ? href : undefined, newTab)] : []),\n {\n type: 'element',\n children,\n properties: {\n className: [CARD_BODY_CLASS_NAMES],\n dataDirectiveBody: 'card',\n },\n tagName: 'div',\n },\n ]\n },\n attributeValues: {\n linkScope: CARD_LINK_SCOPES,\n newTab: ['true', 'false'],\n },\n defaultAttributes: {\n linkScope: DEFAULT_CARD_LINK_SCOPE,\n newTab: 'false',\n },\n description: 'Card content block with optional title, eyebrow, and card link.',\n editor: {\n detail: 'Layout directive',\n label: 'Card',\n snippet: ':::card[${Title}]\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'card',\n dataEyebrow: getAttribute(node, 'eyebrow'),\n dataHref: getSafeHref(getAttribute(node, 'href')),\n dataIcon: getAttribute(node, 'icon'),\n dataLinkScope: getLinkScope(node),\n dataNewTab: 'newTab' in (node.attributes ?? {})\n ? getBooleanAttribute(node, 'newTab') ? 'true' : 'false'\n : undefined,\n dataTheme: getAttribute(node, 'theme'),\n dataTitle: getDirectiveLabelOrAttribute(node, 'title'),\n }\n },\n kind: 'card',\n openMarker: ':::card',\n public: true,\n supportsAttributes: true,\n tagName: 'article',\n themeAttributes: {\n theme: 'card',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = [...getUnsafeHrefWarnings('card', attributes)]\n\n if (typeof attributes.linkScope === 'string' && !isCardLinkScope(attributes.linkScope))\n warnings.push(\n `Invalid card linkScope \"${attributes.linkScope}\". Falling back to \"${DEFAULT_CARD_LINK_SCOPE}\".`,\n )\n\n return warnings\n },\n}\n"],"names":["makeDirectiveIconPlaceholder","getDirectiveLabelOrAttribute","resolveDirectiveTheme","getSafeHref","getUnsafeHrefWarnings","CARD_BODY_CLASS_NAMES","CARD_TITLE_CLASS_NAMES","CARD_LINK_SCOPES","DEFAULT_CARD_LINK_SCOPE","isCardLinkScope","value","includes","getAttribute","node","name","attributes","trim","undefined","getBooleanAttribute","getLinkScope","linkScope","getLinkProperties","href","newTab","rel","target","makeTitle","title","children","type","properties","tagName","className","dataDirectiveTitle","makeFullCardLink","ariaLabel","dataDirectiveLink","makeEyebrow","eyebrow","dataDirectiveEyebrow","cardDirective","allowedAttributes","applyHast","config","mergeClassNames","dataTitle","dataHref","dataLinkScope","dataNewTab","dataEyebrow","icon","dataIcon","theme","dataTheme","themes","hookClassName","modifierClassName","classes","dataDirectiveBody","attributeValues","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings","push"],"mappings":"AAKA,SAASA,4BAA4B,QAAQ,wBAAuB;AACpE,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,aAAY;AAE/D,OAAO,MAAMC,wBAAwB,uDAAsD;AAC3F,OAAO,MAAMC,yBAAyB,4CAA2C;AACjF,OAAO,MAAMC,mBAAmB;IAAC;IAAQ;CAAQ,CAAS;AAC1D,OAAO,MAAMC,0BAA0B,OAAM;AAI7C,OAAO,SAASC,gBAAgBC,KAAc;IAC5C,OAAO,OAAOA,UAAU,YAAYH,iBAAiBI,QAAQ,CAACD;AAChE;AAEA,SAASE,aAAaC,IAAwB,EAAEC,IAAY;IAC1D,MAAMJ,QAAQG,KAAKE,UAAU,EAAE,CAACD,KAAK;IAErC,OAAO,OAAOJ,UAAU,YAAYA,MAAMM,IAAI,KAAKN,MAAMM,IAAI,KAAKC;AACpE;AAEA,SAASC,oBAAoBL,IAAwB,EAAEC,IAAY;IACjE,MAAMC,aAAaF,KAAKE,UAAU;IAIlC,MAAML,QAAQK,YAAY,CAACD,KAAK;IAEhC,IAAIJ,UAAU,MAAM,OAAO;IAC3B,IAAI,OAAOA,UAAU,UAAU,OAAO;IAEtC,OAAOA,UAAU;AACnB;AAEA,SAASS,aAAaN,IAAw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CAACX,gBAAgBM,WAAWK,SAAS,GACnFsD,SAASC,IAAI,CACX,CAAC,wBAAwB,EAAE5D,WAAWK,SAAS,CAAC,oBAAoB,EAAEZ,wBAAwB,EAAE,CAAC;QAGrG,OAAOkE;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/directives/definitions/card.ts"],"sourcesContent":["import type { Element, ElementContent } from 'hast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { DIRECTIVE_BODY_CLASS } from '../../styles/directiveSurface.js'\nimport { makeDirectiveIconPlaceholder } from '../iconPlaceholder.js'\nimport { getDirectiveLabelOrAttribute } from '../labels.js'\nimport { resolveDirectiveTheme } from '../themes.js'\nimport { getSafeHref, getUnsafeHrefWarnings } from '../urls.js'\n\nexport const CARD_BODY_CLASS_NAMES = DIRECTIVE_BODY_CLASS\nexport const CARD_TITLE_CLASS_NAMES =\n 'not-prose mb-3 text-lg font-semibold tracking-tight text-(--tw-prose-headings)'\nconst CARD_TITLE_LINK_CLASS_NAMES =\n 'rounded-sm transition-colors hover:text-[color:var(--pmd-accent-hover,color-mix(in_oklab,#67e8f9_calc(var(--pmd-scheme-dark,1)*100%),#155e75))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--pmd-accent,color-mix(in_oklab,#22d3ee_calc(var(--pmd-scheme-dark,1)*100%),#0e7490))]'\nexport const CARD_LINK_SCOPES = ['full', 'title'] as const\nexport const DEFAULT_CARD_LINK_SCOPE = 'full'\n\nexport type CardLinkScope = (typeof CARD_LINK_SCOPES)[number]\n\nexport function isCardLinkScope(value: unknown): value is CardLinkScope {\n return typeof value === 'string' && CARD_LINK_SCOPES.includes(value as CardLinkScope)\n}\n\nfunction getAttribute(node: ContainerDirective, name: string): string | undefined {\n const value = node.attributes?.[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nfunction getBooleanAttribute(node: ContainerDirective, name: string): boolean {\n const attributes = node.attributes as\n | null\n | Record<string, boolean | null | string | undefined>\n | undefined\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 getLinkScope(node: ContainerDirective): CardLinkScope | undefined {\n const value = node.attributes?.linkScope\n\n if (typeof value !== 'string') return undefined\n\n return isCardLinkScope(value) ? value : DEFAULT_CARD_LINK_SCOPE\n}\n\nfunction getLinkProperties(href: string, newTab: boolean): Element['properties'] {\n return {\n href,\n ...(newTab\n ? {\n rel: ['noopener', 'noreferrer'],\n target: '_blank',\n }\n : {}),\n }\n}\n\nfunction makeTitle(title: string, href?: string, newTab = false): Element {\n const children: ElementContent[] = href\n ? [\n {\n type: 'element',\n children: [{ type: 'text', value: title }],\n properties: { ...getLinkProperties(href, newTab), className: [CARD_TITLE_LINK_CLASS_NAMES] },\n tagName: 'a',\n },\n ]\n : [{ type: 'text', value: title }]\n\n return {\n type: 'element',\n children,\n properties: {\n className: [CARD_TITLE_CLASS_NAMES],\n dataDirectiveTitle: 'card',\n },\n tagName: 'h3',\n }\n}\n\nfunction makeFullCardLink(href: string, title: string | undefined, newTab: boolean): Element {\n return {\n type: 'element',\n children: [],\n properties: {\n ...getLinkProperties(href, newTab),\n ariaLabel: title ? `Open ${title}` : 'Open card',\n className: [\n 'not-prose absolute inset-0 z-10 rounded-[inherit] focus:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--pmd-accent,color-mix(in_oklab,#22d3ee_calc(var(--pmd-scheme-dark,1)*100%),#0e7490))]',\n ],\n dataDirectiveLink: 'card',\n },\n tagName: 'a',\n }\n}\n\n/** `icon` takes one icon ref or a comma-separated list (`@fa/debian, @fa/ubuntu`). */\nexport function parseCardIcons(value: string | undefined): string[] {\n return value?.split(',').map((icon) => icon.trim()).filter(Boolean) ?? []\n}\n\nfunction makeIcons(icons: string[], hasEyebrow: boolean): Element {\n return {\n type: 'element',\n children: icons.map((icon) =>\n makeDirectiveIconPlaceholder(icon, ['pmd-card__icon inline-flex size-5 text-current']),\n ),\n properties: {\n className: [\n 'not-prose pmd-card__icons mb-3 flex flex-wrap items-center gap-2',\n // Clear of the eyebrow; its mb-2 collapses into this margin.\n ...(hasEyebrow ? ['mt-4'] : []),\n ],\n },\n tagName: 'div',\n }\n}\n\nfunction makeEyebrow(eyebrow: string): Element {\n return {\n type: 'element',\n children: [{ type: 'text', value: eyebrow }],\n properties: {\n // Muted relative to the body text rather than a fixed grey, so small\n // uppercase labels keep AA contrast on tinted or custom surfaces.\n className: ['not-prose mb-2 text-xs font-semibold uppercase tracking-[0.18em] text-(--tw-prose-body)/80'],\n dataDirectiveEyebrow: 'card',\n },\n tagName: 'p',\n }\n}\n\nexport const cardDirective: LayoutDirectiveDefinition = {\n name: 'card',\n allowedAttributes: ['eyebrow', 'href', 'icon', 'linkScope', 'newTab', 'theme', 'title'],\n applyHast(node, config, { mergeClassNames }) {\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined\n // Re-validate at the hast stage: this is where the live <a href> is built.\n const href = getSafeHref(node.properties.dataHref)\n if (!href) delete node.properties.dataHref\n const linkScope =\n typeof node.properties.dataLinkScope === 'string' && isCardLinkScope(node.properties.dataLinkScope)\n ? node.properties.dataLinkScope\n : DEFAULT_CARD_LINK_SCOPE\n const newTab = node.properties.dataNewTab === 'true'\n const eyebrow =\n typeof node.properties.dataEyebrow === 'string' ? node.properties.dataEyebrow : undefined\n const icons = parseCardIcons(\n typeof node.properties.dataIcon === 'string' ? node.properties.dataIcon : undefined,\n )\n const theme = resolveDirectiveTheme(\n 'card',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const children = node.children\n\n node.properties.dataTheme = theme.name\n if (href) {\n node.properties.dataLinkScope = linkScope\n node.properties.dataNewTab = newTab ? 'true' : 'false'\n }\n node.properties.className = mergeClassNames(\n 'my-6',\n href && linkScope === 'full'\n ? 'relative cursor-pointer transition-colors hover:border-[color:color-mix(in_oklab,rgb(255_255_255/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.2))] [&>[data-directive-title]]:transition-colors hover:[&>[data-directive-title]]:text-[color:var(--pmd-accent-hover,color-mix(in_oklab,#67e8f9_calc(var(--pmd-scheme-dark,1)*100%),#155e75))] [&_a:not([data-directive-link])]:relative [&_a:not([data-directive-link])]:z-20'\n : undefined,\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n )\n node.children = [\n ...(href && linkScope === 'full' ? [makeFullCardLink(href, title, newTab)] : []),\n ...(eyebrow ? [makeEyebrow(eyebrow)] : []),\n ...(icons.length > 0 ? [makeIcons(icons, Boolean(eyebrow))] : []),\n ...(title ? [makeTitle(title, href && linkScope === 'title' ? href : undefined, newTab)] : []),\n {\n type: 'element',\n children,\n properties: {\n className: [CARD_BODY_CLASS_NAMES],\n dataDirectiveBody: 'card',\n },\n tagName: 'div',\n },\n ]\n },\n attributeValues: {\n linkScope: CARD_LINK_SCOPES,\n newTab: ['true', 'false'],\n },\n defaultAttributes: {\n linkScope: DEFAULT_CARD_LINK_SCOPE,\n newTab: 'false',\n },\n description: 'Card content block with optional title, eyebrow, and card link.',\n editor: {\n detail: 'Layout directive',\n label: 'Card',\n snippet: ':::card[${Title}]\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'card',\n dataEyebrow: getAttribute(node, 'eyebrow'),\n dataHref: getSafeHref(getAttribute(node, 'href')),\n dataIcon: getAttribute(node, 'icon'),\n dataLinkScope: getLinkScope(node),\n dataNewTab: 'newTab' in (node.attributes ?? {})\n ? getBooleanAttribute(node, 'newTab') ? 'true' : 'false'\n : undefined,\n dataTheme: getAttribute(node, 'theme'),\n dataTitle: getDirectiveLabelOrAttribute(node, 'title'),\n }\n },\n kind: 'card',\n openMarker: ':::card',\n public: true,\n supportsAttributes: true,\n tagName: 'article',\n themeAttributes: {\n theme: 'card',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = [...getUnsafeHrefWarnings('card', attributes)]\n\n if (typeof attributes.linkScope === 'string' && !isCardLinkScope(attributes.linkScope))\n warnings.push(\n `Invalid card linkScope \"${attributes.linkScope}\". Falling back to \"${DEFAULT_CARD_LINK_SCOPE}\".`,\n )\n\n return warnings\n },\n}\n"],"names":["DIRECTIVE_BODY_CLASS","makeDirectiveIconPlaceholder","getDirectiveLabelOrAttribute","resolveDirectiveTheme","getSafeHref","getUnsafeHrefWarnings","CARD_BODY_CLASS_NAMES","CARD_TITLE_CLASS_NAMES","CARD_TITLE_LINK_CLASS_NAMES","CARD_LINK_SCOPES","DEFAULT_CARD_LINK_SCOPE","isCardLinkScope","value","includes","getAttribute","node","name","attributes","trim","undefined","getBooleanAttribute","getLinkScope","linkScope","getLinkProperties","href","newTab","rel","target","makeTitle","title","children","type","properties","className","tagName","dataDirectiveTitle","makeFullCardLink","ariaLabel","dataDirectiveLink","parseCardIcons","split","map","icon","filter","Boolean","makeIcons","icons","hasEyebrow","makeEyebrow","eyebrow","dataDirectiveEyebrow","cardDirective","allowedAttributes","applyHast","config","mergeClassNames","dataTitle","dataHref","dataLinkScope","dataNewTab","dataEyebrow","dataIcon","theme","dataTheme","themes","hookClassName","modifierClassName","classes","length","dataDirectiveBody","attributeValues","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings","push"],"mappings":"AAKA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,4BAA4B,QAAQ,wBAAuB;AACpE,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,aAAY;AAE/D,OAAO,MAAMC,wBAAwBN,qBAAoB;AACzD,OAAO,MAAMO,yBACX,iFAAgF;AAClF,MAAMC,8BACJ;AACF,OAAO,MAAMC,mBAAmB;IAAC;IAAQ;CAAQ,CAAS;AAC1D,OAAO,MAAMC,0BAA0B,OAAM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
@@ -16,12 +16,15 @@ export const CARDS_LINK_SCOPES = [
16
16
  ];
17
17
  export const DEFAULT_CARDS_LINK_SCOPE = 'section';
18
18
  export const FALLBACK_CARDS_LINK_SCOPE = 'card';
19
+ // Columns collapse on the grid's own width (not the viewport): up to N
20
+ // columns while each stays at least 14rem wide. The 2rem term covers the
21
+ // widest theme gap, so a theme's gap never costs a column that would fit.
19
22
  const cardGridColumnClasses = {
20
23
  '1': 'grid-cols-1',
21
- '2': 'grid-cols-1 md:grid-cols-2',
22
- '3': 'grid-cols-1 md:grid-cols-3',
23
- '4': 'grid-cols-1 sm:grid-cols-2 xl:grid-cols-4',
24
- auto: 'grid-cols-1 md:grid-cols-[repeat(auto-fit,minmax(16rem,1fr))]'
24
+ '2': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2rem)/2))),1fr))]',
25
+ '3': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_2*2rem)/3))),1fr))]',
26
+ '4': 'grid-cols-[repeat(auto-fill,minmax(min(100%,max(14rem,calc((100%_-_3*2rem)/4))),1fr))]',
27
+ auto: 'grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))]'
25
28
  };
26
29
  function isCardGridColumns(value) {
27
30
  return typeof value === 'string' && CARD_GRID_COLUMNS.includes(value);
@@ -68,7 +71,7 @@ function makeSectionLink(href, newTab) {
68
71
  ...getLinkProperties(href, newTab),
69
72
  ariaLabel: 'Open card section',
70
73
  className: [
71
- 'absolute inset-0 z-10 rounded-[inherit] focus:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300'
74
+ 'not-prose absolute -inset-2 z-10 rounded-3xl focus:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--pmd-accent,color-mix(in_oklab,#22d3ee_calc(var(--pmd-scheme-dark,1)*100%),#0e7490))]'
72
75
  ],
73
76
  dataDirectiveLink: 'cards'
74
77
  },
@@ -128,7 +131,8 @@ export const cardsDirective = {
128
131
  node.properties.dataLinkScope = linkScope;
129
132
  node.properties.dataNewTab = newTab ? 'true' : 'false';
130
133
  }
131
- node.properties.className = mergeClassNames('not-prose my-8 grid gap-4', href && linkScope === 'section' ? 'relative cursor-pointer [&_a:not([data-directive-link])]:relative [&_a:not([data-directive-link])]:z-20' : undefined, theme.hookClassName, theme.modifierClassName, theme.classes, cardGridColumnClasses[isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS]);
134
+ node.properties.className = mergeClassNames(// Spacing lives in the theme; the base only sets what every grid needs.
135
+ 'grid [&>article]:my-0', href && linkScope === 'section' ? 'relative cursor-pointer [&>article]:transition-colors hover:[&>article]:border-[color:color-mix(in_oklab,rgb(255_255_255/0.15)_calc(var(--pmd-scheme-dark,1)*100%),rgb(0_0_0/0.2))] [&_a:not([data-directive-link])]:relative [&_a:not([data-directive-link])]:z-20' : undefined, theme.hookClassName, theme.modifierClassName, theme.classes, cardGridColumnClasses[isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS]);
132
136
  if (href && linkScope === 'section') node.children = [
133
137
  makeSectionLink(href, newTab),
134
138
  ...node.children