Posting java code on wordpress.com. Highlight issues and lost indentation
-
27-05-2021 - |
Question
I am trying to post some java code snippets on wordpress.com using the following tags as suggested here: http://en.support.wordpress.com/code/posting-source-code/
[sourcecode language="java"] ... [/sourcecode]
But all the indentation is lost and the comments doesn't get highlighted properly. The codes were copied from Eclipse.
You can see the problem here: http://lifelearner168.wordpress.com/
Thanks in advance.
Solution
Try posting this code and tell me what it does:
//indentation test
//further indentation
OTHER TIPS
Paste it in the JavaScript text area here: http://jsfiddle.net/ to make sure the indentation is in a web compatible format and then copy it from the textarea again and paste it in the wordpress posting text area. Eclipse probably has a weird indentation method.
I looked at the source of the page and it didn't have any indentation, so it has to be something in the posting process on wordpress rather than a problem with the way it is displaying on the page when it is queried. (ignore this if it doesn't make any sense..)
As user1296058 mentioned, if you use [sourcecode language="javascript"] it will fix this issue.
Finally this worked for me :
[code language="java"]
//YOUR CODE
[/code]