]*>([\s\S]*?)<\/p>/g, (_, t) => `\n\n${t.trim().replace(/\s*\n\s*/g, ' ')}\n\n`) + .replace(new RegExp(`?${ELEMENT}\\b[^>]*?/?>`, 'g'), '\n') + .replace(/ /g, ' ') + .replace(/&/g, '&') + .replace(/[ \t]+$/gm, '') + // Indentation survives only on nested list items; anywhere else four + // spaces would turn a line into a code block. + .replace(/^[ \t]+(?=\S)/gm, (ws, off, all) => (/^[ \t]+(?:[-*+]|\d+\.)\s/.test(all.slice(off, off + ws.length + 4)) ? ws : '')) + .replace(/\n{3,}/g, '\n\n') + .trim() + src = src.replace(/\u0000(\d+)\u0000/g, (_, i) => kept[+i]) + if (title && !/^# /.test(src)) src = `# ${title}\n\n${src}` + return src + '\n' +} + +const full = ['# zig-nostr, every page\n', 'The whole site as Markdown, in navigation order. Each page is also served on its own at its path with `.md` added; the home page is `/index.md`.\n'] +for (const page of ordered) { + const md = toMarkdown(readFileSync(join(content, `${page}.mdx`), 'utf8')) + writeFileSync(join(out, `${page}.md`), md) + full.push(`\n---\n\nSource: /${page === 'index' ? '' : page}\n\n${md}`) +} +writeFileSync(join(out, 'llms-full.txt'), full.join('')) +console.log(`agent files: ${ordered.length} pages, llms-full.txt`)