Revision history for FormatterInfo


Revision [22794]

Last edited on 2016-05-20 07:38:42 by NilsLindenberg [Replaces old-style internal links with new pipe-split links.]
Additions:
This page can now be found on the [[Docs:FormatterInfo | Wikka Documentation Server]].
An archive of [[http://wikkawiki.org/FormatterInfo/revisions | old revisions of this page]] is still available for reference.<<
Deletions:
This page can now be found on the [[Docs:FormatterInfo Wikka Documentation Server]].
An archive of [[http://wikkawiki.org/FormatterInfo/revisions
old revisions of this page]] is still available for reference.<<


Revision [17998]

Edited on 2008-01-27 02:34:53 by NilsLindenberg [Migrated to doc server]
Additions:
<<===This page has moved===
This page can now be found on the [[Docs:FormatterInfo Wikka Documentation Server]].
Thanks for updating your bookmarks!
An archive of [[http://wikkawiki.org/FormatterInfo/revisions
old revisions of this page]] is still available for reference.<<
CategoryMigratedDocs
Deletions:
[[WikkaDocumentation Wikka Documentation]]
====What are formatters and how do they work?====
//The formatter is in charge of converting wiki syntax into HTML output.//
>>**See also**
- [[FormatterDevInfo Explanation for developers]]
- [[WantedFormatters Wanted Wikka formatters]]
- SyntaxHighlighter
- GeSHi -WikkaGeshiIntegration
>>
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:==
- Native:
- code - wraps the the block in <pre> </pre> tags, show as plain text.
- email - add every reply in another color.
- ini - highlighting for ini-file format.
- php - based on the [[http://php.net/highlight_string PHP highlight_string function]].
- wakka - this is the code behind the function $this->Format and is responsible for translating the wiki-code into html-code.
- [[ThirdPartyInfo 3rd Party]]:
- GeSHi - see SyntaxHighlighter for a list of all supported syntax.
- (SafeHTML can also be seen as a formatter of safe html code, but is accessed by wrapping the code in double-double-quote signs. )
==Usage:==
- ""%%(formatter[;line-number]) code %%""
- Example:
%%(ini)
[title section]
key1=var1
key2=var2%%
- Result
%%(ini)
[title section]
key1=var1
key2=var2%%
CategoryDocumentation


Revision [8741]

Edited on 2005-05-31 12:13:12 by NilsLindenberg [copied part about development to FormatterDevInfo]
Additions:
====What are formatters and how do they work?====
- [[FormatterDevInfo Explanation for developers]]
- GeSHi -WikkaGeshiIntegration
Deletions:
====How Formatters work and why it is easy to write your own====
- GeSHi - WikkaGeshiIntegration
===Programmer point of view===
==What php-code is used?==
- In the above example the "ini" formatter was selected, so the file ##formatters/ini.php## was included.
- Within this script you have access to a variable $text, a string that contains the code, content of the block.
- Within the formatter process $text (mostly string manipulations) and print the result to stdout.
- note: the ";line-number" is for the moment only used in the GeSHi code.
==How do we get there?==
- When you display a normal page, the default ##handlers/page/show.php## handler will call at some point $this->Format($this->page["body"], "wakka") which includes the ##formatters/wakka.php## code.
- Within ##formatters/wakka.php## the ""%%(formatter[;line-number]) code %%"" is detected and
- In " else if (preg_match("/^%%(.*?)%%$/s", $thing, $matches)) " a new call to $wakka->Format($code, $language); is made.
- $language = "ini" in this example and $code is our content (and will become $text).
==Code examples==
1) preg_replace patterns in $text: ##formatters/ini.php##
%%(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)<?php
foreach(split("\n", $text) as $n => $line){
if(preg_match("/^\s*$/",$line)) continue; // ignore empty lines
// process $line here...

}
?>%%


Revision [8477]

The oldest known version of this page was created on 2005-05-25 20:38:48 by OnegWR [copied part about development to FormatterDevInfo]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki