import { execFile } from 'node:child_process'; import fs from 'node:fs/promises'; import path from 'node:path'; import { promisify } from 'node:util'; import { inflateRawSync } from 'node:zlib'; const execFileAsync = promisify(execFile); function extractDocumentContent(markdown) { const titleMatch = markdown.match(/^#\s+.+\n+/m); const body = markdown .slice((titleMatch?.index ?? 0) + (titleMatch?.[0].length ?? 0)) .replace(/^\s*$/m, '') .replace(//gi, ' ') // markup, not document text // A figure prints its caption; the image path is markup. .replace(/^!\[([^\]]*)\]\([^)]*\)\s*$/gm, '$1') // List markers are drawn by the renderer, not stored as text: the browser // paints them from
    /