WikiRenderer

français

Using Wikirenderer 3.1

last update: 06/20/2009

Simple use

 include('WikiRenderer.lib.php');
 $wkr = new WikiRenderer();
 $myXHTMLText = $wkr->render($myWikiText);

By default, it uses the rule "wr3_to_xhtml". This is why the output is in XHTML. If you want to use an other rule, for example "dokuwiki_to_xhtml":

 include('WikiRenderer.lib.php');
  include('rules/dokuwiki_to_xhtml.php');

  $wkr = new WikiRenderer('dokuwiki_to_xhtml');
  $myXHTMLText = $wkr->render($myWikiText);

If you want to change the configuration of the rule, you have to change some properties on its configuration class. Example:

 include('WikiRenderer.lib.php');
  include('rules/classicwr_to_xhtml.php');
  $config = new classicwr_to_xhtml();

  $config->simpletags = array('%%%'=>'
', ':-)'=>'<img src="laugh.png" alt=":-)" />', ':-('=>'<img src="sad.png" alt=":-(" />' ); $wkr = new WikiRenderer($config); $myXHTMLText = $wkr->render($myWikiText);

To know wiki errors

It is possible to know if there are some syntax errors in the given wiki content. After the transformation, just check the errors property of WikiRenderer, as shown on this example:

include('WikiRenderer.lib.php');
$wkr = new WikiRenderer();
$myXHTMLText = $wkr->render($myWikiText);

if($wkr->errors){
   echo '<p style="color:red;">There are some syntax errors at lines: ';
   echo implode(',',array_keys($wkr->errors)),'</p>' ;
}

The property errors is an array in which keys are line numbers where an error has been found, and values are the lines themselves.

WikiRenderer don't stop on errors. Bad wiki tags are ignored and appeared in the resulting content.

Configuration

Each rule have its own configuration object which inherits from the class WikiRendererConfig. It have at least this properties:

inlinetags
list of class names of the rule which support "inline" tags (tags used in sentence, a paragraph etc). See development of rules. You can modify this list if you don't support some wiki tag.
bloctags
list of class names of the rule which support "block" tags (tags which introduce a specific block of content, like a list, a table etc..) See development of rules. You can modify this list if you don't support some wiki tag.
simpletags
simple tags which should be replace by a specific string. This is a php array of 'string to replace'=>'new string'.
checkWikiWordFunction
Should be the name of the function called when WikiRenderer find some "CamelCase" words. This function receive an array of CamelCase work, and should return corresponding strings which will replace the CamelCase words. There is no default function for this, since this is specific to your website. Keep it to null if you don't want to support CamelCase detection.

Other documentations