Files
documentation/scripts/target-caption.mjs
T
jarvis-at-skic 1a2d16bc91
Build and publish Eldorado documentation / build (pull_request) Successful in 1m30s
docs: [verified] answer the six-month AI Architect assignment
2026-10-08 16:59:36 +00:00

17 lines
1.2 KiB
JavaScript

// Caption the retained optional target without changing its native topology.
// Text lives inside the SVG so standalone exports retain proposal/line semantics.
export function targetCaption(html) {
const roots = [...html.matchAll(/<svg\b[^>]*role="img"[^>]*>/g)];
if (roots.length !== 1) throw new Error('Target caption SVG contract drift');
const root = roots[0][0];
const match = /viewBox="([\d. -]+)"/.exec(root);
if (!match) throw new Error('Target caption requires viewBox');
const [x,y,w,h] = match[1].trim().split(/\s+/).map(Number);
const size = Math.min(26, w / 30);
const lines = ['Proposed optional target — not a six-month commitment',
'Solid: lifecycle · Dotted: execution / governance', 'Dashed: human-controlled contributions'];
const extra = size * 5;
const caption = `<g id="eldorado-target-caption" aria-label="Proposed target legend">${lines.map((line,i) => `<text x="${x+20}" y="${y+h+size*(1.2+i*1.3)}" font-family="Arial, sans-serif" font-size="${size}" style="font-size:${size}px!important" class="t-primary">${line}</text>`).join('')}</g>`;
return html.replace(root, root.replace(match[0], `viewBox="${x} ${y} ${w} ${h+extra}"`) + caption);
}