LLM-output to Microsoft Word

My dayjob varies between MS Word, Python and SQL, but it's mostly MS Word. That means I often paste text back and forth between Microsoft Word and an LLM (my current favorite is Claude 3.7-Sonnet). That is frustrating, becase Word sucks at formating that correctly. This has caused me a lot of pain and googling. Finally, I realized that pandoc is the best answer, and that pandoc ban be found as a wasm file. Thanks to https://tweag.github.io/pandoc-wasm/, I was halfway there. They made the wasm available, but without a download option I couldn't figure out how to get a MS Word output. So I rolled my own with Claude. The code is in the gist at the bottom of the page.

The solution worked quickly and is available here under my new tools section.

The real problem was figuring out how to serve that 55MB Wasm file from my static dokku setup. In the end, after a lot of back and forth, I ended up using Dokku persistent storage and copy the file from the mounted storage to the static folder in my final nginx container, and then reference it from there. I tried a separate static folder for these large files, but it involved too much file permissions debugging for me to see it through. A bit hacky with an entrypoint like this, but hey, it works!

#!/bin/sh
set -e

# Copy files from mounted volume to static directory
cp -a /tmp/lfs/* /usr/share/nginx/html/static/lfs/ 2>/dev/null || true

# Start nginx
exec nginx -g "daemon off;"

And here is the entire pandoc wasm solution: