How to change GeSHi stylesheet
I'm using syntax highlighting very often on this site and two days ago I switched my website to dark theme which caused some troubles because by default GeSHi (Generic Syntax Highlighter) uses light color scheme.This can be easily changed by some modifications.
function use_geshi($match) { $geshi = new GeSHi($match[2], $match[1]); $geshi->enable_classes(true); $geshi->set_overall_class('geshi'); return $geshi->parse_code(); }
So this is my current callback function. The key component for customization is method
enable_classes(true)
which
in this case enables classes for HTML elements generated by GeSHi and set_overall_class('geshi')
method which will add geshi
named
class for each HTML element. I chose 'geshi'
but you can choose any string you need eg. 'darkscheme', etc...So and from now you can start to style the GeSHi output. There is my stylesheet which you can use if you want.
/* * Geshi stylesheet * * CyberAsylum.eu * dark theme by niekto@niekde.sk (Jaroslav Petras) * there is no licence and you can use it, copy it, sell it * or burn it * */ /* all */ .geshi { border: none !important; } /* lines */ .geshi .li1 { background: #252525 !important; } .geshi .li2 { background: #272727 !important; } /* brackets */ .geshi .br0 { color: #bfbfbf !important; } /* comments */ .geshi .co0, .geshi .co1, .geshi .coMULTI { color: #7a7a75 !important; } /* strings */ .geshi .st0, .geshi .st_h { color: #ff4444 !important; } /* methods */ .geshi .me0, .geshi .me1 { color: #ffffff !important; } .geshi .me2 { color: #ffcc66 !important; } /* keywords */ .geshi .kw1 { color: #99ee00 !important; } .geshi .kw2 { color: #eeaa22 !important; } .geshi .kw3 { color: #dd88ff !important; } .geshi .kw4 { color: #ff7744 !important; } /* operators */ .geshi .sy0 { color: #44ffbb !important; } /* numbers */ .geshi .nu0 { color: #ff2288 !important; } /* variables */ .geshi .re0 { color: #88c0ff !important; } .geshi .re1 { color: #88c0ff !important; } .geshi .re2 { color: #ccddff !important; } .geshi .re3 { color: #88c0ff !important; } .geshi .re4 { color: #88c0ff !important; } .geshi .re5 { color: #ddddff !important; } /* EOF */
date: Thu, 20 Feb 2014 09:07:00 +0000
link: CyberAsylum.eu/how-to-change-geshi-stylesheet