This is an old thread but I thought I'd put here what I've been doing so the next person who finds this thread can reference it.
Basically, I found a website that formats code as syntax-highlighted HTML:
http://hilite.me/. I paste my code there and then copy/paste the output into Mnemosyne and it displays the HTML perfectly.
Unfortunately, there is a bug in QT that disallows copying from Mnemosyne, which is frustrating as I sometimes want to copy/paste code _from_ Mnemosyne to a text editor (I often use this for test cases) and this does not work. You can copy/paste from within edit mode in Mnemosyne but the code is wrapped in HTML so is unusable.