How to use the GeSHi plugin/mambot
Written by Cory |
July 22, 2008
|
(0)
Joomla! comes with a plugin/mambot called GeSHi that comes in quite handy if you have a site like HowToJoomla.net in which you share code snippets with your readers. I recently tried to use GeSHi on a Joomla! 1.5 site, and I found that it works differently in Joomla! 1.5 than it does in Joomla! 1.0. Read on to see how to use it in both.
What is GeSHi?
GeSHi stands for "Generic Syntax Highlighter", and it is used to highlight code snippets in different web languages like PHP, HTML, and CSS. It also converts tags in those languages so that they will not render like regular tags.
For example, if you want to share some HTML code, you have to use something like GeSHi, or the browser will treat your HTML code like regular HTML code.
The following code is done without GeSHi:
Without GeSHi
The following code is done with GeSHi:
<p><strong>With GeSHi</strong></p>
Not that in the code with GeSHi, you can see the HTML tags, and in the code without GeSHi, you cannot see the HTML tags. The words "Without GeSHi" are rendered like regular HTML
How to use GeSHi in Joomla! 1.0
To use GeSHi in Joomla! 1.0, you use the following HTML code:
<pre lang="html">
<!-- your HTML code here -->
</pre>
You can change 'lang="html"' to other languages like 'lang="php"' so that GeSHi highlights it according to the language you are using.
How to use GeSHi in Joomla! 1.5
GeSHi has a very slight difference in Joomla! 1.5. Here is an example:
<pre xml:html> <!-- your HTML code here --> </pre>
Note that instead of 'lang="html"', you use 'xml:html'. That is the only difference. I'm not sure why they did it that way, but they did so if yo plan on using GeSHi for Joomla! 1.5, you need to be aware of this.
Questions/Comments
As always, questions and comments are welcome.
Trackback(0)
Comments (17)
written by Jason Boyette, July 24, 2008
written by Jason Boyette, July 24, 2008
You can change 'lang="html"' to other languages like 'lang="php"' so that GeSHi highlights it according to the language you are using.
In 1.5, if you want to display PHP code, do you change it to ? How about CSS? I'm looking for a resource for the syntax inside the tag.
Maybe I'll just use the old trial-and-error method.
written by Jason Boyette, July 24, 2008
written by wene, September 24, 2008
i had a problem using a custom language file with geshi and j1.5.
the working syntax is for me :
written by Spacemonkey, October 15, 2008
For [removed]
written by Spacemonkey, October 15, 2008
*sniff*
written by Kenneth Crowder, November 11, 2008
I'm not sure of all the languages it supports...
From: libraries/geshi/geshi.php
actionscript, ada, apache, asm, asp, bash, c, c_mac, caddcl, cadlisp, cdfg, cpp, csharp, css, delphi, html4strict, java, javascript, lisp, lua, mpasm, nsis, objc, oobas, oracle8, pascal, perl, php, python, qbasic, sas, smarty, vb, vbnet, visualfoxpro, xml
written by smalls, December 30, 2008
Also, you don't mention that i need to turn off the WYSIWYG why not?
thanks
written by Federico Capoano, March 06, 2009
written by Dylan, May 11, 2009
Using xml:html, xml:xhtml or even xml:xml all do not get the intended result.
It would simply show something like
You could of cours always use the corresponding ampersand-something but that seems a drag
Write comment
Join the HowToJoomla Community!
- Create a profile
- Connect with other members
of the community - All for FREE
Already a member? Login here.


