Request

Patch to insert line-breaks into a table

Summary

open
Oct 5, 2007
Oct 5, 2007 / mikecrowe
May 16, 2008 / pixtur
cody-somerville
 

Attached files

No files uploaded
 
I needed the ability to have multi-line tables. Other wiki's use \\ to designate a table break. I patched render_wiki.php as follows to provide the same functionality.

Comments to mike.at.mikeandkellycrowe.dot.com

diff -r c3211ac211ed render/render_wiki.inc.php
--- a/render/render_wiki.inc.php        Wed Sep 12 15:49:26 2007 -0400
+++ b/render/render_wiki.inc.php        Fri Oct 05 14:09:10 2007 -0400
@@ -565,6 +565,29 @@ class FormatBlockMonospaced extends Form
 
 
 
+
+class FormatBlockBrs extends FormatBlock
+{
+    public function renderAsHtml()
+    {
+        return $this->str;
+    }
+
+    static function parseBlocks(&$blocks)
+    {
+        $blocks_new= array();
+
+        foreach($blocks as $b) {
+
+            if($b->str && !($b instanceof FormatBlockCode)) {
+               $b->str = str_replace("\\\\","<br>",$b->str);
+            }
+            $blocks_new[]=$b;
+        }
+        return $blocks_new;
+
+    }
+}
 
 class FormatBlockSub extends FormatBlock
 {
@@ -1708,7 +1731,8 @@ class FormatBlockTable extends FormatBlo
 
                 $cell_blocks= FormatBlockLink::parseBlocks($cell_blocks);
                 $cell_blocks= FormatBlockHref::parseBlocks($cell_blocks);
-                $new_cells[]=  FormatBlockItemId::parseBlocks($cell_blocks);
+                $cell_blocks= FormatBlockBrs::parseBlocks($cell_blocks);
+               $new_cells[]=  FormatBlockItemId::parseBlocks($cell_blocks);
 
             }
             $this->line_cells[]= $new_cells;

2 Comments

guest:Great

11 years ago -

How timely. I was just looking for this feature today. Patch works great. Thx,

mel

pixtur:Excellent...

10 years ago

This patch should be added to the trunk.