Table of Contents

Code Prettifier Plugin

Compatible with DokuWiki

  • 2017-02-19 "Frusterick Manners" yes
  • 2016-06-26 "Elenor Of Tsort" yes
  • 2015-08-10 "Detritus" yes
  • 2014-09-29 "Hrun" yes

plugin syntax highlighting of source code snippets in wiki page using google-code-prettify (javascript module with CSS files)

Last updated on
2017-11-05
Provides
Syntax
Repository
Source
Conflicts with
syntaxhighlighter4

Installation

Install the plugin through the Extension Manager or Plugin Manager using the download URL above, which points to latest version of the plugin. Refer to plugin installation instructions.

Note: After updated to 2015-09-12 release, you can remove older “google-code-prettify” subfolder in this plugin directory.

Feature

This plugin enable syntax highlighting of code snippets in your page using Javascript code prettifier (former “google-code-prettify”). This plugin package includes subset of Javascript code prettifier, they are separately licensed under the Apache License, Version 2.0

Examples/Usage

<Code:php linenums:1 |Example #1 Our first PHP script: //hello.php//>
<html>
  <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php echo '<p>Hello World</p>'; ?> 
 </body>
</html>
</Code>

Example #1

Configuration and Settings

Config key Description
override override DokuWiki built-in syntax <code> for Code Blocks.
url_loader url of prettify loader (default blank)
:!: obsoleted since 2015-09-12 release
url_prettify_handlers Base URL for prettify.js and optional language handler scripts
ex: https://cdn.rawgit.com/google/code-prettify/master/src/
(default blank)
:!: available in 2015-09-12 release
url_prettify_skins Base URL for color theme for code-prettify (css)
ex: https://cdn.rawgit.com/google/code-prettify/master/styles/
(default blank)
:!: available in 2015-09-12 release
lang_handlers additional langage handler (comma separated)
skin color theme/skin for code-prettify (CSS filename in code-prettify/styles/)

Detail information of the Javascript code prettifier is available from:

This plugin package contains some skins those found in Prettify Themes Gallery. You may set one of following css filename in the skin field.

Other color themes for Prettify will be found at http://jmblog.github.io/color-themes-for-google-code-prettify/

Development

Change Log from github repository

ToDo/Wish List

FAQ

Non-highlight code block

use <Code:none> or <Code lang-none> to prevent highlight code. Maybe useful to show error log output or console output.

<Code:none>
This is not any kind of code.
</Code>

Known Bugs and Issues

see also: https://github.com/ssahara/dw-plugin-codeprettify/issues

Discussion

Using current dokuwiki theme and prettifyer with <Code linenums> does print a linenumber only on every fifth. line.

To solve just add .prettyprint ol.linenums > li { list-style-type: decimal; } to lib/plugins/codeprettify/all.css