DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:codeprettify

This is an old revision of the document!


Code Prettifier Plugin

Compatible with DokuWiki

Hrun

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

Last updated on
2015-01-24
Provides
Syntax
Repository
Source
Conflicts with
syntaxhighlighter4

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to highlightjs, jquery-syntax, syntaxhighlighter3, syntaxhighlighter4

Tagged with code, syntaxhighlight

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.

Feature

This plugin enable syntax highlighting of code snippets in your page using google-code-prettify. This plugin package includes minified .js files of google-code-prettify, they are separately licensed under the Apache License, Version 2.0

  • You can configure Code Prettifier plugin to override DokuWiki built-in syntax <code> for code blocks.
  • you may use skin (css file) for code block.

Examples/Usage

  • Enclose code snippets using <Code> and </Code> tag to show it pretty-printed in wiki page.
  • Google-code-prettify module makes a best effort to guess the language but works best with C-like and HTML-like languages.
  • To specify language hint for Prettify, you can use
    1) <Code:ext> (file extension, you must put it just after “Code:” keyword) or
    2) <Code lang-ext> option.
  • For example, use <Code:css> or <Code lang-css> to specify that the code is Cascading Style Sheets(CSS).
  • use linenums option to turn on line numbering. To specify start line number, you can add a colon and the number to the end of the option, eg. linenums:12.
  • If you want to add title for code block, you can specify it after | that will be shown just above the code box.
<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 google-code-prettify loader (default blank)
lang_handlers loader parameter for additional langage handler (comma separated)
skin loader parameter for skin (CSS filename in google-code-prettify/skin/)

Detail information of the google-code-prettify 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.

  • desert.css
  • doxy.css
  • sons-of-obsidian.css
  • sunburst.css

Development

Change Log from github repository

ToDo/Wish List

  • Collapse/Expand Code Feature

FAQ

Known Bugs and Issues

Discussion

plugin/codeprettify.1437601385.txt.gz · Last modified: 2015-07-22 23:43 by 90.146.140.162

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki