UNPKG

c9ai

Version:

Universal AI assistant with vibe-based workflows, hybrid cloud+local AI, and comprehensive tool integration

72 lines (65 loc) 2.76 kB
#!/usr/bin/env node "use strict"; // Convert a Markdown file into a Reveal.js slideshow HTML in public/slides/ // Usage: node scripts/md-to-slides.js --input docs/slides/c9ai-gamma-deck.md --output public/slides/c9ai.html --title "C9AI" --theme black const fs = require("node:fs"); const fsp = require("node:fs/promises"); const path = require("node:path"); function parseArgs(argv) { const out = { theme: process.env.SLIDES_THEME || "black" }; for (let i = 0; i < argv.length; i++) { const a = argv[i]; if (a === "--input" || a === "-i") out.input = argv[++i]; else if (a === "--output" || a === "-o") out.output = argv[++i]; else if (a === "--title" || a === "-t") out.title = argv[++i]; else if (a === "--theme") out.theme = argv[++i]; } return out; } function buildHtml({ title, markdown, theme }) { const escTitle = String(title || "Slides"); const md = String(markdown || ""); return `<!doctype html> <html> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/> <title>${escTitle}</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reveal.js@4/dist/reveal.css"/> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reveal.js@4/dist/theme/${theme}.css" id="theme"/> <style> .reveal h1,h2,h3 { text-transform: none; } </style> </head> <body> <div class="reveal"> <div class="slides"> <section data-markdown> <textarea data-template>${md.replace(/<\/textarea>/g, "</texarea>")}</textarea> </section> </div> </div> <script src="https://cdn.jsdelivr.net/npm/reveal.js@4/dist/reveal.js"></script> <script src="https://cdn.jsdelivr.net/npm/reveal.js@4/plugin/markdown/markdown.js"></script> <script> const deck = new Reveal({ hash: true, plugins: [ RevealMarkdown ] }); deck.initialize(); </script> </body> </html>`; } (async () => { const args = parseArgs(process.argv.slice(2)); if (!args.input) { console.error("Usage: node scripts/md-to-slides.js --input <file.md> [--output public/slides/out.html] [--title 'Title'] [--theme black|white|beige|...]"); process.exit(1); } const inputPath = path.resolve(args.input); const md = await fsp.readFile(inputPath, "utf8"); const title = args.title || path.basename(inputPath).replace(/\.[^.]+$/, ""); const outFile = path.resolve(args.output || path.join(process.cwd(), "public", "slides", `${title}.html`)); await fsp.mkdir(path.dirname(outFile), { recursive: true }); const html = buildHtml({ title, markdown: md, theme: args.theme }); await fsp.writeFile(outFile, html, "utf8"); console.log(`✅ Slides generated: ${outFile}`); })();