* Render YAML frontmatter as a GitHub-style key-value table.
(data: Record<string, unknown>)
| 448 | * Render YAML frontmatter as a GitHub-style key-value table. |
| 449 | */ |
| 450 | function renderFrontmatterTable(data: Record<string, unknown>): string { |
| 451 | const entries = Object.entries(data) |
| 452 | if (entries.length === 0) return '' |
| 453 | |
| 454 | const rows = entries |
| 455 | .map(([key, value]) => { |
| 456 | const displayValue = |
| 457 | typeof value === 'object' && value !== null ? JSON.stringify(value) : String(value ?? '') |
| 458 | return `<tr><th>${escapeHtml(key)}</th><td>${escapeHtml(displayValue)}</td></tr>` |
| 459 | }) |
| 460 | .join('\n') |
| 461 | return `<table><thead><tr><th>Key</th><th>Value</th></tr></thead><tbody>\n${rows}\n</tbody></table>\n` |
| 462 | } |
| 463 | |
| 464 | // Extract and preserve allowed attributes from HTML heading tags |
| 465 | function extractHeadingAttrs(attrsString: string): string { |
no test coverage detected