Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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