/** Markdown-only document chrome and progressive reader controls. */ import { readFileSync } from 'node:fs'; import { READER_CONFIG } from './config.js'; import { READER_CSS } from './reader-styles.js'; import { schemeTokens } from './styles.js'; function embeddedFont(): string { // Sources live beside assets, compiled modules one directory below them. for (const base of ['./assets/', '../assets/']) { try { const font = readFileSync(new URL(`${base}nunito-sans-latin.woff2`, import.meta.url)); const license = readFileSync(new URL(`${base}OFL.txt`, import.meta.url), 'utf8'); return `/* ${license} */\n@font-face{font-family:"Nunito Sans";font-style:normal;font-weight:400 900;font-display:swap;src:url(data:font/woff2;base64,${font.toString('base64')}) format("woff2")}`; } catch { // A missing optional font must not prevent an artifact from opening. } } return ''; } const LIGHT = `${schemeTokens('light')} --bg:#eff0f6;--fg:#202334;--muted:#606579;--border:#d9dce7;--code-bg:#f6f6fb; --accent:${READER_CONFIG.accentLight};--reader-second:#6556b8;--reader-paper:#ffffff;--reader-on-accent:#ffffff;`; const DARK = `${schemeTokens('dark')} --bg:#14151e;--fg:#f5f3fa;--muted:#b5b5c8;--border:#383b4d;--code-bg:#252735; --accent:${READER_CONFIG.accent};--reader-second:#b9adff;--reader-paper:#1c1e2a;--reader-on-accent:#281725;`; export const READER_STYLES = ``; export const READER_ATTRIBUTES = `data-artifact-reader data-reader-theme="${READER_CONFIG.theme}" data-reader-size="normal"`; function escape(value: string): string { return value.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); } export function readerBody(title: string, bodyHtml: string, generatedIso: string, projectPath: string): string { const heading = /