0

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?

  • Format the code in a proper text editor first, then just paste it inside the shortcode once you're done. I post code to my WP.com blog without a problem. – t31os Mar 1 '11 at 13:56
  • I copied the code to gedit, and I still have the same problem – Mahmoud Hossam Mar 1 '11 at 14:12
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.