=== PluGeSHin === Contributors: pajtai Donate link: http://netlumination.com/ Tags: syntax highlighting, GeSHi Requires at least: 2.5 Tested up to: 3.2.1 Stable tag: 1.0 PluGeSHin is a Wordpress plugin by Peter Ajtai that lets you use the syntax highlighting of GeSHi through Wordpress shortcodes. == Description == [PluGeSHin](http://netlumination.com/blog/plugeshin) is a [Wordpress](http://wordpress.org/) plugin by Peter Ajtai that lets you use the syntax highlighting of [GeSHi](http://qbnz.com/highlighter/) through Wordpress [shortcodes](http://codex.wordpress.org/Shortcode_API). To see working examples of GeSHi with PluGeSHin visit [this page](http://netlumination.com/blog/plugeshin). If you install PluGeSHin you can draft a sample Post with the push of a button on the PluGeSHin WP-Admin settings page that has multiple examples of PluGeSHin shortcods, so you can make sure the plugin is working, and so you can look at how the examples were written. The format for using PluGeSHin is: [geshi] CODE TO BE HIGHLIGHTED [/geshi] 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 the defaults. The language and showing line number defaults 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 at on PluGeSHin's settings page. * 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. Note that the highlighted code will be wrapped in PRE tags and the class attribute of the PRE tag will be "PluGeSHin" and the name of the language highlighted. 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. = Quick Start = 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: 1. Pick Paragraph format from the dropdown. 2. Hit "Alt-Shift-Z" if you don't see the Format drop down in the TinyMCE toolbar 1. Type [geshi] 1. Hit enter twice 1. Type [/geshi] 1. Hit the up arrow once 1. Pick the Preformatted format. 1. Type or paste in your code. The Preformat will preserve your indentation. 1. Save your post and View or Preview it from the front end. The code will now be highlighted. The code you type or paste in should be preformatted - in PRE tags. The geshi short code tags should not be preformatted. == Installation == * Download PluGeSHin * Unzip the file * Upload the "plugeshin" directory and contents to the wp-content/plugins director on your server. * In the WP-Admin panel navigate to the Plugins page. * Click the "Activate" option for PluGeSHin. After you have PluGeSHin installed, you can: 1. Use the PluGeSHin shortcodes as outlined above 1. Set global PluGeSHin defualts on the WP-Admin PluGeSHin Settings page. 1. Open the Settings dropwon in the left nav bar and then click on PluGeSHin 1. Draft a sample Post to make sure PluGeSHin is working and to look at examples of its use 1. You can draft a sample Post with the push of a button on the PluGeSHin settings page. == Frequently Asked Questions == = What happens if there's a GeSHi error? = That code block gets the class attribute of "geshi-error", and a hidden div with the error message contents is placed right before the code block. The div is hidden, since the error messages often contain full path info for file names. You can look at the error message with something like Firebug or by looking at the page's source. = Why are there a bunch of funny characters instead of quote marks in the highlighted code? = The code is not wrapped in PRE tags. When you look at the HTML view of your post it should look like this: ` [geshi]
// some code here
alert("example");
[/gesh]
`
= Everything's highlighted, but I can see two scroll bars or my code is wrapped in two PRE tags =
PluGeSHin only know about things between the two shortcode tags, so you cannot wrap the shortcodes in PRE tags. Take a
look at the previous answer for correct formatting.
= I'm typing code between the PluGeSHin shortcode tags, and everything highlights as it should, but there are annoyingly
large spaces between my lines of code in the WP-Admin window. What is going on? =
Hit `Shift + Enter` between lines instead of `Enter`. Hitting simple `Enter` will wrap each line in a `` tag. PluGeSHin isn't bothered by this, and it doesn't affect the front end, but it does cause big gaps between lines in the editor. == Screenshots == 1. A typical view of the WP-Admin screen when using PuGeSHin. You can use either the View or HTML modes, but I find using the View mode easier. 2. The highlighting shown on the front end due to the shortcode tags used in Screenshot-1. == Changelog == = 1.0 = * First stable release of PluGeSHin == Upgrade Notice == No updgrades yet.