I’ve been trying to post some Java code to my blog, but it seems like it has some problems with the formatting.
First, whenever I copy/paste code into the editor, it’s pasted as pre-formatted, which means that it converts the indents to spaces, all on a single line.
And when I try to separate the lines by making each line of code on a single physical line, it doesn’t indent them automatically.
I’m using the visual editor, and I’ve checked the HTML code, and nothing seems to be wrong with it.
What am I doing wrong? Or is this a bug I should report to WordPress?
Paste the code in the HTML editor, it probably won’t try to convert indents and linebreaks. Surround it with the
[sourcecode] shortcode and only then return to the visual editor.