I was building an exam authoring tool. Teachers wrote their questions in Word — full of maths — and pasted them into the browser.

The equations came through as pictures. Flat images of what used to be an equation. Nobody could click into one to fix a typo in a denominator; the only option was to delete it and rebuild the whole thing by hand.

I assumed that would take an afternoon to fix.

The thing I got wrong first

My first instinct was the obvious one. Word pastes garbage, so strip the garbage. Kill the mso- styles, kill the XML namespaces, kill the classes, keep the plain tags underneath.