Renderer plugins aka. pluggable renderers, allow to implement different rendering mechanisms for DokuWiki. DokuWiki parses Wiki syntax into an instruction array which then is “rendered” to the desired output format. This output format is usually the XHTML to display a nicely formatted Wiki page. Pluggable renderers allow plugin authors to write their own renderer to output any format they want.
A Renderer Plugin example needs to define a class named renderer_plugin_example which extends Doku_Renderer1) or one of it's subclasses. The class needs to be stored in a file called lib/plugins/example/renderer.php.
You need to implement all methods of the Doku_Renderer class to implement full output of all DokuWiki's markup.
There are two mechanisms for calling a renderer plugin.
All renderers can be accessed through the export command. This is primarily used to export wiki pages to usually non-xhtml formats.
The output of the plugin is accessed by appending do=export_<plugin_name> to the page URL. Eg. http://www.mywiki.com/doku.php?id=somepage&do=export_s5 or with URL rewriting, http://www.mywiki.com/somepage?do=export_s5.
To make the plugin's export mode accessible to the wiki user, add a button or link somewhere using a syntax plugin or action plugin. To create the correct link you should use the exportlink function.
When your plugin creates a different output format than text/html, you need to set all needed HTTP headers in the metadata of the page. This is best done in the document_start method of your renderer. Here is an example from the ODT plugin:
$headers = array( 'Content-Type' => 'application/vnd.oasis.opendocument.text', 'Content-Disposition' => 'attachment; filename="'.noNS($ID).'.odt";' ); p_set_metadata($ID,array('format' => array('odt' => $headers) ));
Typical examples of export renderer plugins are
The renderer_xhtml configuration setting allows you to replace DokuWiki's default renderer with your own. Only xhtml renderer plugins should be used for this. Also it's only possible to have one render at a time with this method. For example you have to choose between noblankcells and purplenumbers.
Plugins which wish to use this method should also implement the canRender() method:
function canRender($format) { return ($format=='xhtml'); }
This method allows DokuWiki to list the plugin in the options for renderer_xhtml setting on its configuration page.
Don't forget to mention the renderer_xhtml setting on the plugin page.
A typical example of a replacement renderer plugin is