AI2Word by Zimist Coded
How it works

Eight deliberate stages,
each solving a specific failure mode.

Most markdown-to-Word tools are a wrapper around a library. AI2Word runs a purpose-built pipeline. Here’s exactly what happens between the moment you click Download Word and the moment Word opens your file.

The pipeline

1 Paste 2 Normalize 3 Shield code 4 Detect math 5 Parse blocks 6 Build IR 7 LaTeX → OMML 8 Render DOCX

Stage by stage

Each stage exists for a reason. Here’s the reason.

1

Normalize the input

UTF-8 BOMs, mixed line endings, zero-width characters, Unicode spaces, and smart quotes are all normalised before anything else touches the text.

Why: a paste from ChatGPT’s web UI carries invisible characters that break every downstream parser. Cleaning once, at the top, saves ten patches further down.

2

Shield code blocks

Every fenced block and inline `span` is lifted out and replaced with an invisible sentinel character.

Why: $x inside a code sample is not a variable. A naïve math regex doesn’t know that. Shielding first means $this->db->query() survives intact.

3

Detect math

$…$, $$…$$, \(…\), \[…\], and \begin{env}…\end{env} are located. A looksLikeMath guard rejects dollar amounts, English words, and $ x $ with stray spaces.

Why: turning every $5 and tax is $ into an equation is the fastest way to lose a user’s trust. False negatives are cheap; false positives are not.

4

Parse markdown blocks

Headings, lists, tables, blockquotes, horizontal rules, and paragraphs are split into a block list. A special case folds ChatGPT’s “N.” on its own line into a numbered list item.

Why: line-based block parsing is deterministic and debuggable. A regex-first approach tangles when tables and lists nest.

5

Build the document IR

Blocks are converted to an intermediate DocumentNode tree — headings, paragraphs, lists, tables, equations. Inline spans (bold, italic, links, math) are parsed within each block.

Why: separating “what the document says” from “how Word writes it” means the same IR could render to DOCX, HTML, or PDF with no parser changes.

6

LaTeX → OMML

A recursive-descent LaTeX parser turns \frac{a}{b}, \sqrt[n]{x}, \sum_{i=1}^n, \begin{pmatrix}…\end{pmatrix} into real Office Math nodes.

Why: Word speaks OMML, not LaTeX. Rendering equations as Unicode approximations loses subscripts, fractions, and matrices. Native OMML means the equation is editable in Word’s equation editor.

7

Render the DOCX package

Styles, numbering, headers, footers, settings, and content are written as separate XML parts and zipped into the .docx container.

Why: a .docx is a ZIP with a specific internal structure. Writing the parts directly is faster and more controllable than any library.

8

Clean up

The generated file is stored, handed to the browser, and pruned after two hours. Old documents are removed on every download.

Why: conversion happens on the server, but storage doesn’t have to be permanent. Old documents are removed on every download so the disk never grows without bound.

See it in action

Paste something with a heading, a table, and a formula. Watch the preview.

Open the app