Revision [8477]

This is an old revision of FormatterInfo made by OnegWR on 2005-05-25 20:38:48.

 

WikkaDocumentation Wikka Documentation

How Formatters work and why it is easy to write your own

The formatter is in charge of converting wiki syntax into HTML output.

If you wrap a block of text in double percent signs, you can display the content in another format/Layout.
 

Use(r) point of view


Included formatters in Wikka 1.1.6.0:
Usage:
%%(ini)
[title section]
key1=var1
key2=var2%%
[title section]
key1=var1
key2=var2



Programmer point of view


What php-code is used?
How do we get there?
Code examples
  1. preg_replace patterns in $text: formatters/ini.php
<?php
/**
 * INI language file for Wikka highlighting (configuration file).
 */


$text = htmlspecialchars($text, ENT_QUOTES);

$text = preg_replace("/([=,\|]+)/m","<span style=\"color:#4400DD\">\\1</span>",$text);
$text = preg_replace("/^([;#].+)$/m","<span style=\"color:#226622\">\\1</span>",$text);
$text = preg_replace("/([^\d\w#;:>])([;#].+)$/m","<span style=\"color:#226622\">\\2</span>",$text);
$text = preg_replace("/^(\[.*\])/m","<strong style=\"color:#AA0000;background:#EEE0CC\">\\1</strong>",$text);
print "<pre>".$text."</pre>";

?>

  1. Do something with every line in the block:
<?php
foreach(split("\n", $text) as $n => $line){
    if(preg_match("/^\s*$/",$line)) continue; // ignore empty lines

    // process $line here...
 
}
?>



CategoryDocumentation
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki