UNPKG

@entro314labs/starlight-document-converter

Version:

A comprehensive document converter for Astro Starlight that transforms various document formats into Starlight-compatible Markdown with proper frontmatter

59 lines (58 loc) 2.29 kB
// src/plugins/built-in/markdown-processor.ts var markdownProcessor = { extensions: [".md", ".mdx"], metadata: { name: "markdown-processor", version: "1.0.0", description: "Advanced markdown processing with link fixing, image processing, and TOC generation", author: "Starlight Document Converter" }, validate: (content) => { return typeof content === "string" && content.length > 0; }, process: async (content, context) => { let processedContent = content; try { if (context.options.fixLinks || context.options.processImages || context.options.generateToc) { const { LinkImageProcessor } = await import("./link-image-processor-5LK3OBO7.js"); const { TocGenerator } = await import("./toc-generator-XJPRHRCH.js"); const { dirname } = await import("path"); if (context.options.fixLinks || context.options.processImages) { const processor = new LinkImageProcessor( dirname(context.inputPath), dirname(context.outputPath) ); const result = await processor.processContent( processedContent, context.inputPath, context.outputPath ); processedContent = result.content; if (context.options.verbose) { const linkReport = processor.generateLinkReport(result.links); const imageReport = processor.generateImageReport(result.images); console.log(` Links: ${linkReport.repaired} repaired, ${linkReport.broken} broken`); console.log(` Images: ${imageReport.copied} copied, ${imageReport.missing} missing`); } } if (context.options.generateToc) { const tocGenerator = new TocGenerator(); if (!tocGenerator.hasExistingToc(processedContent)) { processedContent = tocGenerator.insertTocIntoContent(processedContent); if (context.options.verbose) { console.log(" Added table of contents"); } } } } return processedContent; } catch (error) { console.warn(`Failed to process markdown for ${context.inputPath}:`, error); return content; } } }; export { markdownProcessor }; //# sourceMappingURL=chunk-KMYKM5T4.js.map