How to put formatted, highlighted code in a Wordpress post
I found two complementary plugins that enable me to put highlighted formatted code in a Wordpress page or post. Here’s an example of what they do:
[sourcecode language="python"]
# Plot flux at continuum boundary
pylab.figure()
pylab.hold(True)
pylab.plot(nd_times, Jl_BD, 'b-', label="Flux from BD simulation")
pylab.plot(nd_times, Jl_BD+Jl_BD_std, 'b.', label="Flux from BD simulation")
pylab.plot(nd_times, Jl_BD-Jl_BD_std, 'b.', label="Flux from BD simulation")
[/sourcecode]Test successful! Note that Javascript must be enabled to see the highlighting. Get the plugins here:
Visual Code Editor SyntaxHighlighter Plus
Comments
Comment #1 by lubos
lubos - Jun 3, 2012
Another good option is WP-Syntax, http://wordpress.org/extend/plugins/wp-syntax/. Also check out WP-Latex, http://wordpress.org/extend/plugins/wp-latex/, for inputing equations.