Natasha The Robot

Currently learning... Swift!                                                                     You can follow me on Twitter here.                                            Subscribe via RSS here.

How To Embed Code Into Your WordPress.com Blog

Posted on

When I first started this blog, I was completely lost on how to properly embed code. Luckily, someone commented on one of my posts and told me I need to embed my code between the “[ sourcecode language = "css" ]” and “[ /sourcecode ]” tags. It seemed to be working ok, but I kept wondering why the language was css, when I was working with Java and now Ruby. Also, the formatting wasn’t quite right, especially for Ruby # comments.

The other day, I tried experimenting with the tages, by embedding my ruby code between the “[ sourcecode language = "ruby"]” and “[ /sourcecode]”  tags. Lo and behold, this worked perfectly! My code is now property formatted for Ruby specifically, just like it is in my TextMate text editor. I really wish I tried this earlier, but it’s never too late. So if you’re embedding code into your WordPress.com blog, make sure to play around with the language in the sourcecode tag :)

  • DM

    for a list of supported languages:
    http://en.support.wordpress.com/code/posting-source-code/

    … I found the sourcecode embedding support to be lacking however.
    When I toggled between ‘html’ and ‘visual’ view in the editor once too many times, it messed up the body that had some sourcecode in it.

    which is why I offloaded my sources to the other site ;)

    another thing was the greedy multi-line comment bug…. which is still there on wordpress’ version of it. O_o

    • http://learning2program.wordpress.com Natasha Murashev

      Thanks! That’s a great link – had a hard problem finding info on this when I first started this blog.

  • http://gotfu.wordpress.com DM

    natasha the link at your name points to learning2program.wordpress… (which I’m guessing was your old choice of blog name but changed it) …

    You can change that at the bottom of the ‘users’->’personal settings’ in your dashboard.

    … /wp-admin/users.php?page=grofiles-user-settings

    • http://natashamurashev.com Natasha Murashev

      Awesome, totally didn’t notice this. I updated the settings, but looks like it doesn’t change the link retroactively.

  • http://shiftingbytecodes.wordpress.com egbossi

    Reblogged this on Shifting Bytecodes and commented:
    Great post of how to embed code on free wordpress blog