How To Embed Code Into Your Blog

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 blog, make sure to play around with the language in the sourcecode tag 🙂

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.

  • DM

    for a list of supported languages:

    … 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

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

  • 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

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

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

  • Serge Sukhanov

    But unfortunately there is no Swift embedding. 🙁