"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); const parser_1 = require("./src/parser"); const fs = __importStar(require("fs")); const path = __importStar(require("path")); async function main() { const parser = new parser_1.Parser({ linkBaseURL: 'https://example.com', wikilinkUrl: '/events?d={dtag}', hashtagUrl: '/notes?t={topic}', }); console.log('Reading test documents...'); // Read test documents const markdownContent = fs.readFileSync(path.join(__dirname, 'markdown_testdoc.md'), 'utf-8'); const asciidocContent = fs.readFileSync(path.join(__dirname, 'asciidoc_testdoc.adoc'), 'utf-8'); console.log('Parsing markdown document...'); const markdownResult = await parser.process(markdownContent); console.log('Parsing asciidoc document...'); const asciidocResult = await parser.process(asciidocContent); console.log('Generating HTML report...'); // Generate HTML report const htmlReport = generateHTMLReport({ markdown: { original: markdownContent, result: markdownResult, }, asciidoc: { original: asciidocContent, result: asciidocResult, }, }); // Write HTML report to file (force fresh write) const reportPath = path.join(__dirname, 'test-report.html'); // Delete old report if it exists to ensure fresh generation if (fs.existsSync(reportPath)) { fs.unlinkSync(reportPath); } fs.writeFileSync(reportPath, htmlReport, 'utf-8'); const reportUrl = `file://${reportPath}`; console.log(`\n✅ Test report generated successfully!`); console.log(` File: ${reportPath}`); console.log(` Size: ${(htmlReport.length / 1024).toFixed(2)} KB`); console.log(` Timestamp: ${new Date().toISOString()}`); console.log(` Open this file in your browser to view the results.\n`); } function generateHTMLReport(data) { const { markdown, asciidoc } = data; return ` GC Parser Test Report

GC Parser Test Report

Generated: ${new Date().toLocaleString()}

Markdown Document Test ✓ Parsed

${markdown.result.nostrLinks.length}
Nostr Links
${markdown.result.wikilinks.length}
Wikilinks
${markdown.result.hashtags.length}
Hashtags
${markdown.result.links.length}
Links
${markdown.result.media.length}
Media URLs
${markdown.result.hasLaTeX ? 'Yes' : 'No'}
Has LaTeX
${markdown.result.hasMusicalNotation ? 'Yes' : 'No'}
Has Music

Frontmatter

${markdown.result.frontmatter ? ` ` : '

No frontmatter found

'}

Original Markdown Content

${escapeHtml(markdown.original)}

Rendered HTML Output

${markdown.result.content}
View Raw HTML
${escapeHtml(markdown.result.content)}

Extracted Metadata

${markdown.result.nostrLinks.length > 0 ? `

Nostr Links (${markdown.result.nostrLinks.length})

${markdown.result.nostrLinks.map((link) => `
${escapeHtml(link.type)}: ${escapeHtml(link.bech32)} ${link.text ? ` - ${escapeHtml(link.text)}` : ''}
`).join('')} ` : ''} ${markdown.result.wikilinks.length > 0 ? `

Wikilinks (${markdown.result.wikilinks.length})

${markdown.result.wikilinks.map((wl) => `
${escapeHtml(wl.original)} → dtag: ${escapeHtml(wl.dtag)} ${wl.display ? ` (display: ${escapeHtml(wl.display)})` : ''}
`).join('')} ` : ''} ${markdown.result.hashtags.length > 0 ? `

Hashtags (${markdown.result.hashtags.length})

${markdown.result.hashtags.map((tag) => `
#${escapeHtml(tag)}
`).join('')} ` : ''} ${markdown.result.links.length > 0 ? `

Links (${markdown.result.links.length})

${markdown.result.links.map((link) => `
${escapeHtml(link.text || link.url)} ${link.isExternal ? 'External' : ''}
`).join('')} ` : ''} ${markdown.result.media.length > 0 ? `

Media URLs (${markdown.result.media.length})

${markdown.result.media.map((url) => ` `).join('')} ` : ''} ${markdown.result.tableOfContents ? `

Table of Contents

${markdown.result.tableOfContents}
` : ''}

AsciiDoc Document Test ✓ Parsed

${asciidoc.result.nostrLinks.length}
Nostr Links
${asciidoc.result.wikilinks.length}
Wikilinks
${asciidoc.result.hashtags.length}
Hashtags
${asciidoc.result.links.length}
Links
${asciidoc.result.media.length}
Media URLs
${asciidoc.result.hasLaTeX ? 'Yes' : 'No'}
Has LaTeX
${asciidoc.result.hasMusicalNotation ? 'Yes' : 'No'}
Has Music

Frontmatter

${asciidoc.result.frontmatter ? ` ` : '

No frontmatter found

'}

Original AsciiDoc Content

${escapeHtml(asciidoc.original)}

Rendered HTML Output

${asciidoc.result.content}
View Raw HTML
${escapeHtml(asciidoc.result.content)}

Extracted Metadata

${asciidoc.result.nostrLinks.length > 0 ? `

Nostr Links (${asciidoc.result.nostrLinks.length})

${asciidoc.result.nostrLinks.map((link) => `
${escapeHtml(link.type)}: ${escapeHtml(link.bech32)} ${link.text ? ` - ${escapeHtml(link.text)}` : ''}
`).join('')} ` : ''} ${asciidoc.result.wikilinks.length > 0 ? `

Wikilinks (${asciidoc.result.wikilinks.length})

${asciidoc.result.wikilinks.map((wl) => `
${escapeHtml(wl.original)} → dtag: ${escapeHtml(wl.dtag)} ${wl.display ? ` (display: ${escapeHtml(wl.display)})` : ''}
`).join('')} ` : ''} ${asciidoc.result.hashtags.length > 0 ? `

Hashtags (${asciidoc.result.hashtags.length})

${asciidoc.result.hashtags.map((tag) => `
#${escapeHtml(tag)}
`).join('')} ` : ''} ${asciidoc.result.links.length > 0 ? `

Links (${asciidoc.result.links.length})

${asciidoc.result.links.map((link) => `
${escapeHtml(link.text || link.url)} ${link.isExternal ? 'External' : ''}
`).join('')} ` : ''} ${asciidoc.result.media.length > 0 ? `

Media URLs (${asciidoc.result.media.length})

${asciidoc.result.media.map((url) => ` `).join('')} ` : ''} ${asciidoc.result.tableOfContents ? `

Table of Contents

${asciidoc.result.tableOfContents}
` : ''}
`; } function escapeHtml(text) { const map = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', }; return text.replace(/[&<>"']/g, (m) => map[m]); } // Run the script main().catch((error) => { console.error('Error generating test report:', error); process.exit(1); });