last update: 06/20/2009
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);
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.
Each rule have its own configuration object which inherits from
the class WikiRendererConfig
. It have at least this properties:
inlinetags
bloctags
simpletags
'string to replace'=>'new string'
.checkWikiWordFunction
null
if you don't want to support
CamelCase detection.