Overview
AI-to-Docx Converter is a Next.js web application built to convert AI chat outputs (ChatGPT, Gemini, DeepSeek) into clean, editable Microsoft Word (.docx) files while translating LaTeX equations into native OpenXML Math (OMML) structures.
π― Problem & Motivation
Pasting raw Markdown or LaTeX math syntax from AI chatbots into Microsoft Word results in unformatted plain text or broken equation blocks, requiring tedious manual re-keying for academic papers.
βοΈ Technical Solution
Developed a parsing engine that intercepts inline and block LaTeX math tokens ($\dots$ and $$\dots$$), translating them into native OpenXML Math (OMML) elements before final DOCX compilation.
ποΈ Architecture & Conversion Pipeline
- Next.js & TypeScript: Modern React frontend and server API request pipeline.
- LaTeX to OMML Translator: Maps mathematical symbols and fraction structures to Microsoft Word native equation XML schemas.
- Pandoc Document Engine: Compiles Markdown AST elements into valid OpenXML package structures.
βοΈ Challenges & Trade-offs
Trade-off: Supporting complex nested matrices in LaTeX requires fallback mechanisms when specific syntax is non-standard across different LLM vendors.
π‘ Lessons Learned
1. Document AST transformation is vastly superior to simple string replacement when building file converters.
2. Microsoft Word XML format requires precise structural namespaces for equations to render as native fields.
π Planned Improvements
- Planned Direct export to Excel sheet tables for data outputs.
- Planned Live side-by-side document preview editor.