Problem with posting HTML code on WordPress

wordpress.com

I am trying to post some source code on a WordPress.com blog. WordPress actually makes posting syntax-highlighted code quite easy–you wrap the code in a [sourcecode] block, optionally specify the language with the lang attribute, and you're good.

I've never had a problem with this before, but I recently found an issue I can't fix. I'm trying to render some source code on the blog with the following.

[sourcecode lang="html"]
<iframe src="http://someserver.edu/somescript.php?id=223"
        marginwidth="0" marginheight="0" frameborder="0" 
        scrolling="no" width="210px" height="60px"></iframe>
[/sourcecode]

When I try to preview the post, the HTML gets stripped from the [sourcecode] block. When I try to escape the < and > characters, the code block is rendered, but the raw text is shown without interpreting the encodings (so you see &lt; instead of <, etc).

I'm guessing the original HTML is being stripped as rendering an iframe could lead to security vulnerabilities. But I don't want to render the iframe, I want to render the code behind the iframe, which should not present any security issues. How can I tell the blog to render my source code correctly?

Best Answer

One solutions that works for me is to host my code snippets on Github Gist, then you can embed the Gist into your post on Wordpress using this shortcode:

[gist *FULL LINK TO GIST*]

You can customize the embedded Gist and the instructions on how to do that are here.