• Go, have a look at the live demo.
• Plugin highlights:
- Syntax highlighting for 240 languages.
- Lightweight and super-simple usage.
- Mobile-friendly: saves bandwidth and battery (no client-side code execution required, usually only one additional HTTP request). This is much better than using one of these heavy-scripted client-side solutions!
- High performance, with near-zero additional load on the back-end. Especially in combination with a caching solution this does not affect your page load time at all.
- Line numbering (only if you want to). No displacements between code line and line number. Numbers are not copied in most browsers.
- I have tested the default style with more than 20 themes, including Twenty Ten to Fifteen.
- If you do not like the default style: just provide your on CSS file. Styles are highly & easily configurable.
- Per-block styles: each code block on a single web page can be designed on its own, if that is something you need to do.
- Clean, small and valid HTML output. That’s super-important!
- Clean and well-documented source code, using modern WordPress API calls.
- Well-maintained for several years already, and I’ll continue to provide support.
- This is based on GeSHi, a reliable and well-established PHP highlighting engine, used by popular forum softwares such as phpBB or wiki applications such as Dokuwiki or MediaWiki.
- Stability, performance and security are inherited from GeSHi. And I’ll continue to merge in upstream changes.
WP-GeSHi-Highlight works as a drop-in replacement for WP-Syntax, which does not seem to be maintained anymore. Make the switch, it should just work (let me know how it went)!
Bear in mind: do not use the visual post editor. Use the raw editor instead. There, insert code blocks as canonical
pre blocks, and use the
lang argument to define the language of the code snippet:
<pre lang="languagestring"> CODE </pre>
A short example for the
<pre lang="bash"> $ dd if=/dev/zero of=image.ext3 bs=1M count=10000 oflag=append conv=notrunc </pre>
This is all you need to do. Right, it is that simple! Isn’t that cool?
Many websites have used this plugin for years, and it seems to serve its purpose very well. Most issues so far were style-related. If you find an issue, please let me know: drop a mail or leave a comment.
• Theme compatibility of the default style sheet:
The default style sheet was tested with recent versions of all official themes (Twenty Ten to Twenty Fifteen), and with a large range of non-official themes such as Vantage, Customizr, ColorWay, Zerif Lite, Responsive, Storefront, Virtue, evolve, Make, Sparkling, Spacious, Enigma, Sydney, Point, Interface, SinglePage.
Certain themes might define styles with a high specificity that negatively affect the visual code block appearance. It is difficult to impossible to anticipate all these cases in advance, so I expect this to happen in rare cases (the past has proven that these things happen). So, I need you to look out for these situations, and please report them!
- Upload the
wp-geshi-highlightdirectory to the
- Activate the plugin through the plugins menu in WordPress.
- Use it.
Please have a look at the plugin’s website.
I cannot see any change in my html or text editor!
Contributors & Developers
“WP-GeSHi-Highlight — simple, fast, and reliable syntax highlighting” is open source software. The following people have contributed to this plugin.Contributors
Interested in development?
- Enhance compatibility of the default stylesheet with a large range of themes by increasing the specificity of certain CSS selectors and by adding more style directives. This ensures a better out-of-the-box experience. Thanks to Pascal Krause for reporting an incompatilibity with Twenty Ten.
- Increase compatibility with CDNs: fix double slash appearing in CSS file URL.
- Remove redundant call to
- Change style sheet ID prefix, add newline characters to GeSHi CSS code output.
- Improve code documentation and readability.
- Update GeSHi to 22.214.171.124 (language file updates).
- Improve default CSS (add box-shadow:none to pre block, override external setting).
- Use plugin_dir_path/url() instead of obsolete WP_PLUGIN_DIR/URL constants (improve compatibility with HTTPS-driven websites).
- Remove obsolete screenshot from release.
- Minor code cleanup.
- Update GeSHi to git state of 2014-04-16 (tons of language updates).
- Largely improve default style, for compatibility with modern browsers.
- Adjust default style for compatibility with Twentythirteen theme.
- Remove GeSHi’s hard-coded font-size and line-height code styles.
- Reduce box shadow and border radius in default style.
- Slightly increase top and bottom padding in default style.
- Improve default stylesheet: make use of CSS3 box shadows, several tweaks.
- If the code block style file is found in the theme style directory, it now has priority over the one in the plugin directory.
- Update GeSHi to 126.96.36.199 (numerous language file updates).
- Include GeSHi language file for nginx configuration files (taken from GeSHi SVN revision r2572, to be released with 188.8.131.52).
- Use wp_enqueue_style method for style sheet inclusion.
- Deactivate GeSHi economic mode when printing style sheet.
- Do not print credits to HTML source anymore.
- Fix collision with other plugins including their own version of GeSHi (thanks to Bas for reporting).
- Fix line-spacing bug when displaying code blocks with different line numbering settings on the same page (thanks to Bas ten Berge for reporting).
- Update GeSHi to 184.108.40.206 (“Some minor parser tweaks and fixes to existing language files. It adds 15 more languages.”).
- Optimize: now, CSS code is only printed once if the same language is used for multiple code blocks on the same page.
- Minor code changes.
- Fix: comments are not always showing up (thanks to Uli for reporting).
- Minor code changes.
- Remove beta tag.
- Fix: highlight in comments not always showing up.
- Initial release.