simplifications
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sat, 29 Jan 2005 23:03:56 +0000 (23:03 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:56 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-412

include/wiki.inc.php

index 23a1595..83c0474 100644 (file)
@@ -316,15 +316,15 @@ class XOrgWikiToText
 
     // {{{ function _render
     
-    function _render($AST, $idt, $list, $first)
+    function _render($AST, $idt, $list, $fst)
     {
         $res = '';
-        if (strpos('|br|div|p|pre|h1|h2|h3|li|', "|{$AST->type}|")!==false && !$first) {
+        if (strpos('|br|div|p|pre|h1|h2|h3|li|', "|{$AST->type}|")!==false && !$fst) {
             $res .= "\n$idt";
         }
         if ($AST->type == 'ol' || $AST->type == 'ul') {
             if ($list) {
-                $res .= "$idt";
+                $res .= $idt;
             } else {
                 $list = true;
             }
@@ -343,15 +343,10 @@ class XOrgWikiToText
             return "[{$AST->attrs['src']}]";
         }
         foreach ($AST->childs as $val) {
-            $first = false;
-            if (is_string($val)) {
-                $res .= $val;
-            } else {
-                $res .= $this->_render($val, $idt, $list, $first);
-            }
+            $fst  = false;
+            $res .= is_string($val) ?  $val : $this->_render($val, $idt, $list, $fst);
         }
-        if (strpos('|br|div|p|pre|h1|h2|h3|li|', "|{$AST->type}|")!==false) {
-        } elseif ($AST->type == 'u') {
+        if ($AST->type == 'u') {
             $res .= '_';
         } elseif ($AST->type == 'em') {
             $res .= '/';