A WordPress plugin for syntax highlighting using Pygments, though Pygments is not required to be installed.
By default, Pygment It will auto discover if Pygments is installed (through command -v pygmentize
). If not, it will use http://pygments.appspot.com to highlight code (but without support for: highlighted lines, line numbers and line number to start).
Check out in WordPress Plugin Directory. Did you like it? Rate and star it!
Note: this plugin is an improved version this.
- Syntax-highlighted code cached as post metadata
- Admin panel to choose theme, default language and Pygments usage (local, external API or auto discover)
- Multiple themes available (github, monokai, railscasts, mustang, among others..)
- Support for
hl_lines
(highlighted lines),linenos
(line numbers) andlinenostart
(line number to start) when using a local installation of Pygments
- Clone this repo or upload its content to
/wp-content/plugins/
directory - Activate the plugin through the 'Plugins' menu in WordPress
Through code
shortcode.
[code]
# code here
[/code]
Choosing language (all supported languages can be found here):
[code language="ruby"]
# Ruby language syntax highlighting
[/code]
[code language="ruby" hl_lines="2 3"]
class PagesController < ApplicationController
def index
end
end
[/code]
[code linenos="table" linenostart="20"]
# code here
[/code]
This projected is licensed under the terms of the MIT license.