Easily post source code such as PHP or HTML and display it in a styled box.
SyntaxHighlighter Plus is a WordPress plugin for code syntax highlighting. It is an enhanced version of the original SyntaxHighlighter by Matt, Viper007Bond and mdawaffe. Please give them a big applause for making such a great plugin!
SyntaxHighlighter allows you to easily post syntax highlighted code all without loosing it’s formatting or making an manual changes.
It supports the following languages (the alias for use in the post is listed next to the name):
bash
, sh
cpp
, c
, c++
c#
, c-sharp
, csharp
css
delphi
, pascal
diff
groovy
java
js
, jscript
, javascript
perl
, pl
php
plain
, text
py
, python
rb
, ruby
, rails
, ror
scala
sql
vb
, vb.net
xml
, html
, xhtml
, xslt
This plugin uses the SyntaxHighlighter JavaScript package by Alex Gorbatchev.
Find [sourcecode language='css']code here[/sourcecode]
too long to type? Here’s some alternative examples:
[source language='css']code here[/source]
[code language='css']code here[/code]
[sourcecode lang='css']code here[/sourcecode]
[source lang='css']code here[/source]
[code lang='css']code here[/code]
[sourcecode='css']code here[/sourcecode]
[source='css']code here[/source]
[code='css']code here[/code]
[lang='css']code here[/lang]
[css]code here[/css]
(or any of the supported language)Note: Quotation marks around the language can be omitted for even shorter and neater syntax. 🙂
To upgrade from a previous version of this plugin, delete the entire folder and files from the previous version of the plugin and then follow the installation instructions below.
Important: If you have made any changes to the CSS file, please make sure to back it up before upgrade!
Extract all files from the ZIP file, making sure to keep the file structure intact, and then upload it to /wp-content/plugins/
.
This should result in the following file structure:
- wp-content - plugins - syntaxhighlighter-plus | readme.txt | syntaxhighlighter.php - syntaxhighlighter - scripts | clipboard.swf | shBrushBash.js | shBrushCpp.js | shBrushCSharp.js | [...] | shCore.js | shLegacy.js - src | shCore.js | shLegacy.js - styles | SyntaxHighlighter.css
See Also:“Installing Plugins” article on the WP Codex
Go to the admin area of your WordPress install and click on the “Plugins” menu. Click on “Activate” for the “SyntaxHighlighter” plugin.
Just wrap your code in [sourcecode language='css']code here[/sourcecode]
. The language attribute is required! See the plugin’s description for a list of valid language attributes.
Make sure your theme’s footer has <?php wp_footer(); ?>
somewhere in it, otherwise the JavaScript highlighting files won’t be loaded.
Make sure you correctly use the BBCode with a valid language attribute. A malformed usage of it won’t result in replacement.
Use ‘shift + return’ instead of ‘return’ when changing lines.
Version 1.0b2
Version 1.0b1
Version 0.18
[code][/code]
)Version 0.17
Version 0.16
wptexturize()
doesn’t transform them into fancy quotes and screw up code.’Version 0.15b
Version 0.15a
Version 0.15
Version 0.14
Version 0.13
Version 0.12 (broken)
Version 0.11
Version 0.10