diff --git a/src/main.js b/src/main.js index fa93015..3385f54 100644 --- a/src/main.js +++ b/src/main.js @@ -2562,7 +2562,23 @@ function performExportWithOptions(format, options) { // Use pandoc for export with advanced options - let pandocCmd = `${getPandocPath()} "${currentFile}" -o "${outputFile}"`; + let inputFile = currentFile; + let tempInputFile = null; + + // Pre-process markdown for Word output so that + +# Heading +`; + const output = WordTemplateExporter.preprocessMarkdownForWordExport(input); + expect(output).not.toContain(''); + expect(output).not.toContain('sneh-a4-print'); + expect(output).not.toContain('@media print'); + expect(output).toContain('# Heading'); + }); + + test('removes HTML comments outside style blocks', () => { + const input = ` +Hello world +`; + const output = WordTemplateExporter.preprocessMarkdownForWordExport(input); + expect(output).not.toContain(''); + expect(output).toContain('Hello world'); + }); + + test('removes alignment div tags', () => { + const input = `
+Centered content +
+`; + const output = WordTemplateExporter.preprocessMarkdownForWordExport(input); + expect(output).not.toContain('
'); + expect(output).not.toContain('
'); + expect(output).toContain('Centered content'); + }); + + test('preserves regular markdown content', () => { + const input = `# Title + +| A | B | +|---|---| +| 1 | 2 | +`; + const output = WordTemplateExporter.preprocessMarkdownForWordExport(input); + expect(output).toBe(input); + }); + + test('handles content with no HTML artifacts', () => { + const input = 'Plain text paragraph.'; + const output = WordTemplateExporter.preprocessMarkdownForWordExport(input); + expect(output).toBe(input); + }); +});