Summary: Display code highlighting using Python pygment
Version: 2016-06-24
Prerequisites: 2.2.58, Python, pygment
Status: Stable
Maintainer: ccox
License: GPL
Categories: Layout
Users: (view? / edit)
Discussion: PmPygment-Talk

Questions answered by this recipe

How can I include highlighted code segments on my wiki?


Displays code highlighting using Python pygment.


Download pmpygment.phpΔ to your cookbook directory and add include_once("../cookbook/pmpygment.php"); to your config.php.


You may set the following variables as needed:

  • PubCacheDir - directory where cached results go (default: pub/cache)
  • PmPygmentPgm - full path to the pygmentize program executable (default: /usr/bin/pygmentize)
  • PmPygmentCacheDir - cache dir (defaults to PubCacheDir)
  • PmPygmentIFrameStyle - css for iframe styling, see code for default.


 (:sourcecode lang=<language>
              [linenos=(true|false)] default: false
              [linenostart=<number>] default: 1
              [hl_lines='num1 num2 ...']
              [height=<value>] default: 100% Note: iframe only
              [iframe=(true|false)] default: false
              [noclasses=(true|false)] default: true Note: false if iframe
 <your source code>

Change log / Release notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See also

Cookbook /
Ape  Easy embedding of videos, maps and more in wiki pages (Stable)
Beautifier  Perform syntax highlighting for source code displayed on wiki pages
CodeMirror  An enhanced page editor for PmWiki (Release Candidate)
Gists  Markup to allow easy embedding of syntax-highlighted github gists (active)
PITS  The PmWiki Issue Tracking System (Beta)
Precode  General utility block markup for displaying codes with syntax highlighting (Active/Stable)
SourceBlock  Source code syntax highlighter for PmWiki 2.x using GeSHi (Stable)
Syntaxlove  Syntax highlighting with good look and cool JavaScript-effects
ZCode  Extract and highlight source code files from 7z, TAR, ZIP, or RAR archives (Experimental)



See discussion at PmPygment-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.