Posting Source Code to Wordpress.com

The other day I tried to blog about the vte.terminal, and I had huge problems posting the source code. My problem was that despite how much I searched, and everything I tried, I could not keep the formatting and post the source code. The formatting was wrong when I used the <code> tags (The spaces where removed and in python that’s important).

It turns out that this was the most correct with the exception that befor you make your post you must go to Users then Your Profile and make sure “Use the visual rich editor when writing”
is unselected instead of [sourcecode language=’css’]…[/sourcecode] you are going to want to have [sourcecode language="css"]…[/sourcecode]

[sourcecode language="python"]#This
#is an example
#of what your source code will look like
x = True
if x:
print ‘hello world’[/sourcecode]

The source for this post can be found here.

Share and Enjoy:
  • Digg
  • Reddit
  • del.icio.us
  • Facebook
  • Twitter
  • Identi.ca
  • Slashdot

9 Comments

  1. H3g3m0n says:

    Wordpress still causes massive headaches for me when posting sourcecode, for instance:
    [sourcecode language='cpp'[
    cout << "Hello << endl;
    [/sourcecode]

    No matter what I do it converts < to <, its doesn’t do it for #include though. code tags do the same thing.

    Also it tends to convert quote marks from ASCII to UNICODE which most compilers/interpreters have problems with. I posted about here: http://en.forums.wordpress.com/topic.php?id=15761&amp; although now it doesn’t seem to be a problem anymore.

    I’m going to look at using vim’s :TOhtml function and converting the result into something I can paste in.

  2. earobinson says:

    hey sorry to here it did not work for you :(

  3. farz says:

    doesnt work well at all
    plugins resort :(

  4. earobinson says:

    Thats to bad :( works great for me :)

  5. [...] Cleaning out some cruft October 6th, 2007 — jronnholm Yay, I finally found out how to display code properly in wordpress http://earobinson.wordpress.com/2007/09/12/posting-source-code-to-wordpresscom/ [...]

  6. Sourcecode formatter causes problem when I use templates in my source code. Two consecutive template declarations results in closing brace for the first template, treats the template declaration as an HTML tag in my opinion.

    Also cout << 10 is replaced by cout < < 10;

  7. [...] struggling for a while to get syntax highlighting for my code. Finally found a couple of links that get this going. But the sad thing is that perl is not [...]

  8. Preodapomma says:

    Could not find a suitable section so I written here, how to become a moderator for your forum, that need for this?

Leave a Reply