Wordpress with Markdown

Today I updated Wordpress which went smooth so I decided to fix a problem on my blog which appeared when I first migrated to Wordpress. I’m using the plugin Markdown for WordPress and bbPress so I can write posts with Markdown syntax and I use code sections heavily. The problem was that using special characters like: & “ ‘ within code paragraph would look like this:

& ” ‘ < >

For now I just reverts posts upon displaying so the html entities are replaced by special characters. I know this is not the right way but its temporary :)

I asked on the Wordpress IRC and a nice guy called ‘ansimation’ gave me this to work with:

function reconvert_pre_entities( $d ) {
     return preg_replace_callback('/<pre>(.*?)/sim', create_function('$matches', 'return( html_entity_decode($matches[0]) );'), $d );
}
add_action('the_content', 'reconvert_pre_entities' );

When I get a little time I’m going to incorporate this into the Markdown plugin so it wont affect any of the other blogs not using Markdown.

Enjoyed reading this post?

Here are some others that you might like — or scroll down to leave a comment.