How To Embed Code Into Your WordPress.com Blog

3 Feb

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 🙂

Advertisements

5 Responses to “How To Embed Code Into Your WordPress.com Blog”

  1. DM February 4, 2012 at 1:29 am #

    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

    • Natasha Murashev February 4, 2012 at 11:11 am #

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

  2. DM February 5, 2012 at 1:18 am #

    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

    • Natasha Murashev February 5, 2012 at 11:39 am #

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

  3. egbossi August 27, 2012 at 9:21 am #

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s