allan ๐Ÿ“Š is a user on mastodon.club. You can follow them or interact with them if you have an account anywhere in the fediverse.
allan ๐Ÿ“Š @allan

Anyone know of a tool that will let me paste code into a word document and keep the syntax highlighting?

Because I was a bad person and am currently in hell, I have to document my code in a word document. But I also want the formatting to look nice.

ยท Mastalab ยท 1 ยท 0

@allan maybe could use an online prettifier in JS that uses inline styles, then copy/paste the whole <pre>/<code> block. Pretty sure word tries to preserve HTML formatting.

@thurloat @allan Along the same lines, you can also just use the commandline interface for Pygments to spit out .html files for your source files that you can then open and copy-paste from.

@allan Why not make the formatting incredibly ugly to punish whoever has inflicted this torture upon you? This seems like the kind of thing that passive aggression was invented for.

@allan (only tried on a mac) copying out of VS Code preserves highlighting on paste.

follow up: I ended up using tohtml.com/

Paste in code, click highlight, then paste result into word. Works perfectly.