final move of files
[web.mtrack] / MTrack / Wiki / OneLinerFormatter.php
1 <?php
2
3 require_once 'MTrack/Wiki/HTMLFormatter.php';
4
5 class MTrack_Wiki_OneLinerFormatter extends MTrack_Wiki_HTMLFormatter {
6   function format($text, $escape_newlines = false) {
7     if (!strlen($text)) return;
8     $this->reset();
9     $in_code_block = 0;
10     $num = 0;
11     foreach (preg_split("!\r?\n!", $text) as $line) {
12       if ($num++) $this->out .= ' ';
13       $result = '';
14       if ($this->in_code_block || trim($line) == MTrack_Wiki_Parser::STARTBLOCK) {
15         $in_code_block++;
16       } elseif (trim($line) == MTrack_Wiki_Parser::ENDBLOCK) {
17         if ($in_code_block) {
18           $in_code_block--;
19           if ($in_code_block == 0) {
20             $result .= " [...]\n";
21           }
22         }
23       } elseif (!$in_code_block) {
24         $result .= "$line\n";
25       }
26
27       $result = $this->_apply_rules(rtrim($result, "\r\n"));
28       $this->out .= $result;
29       $this->close_tag(null);
30     }
31   }
32 }