tormodh's wiki : WikiFormatterHightlighter

Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Wiki formatter highlighter


Example


Wikka Code

|=|Header|=|Says||
||I'm||Awesome||

Parsed to (this is it!)

<table class="data">
<tbody>
<tr><th>Header</th><th>Says</th></tr>
<tr><td>I'm</td><td>Awesome</td></tr>
</tbody>
</table>


Rendered as

HeaderSays
I'mAwesome
This is a highlighter that parses wikka markup, and then displays the resulting html code with GeSHi's html4strict highlighter.

The formatter is as follows, call it wiki2html (or something else) and it is then callable by %%(wiki2html)...%% or whatever you called it.

The strange '%'.'%' below is to avoid breaking out of the highlighter before I want to.
Exchange them with '%%(html4strict)'.$temp.'%%' in the file for righteousness! ;)

<?php
/**
 * Highlighter for produced html from wikka code.
 *
 * @package     Formatters
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @filesource
 *
 * @uses        Wakka::Format()
 */

$temp = $this->Format($text);
$this->Format('%'.'%(html4strict)'.$temp.'%'.'%');
?>


In addition you need to change the wakka formatter for code highlighting in order to avoid double grab buttons (near line 725 in formatters/wakka.php).

This should change nothing, except for wikka highlighters that uses Wakka::Format() - and then you're out sailing already ;)

                        // check Wikka highlighter path is set and if we have an internal Wikka highlighter
                        elseif (isset($language) &&
                                        isset($wakka->config['wikka_formatter_path']) &&
                                        file_exists($wikka_hi_path.DIRECTORY_SEPARATOR.$language.'.php') &&
                                        'wakka' != $language)
                        {
                                // use internal Wikka highlighter
                                $temp = '<div class="code">'."\n";
                                $temp .= $wakka->Format($code."\n", $language);
                                $temp .= '</div>'."\n";
                                if ($output == '') $output = $temp;
                                else return $output;
                        }
There are no comments on this page.
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 1.3501 seconds