4

Ok, not technically a programming question but I want a plugin for my WordPress blog that displays code snippets.

Can anyone here recommend a good one? Also, do you guys know which one Jeff uses on codinghorror. That one looks really good.

Thanks.

3 Answers 3

3

wordpress.com claims to use Alex Gorbatchev’s syntaxhighlighter Google Code project.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Oren, I'm now using viper007bond.com/wordpress-plugins/syntaxhighlighter which is based on Alex's project.
2

I guess you might be interested in run-this - there is a wordpress plugin to allow your readers to run your snippets in the browser.

Comments

2

For WP-Snippets, I use Prettify.

You should probably use a plugin for escaping characters to be able to display code without having to do it yourself, or your code wont be displayed. Or just put this in functions.php in your theme folder to do this automatically:

function bbcode( $attr, $content = null ) {
    $content = clean_pre($content); // Clean pre-tags
    return '<pre"><code>' .
            str_replace('<', '&lt;', $content) . // Escape < chars
            '</code></pre>';
}
add_shortcode('code', 'bbcode');

And then wrap your code with [code]<?php echo 'hello world!'; ?>[/code]

Source: Code in posts

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.