Back to Portfolio

πŸ“„ AI-to-Docx Converter β€” Case Study

Next.js LaTeX-to-OMML Math Translation Pipeline for Editable Word Documents

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.

GitHub Repository

🎯 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

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ AI Chat Output β”‚ ────► β”‚ Regex & Tokenizer β”‚ ────► β”‚ LaTeX to OMML β”‚ β”‚ (Markdown + Mathβ”‚ β”‚ AST Parsing β”‚ β”‚ Math Translator β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ Downloadable β”‚ ◄──── β”‚ Pandoc / OpenXML β”‚ β—„β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ .docx File β”‚ β”‚ Document Compiler β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βš–οΈ 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