From 2cac075c0e12ec8f4eb9cf0546fafda08572ce7a Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Tue, 30 Jun 2026 19:57:40 +0530 Subject: [PATCH] fix(word): harden DOCX preprocessing and temp-file cleanup - Make the HTML preprocessor code-block and inline-code aware so code examples containing + +
text
+\`\`\` + +After code. +`; + const output = WordTemplateExporter.preprocessMarkdownForWordExport(input); + expect(output).toContain(''); + expect(output).toContain(''); + expect(output).toContain('
text
'); + expect(output).toContain('After code.'); + }); + + test('preserves HTML artifacts inside inline code', () => { + const input = 'Use `
` for alignment.'; + const output = WordTemplateExporter.preprocessMarkdownForWordExport(input); + expect(output).toContain('`
`'); + }); + + test('handles uppercase tags and unquoted attributes', () => { + const input = `
+Centered +
+`; + const output = WordTemplateExporter.preprocessMarkdownForWordExport(input); + expect(output).not.toContain(''); + expect(output).toContain('Centered'); + }); + + test('handles single-quoted attributes', () => { + const input = `
Right
`; + const output = WordTemplateExporter.preprocessMarkdownForWordExport(input); + expect(output).not.toContain(''); + expect(output).toContain('Right'); + }); + + test('removes non-alignment div tags without leaving malformed HTML', () => { + const input = `
Note text
`; + const output = WordTemplateExporter.preprocessMarkdownForWordExport(input); + expect(output).not.toContain(''); + expect(output).toContain('Note text'); + }); + + test('returns non-string input unchanged', () => { + expect(WordTemplateExporter.preprocessMarkdownForWordExport(null)).toBeNull(); + expect(WordTemplateExporter.preprocessMarkdownForWordExport(123)).toBe(123); + }); });