PluGeSHin is a WordPress plugin by Peter Ajtai that lets you use the syntax highlighting of GeSHi through WordPress shortcodes.
PluGeSHin is a WordPress plugin by Peter Ajtai that lets you use the syntax highlighting of GeSHi through WordPress shortcodes.
The format for using PluGeSHin is:
[geshi] CODE TO BE HIGHLIGHTED [/geshi]
[geshi] shortcode without any attributesG PluGeSHin button
To see working examples of GeSHi with PluGeSHin visit this page.
PluGeSHin comes with a helpful WP-Admin Settings Page. You can draft a sample Post from that page with the push of a button. The sample page has multiple examples of PluGeSHin shortcodes, so you can both make sure the plugin is working, and so you can look at how the examples were written.
A list of supported languages is shown on the PluGeSHin Settings Page in a dropdown.
PluGeSHin can take one or more attributes, like this:
[geshi attribute="ATTRIBUTE VALUE"] CODE TO BE HIGHLIGHTED [/geshi]
All attributes are optional. Leaving them out will trigger default attributes. The default values for the highlighted language and whether line numbers are shown can be set on the PluGeSHin Settings Page in WP-Admin.
The attributes you can use with PluGeSHin are:
lang - is the language used for highlighting. The codes available can be looked up on PluGeSHin's Settings Page from the dropdown.nums - controls whether line numbers are shonw. nums="1" shows line number nums="0" does not.start - controls what the first line number is. You should always have line numbers showing if you set start.highlight - let's you pick the line numbers to draw attention to. It is a comma separated list. The numbers are lines relative to the first one.target - pick the target for anchor element links to documentationNote that the highlighted code will be wrapped in <pre> tags and the class attribute of the <pre> tags will be PluGeSHin and the name of the
highlighted language. This way you can easily use CSS to tweak the styling of your code blocks. You should also wrap the unhighlighted code
in <pre> tags. The short tags themselves should not be within <pre> tags.
Here is an example using all four possible attributes
[geshi lang="cpp" start="37" nums="1" highlight="4,13"]
CODE TO BE HIGHLIGHTED
[/geshi]
Finally, remember to use Shift+Enter if you're typing code and not pasting it in. You don't have to - PluGeSHin will still work if you don't -
but it'll look nicer for you in the Visual edit screen.
Above, in the "Quick Start" section you can read about how to use PluGeSHin with the TinyMCE button. Below are more detailed instructions, in case you want to do things by hand or need to trouble shoot malformed HTML.
The following instructions are for using the Visual editor mode. You can also use the HTML editor mode with PluGeSHin. The important thing to remember is that PluGeSHin can only be responsible for what's between the short codes, so don't wrap the entire short code block in a PRE on the outside!
Steps for using PluGeSHin manually:
Alt-Shift-Z if you don't see the Format drop down in the TinyMCE toolbar[geshi][/geshi]Preformatted format.Preformat will preserve your indentation.The code you type or paste in should be preformatted - in <pre> tags. The [geshi] short code tags should not be preformatted.
Support of more GeSHi methods. Next ones will probably be the option to show code in a <div> or a <pre> as well as the ability
to set header and footer information.
If you have questions, problems, or general ramblings, correspond with me at spam dot database at gmail dot com.
Requires: 2.5 or higher
Compatible up to: 3.2.1
Last Updated: 2011-9-18
Downloads: 416
Got something to say? Need help?