Tables in Wikka

Table markup
(copied from WikkaDevelopment --NilsLindenberg)

Richard Berg has provided code for very simple table code that could be placed in formatters/wakka.php. I think that one weakness that wikka has is the lack of support for any tables. Sure, I know people are thinking about syntax & extended features etc etc (I've contributed to that discussion) but I'd like to suggest that "simple" table support should be provided now if possible. Richard's code builds a table (and keep wikka links and formatting) using....
which is a basal example of code formatting we were thinking of using anyways, so when we do end up supporting tables in a more complex fashion, it should be reasonably simple for users with tables to adapt their previous code to the new code base. Anyways, I'd like to suggest that we add this code into the next release to provide basic table support. --
Editable tables
I don't know if this goes against the Wiki way of doing things, but it would be nice to configure a table in which users could enter data into and then 'submit' (click a submit button I suppose) and have it saved to the page without having to 'edit page'.

Can you post a link to a site where you can enter data without editing the page? I'm not sure what that would look like. - JsnX

GmBowen had something related (I've inserted a link to a screen capture of it in action). I can't seem to get his page to load, therefore I've linked it to its google-cache. Basically, it's a form input thing that allows you to create tables row by row and edit data cell by cell. Very tedious to initialise, (not really, just {{spreadsheet}} starts it, and then you enter rows and columns of data almost like you would in a spreadsheet -- Mike) but i suppose it could be handy just to click on celldata to edit it (and view data if the user has readonly access). This method is a lot more intuitive than the current method of creating tables, but it would involve flatdb (or a new/seperate mysql schema). Just adding to the discussion, I don't believe that this suggestion is the ultimate solution. -- Sam .....this is coming along, but having issues with re-saving with a different name. Functions all work now & refresh automatically. Script works well with individual spreadsheet. Right now, working on it so that user can have one page where all spreadsheets can be managed, and then a user can insert any of their spreadsheets anywhere using an {{inserttable}} action (and you can set function results on or off).....

The "spreadsheet" (or, interactive table if you want) script uses a MYSQL table with the spreadsheet assigned by default to the page name & owner (which has to match the logged in user), although the logged in user can "force" another table name. Another "action" script allows just showing the table without the interactive nature. So the user can enter the table components using the "spreadsheet", and then show it on the page using the "showtable name=" script. The spreadsheet script allows one to calculate sum, average, count, and frequency (at this point only on the columns) and is intended to provide simple on-line spreadsheet functions for kids working on science projects which they can then embed in a written report. I'm moving the server right now which is why it isn't up. It will be in the next week. The script is a (greatly) modified version of one available from this site... .... Because it's intended for kids it is reasonably user friendly, although lacking many formatting abilities that "adult" users are used to -- Mike Bowen

My 2 cents on tables. I think we should consider in the long run the possibility of a major refactoring of the syntax for tabular data. The current table action is extremely user-unfriendly (just have a look at the source of ConfigurationOptions). Moreover, the table action does not convert wikka-formatted strings, which in some cases is a little annoying. It think a nice idea would be to have tables directly handled in the formatter, instead of using an action. I like very much the wacko approach to tables, maybe we could do even better and find a more intuitive syntax. -- DarTar

I haven't checked this out yet, but doesn't UsingHTML pretty much solve the problem on table syntax? Now it's just figuring out how to edit a cell without editting a page. --Sam

If you want to work with individual cells, it sounds like you're thinking about something like this.... ... although it is not open source. Just providing the link for discussion purposes. -- Mike B

Tables were one of the biggest reasons for us wanting to go with Wikka over our existing WakkaWiki. However the syntax as it is right now is pretty unintuitive. Having one giant string of comma separated values just doesn't work for me. It would be nice to at least make it so you can add line breaks between rows. -- Justin F

FlexWiki* has a rich table markup that seems fairly easy to use. See FormattingRules for the basics and TableFormattingRules for the details. I'd like us to adopt at least the basics, and maybe add some of the extended possibilities gradually.
* (MS open source! And with Ward Cunningham apparently working for MS now...)
Picking up on Sam's point....perhaps code written for wikka that does something like this..... -- GmBowen [note: This is a modified version of the linked page which replaces Dave's tablemaking code with the nice blue colors (see comments at bottom of page) with the "freely available" code from without the nice blue colors....and which describes it's code as "The script is yours!" when you access the source shouldn't be any problems now folks]
All that to generate a very basic HTML table (not even a data table)? A good Wiki syntax would probably be easier to understand as well as more efficient for the basics. -- JavaWoman
Like JavaWoman, I use tables frequently, to the point that ugly is better than nothing. I upgraded to Wikka for the inline a longtime user of Wakka, I had concocted just such an ugly hack:
    if( !function_exists('tableize') )
        function tableize($txt)
            $rows = preg_replace('/\|\|(.*)\|\|/', '<tr><td>\1</td></tr>', $txt[0]);
            return '<table border="1">'.str_replace('||', '</td><td>', $rows).'</table>';

    $text = preg_replace_callback("/((?>(?=^\|\|.*?\|\|$)^.*?$\n?)+)/sm", 'tableize', $text);

Unfortunately, inserting it near the bottom of /formatters/wakka.php doesn't seem to work as it did in Wakka, and since I only wrote this with the aid of PHP-literate friends, I have no Wikka solution at this time. A simple regex like this isn't sufficient to develop the extensible syntax seen in FlexWiki, but I have a feeling if someone noticed the (probably obvious) incompatibility that it would be a nice holdover for JW and myself. For the future, I definitely agree that a FW-style syntax is necessary; spreadsheet abilities like in Mike B's link would be orgasmic, even if they represented a completely different feature from regular tables. -- RichardBerg

I've tried inserting this also with no luck. However, it now seems to work quite nicely at Richard's home site. For me, simple to use tables now are much more useful/important than much better tables later (I've got a class using this that I want tabularized time-trial information posted bi-weekly). Can any of the guru's here take a stab at getting this simple approach to tables least "for now"? Thanks. -- GmBowen
It does not actually work at my site either, G. That page was rendered in the Wakka days; if you edited it and clicked 'store,' it would fail just like all my more recent pages. Good news, however -- while the regex above is still illegible to me, I decided to see if I could write my own. Here's a first effort (stick it right before the main preg_replace_callback):
(removed, see below)
The good: it works.
The bad: $wakka->SafeHTML doesn't like it. I'm not sure why -- W3C's validator says the output has no errors -- but for now you have to turn it off.

Also, you must have a blank line after a table!!! (very important)

(I forget whether the previous code had this limitation). I'll see if I can fix these things, but I know GmBowen wanted something quickly. -- RichardBerg
Update: here's a version that goes after the main regex. That makes it even uglier and less extensible, but you can use it without raw HTML (or any HTML setting at all; no safety checks, though it does pass W3C).
// horrible ugly table hack v2.0
if( !function_exists('quicktable') )
function quicktable($txt)
    $temp = $txt[0];
    $temp = "<table border='1'>\n".$temp;
    $temp = preg_replace("/^\|\|(.*?)\|\|\<br \/\>$/m", "<tr><td>$1</td></tr>", $temp);
    $temp = str_replace("||", "</td><td>", $temp);
    $temp = str_replace("<br />", "", $temp);
    $temp = $temp."</table>\n<br />";
    return $temp;

$text = preg_replace_callback("/^\|\|(.*?)\|\|\<br \/\>\n\<br \/\>$/sm", "quicktable", $text);
Hi Richard. Thanks for posting this. Sadly :( I still can't get it working. (i) Do you still have to "turn off" $this->safehtml. If so, how? (ii) could you be more specific wrt where to put the code? I'm assuming formatters/wakka.php is the file to modify, and I tried it in several places at the end of the file, but no luck. Do you have to comment out any other lines? Thanks. -- GmBowen (aka Mike).
Mike, here's the file: - you'll see that safehtml is still enabled (my previous short-circuit is commented out) --RichardBerg
Thanks Richard, works like a charm. What's weird, is I cannot see what is any different than what I did. Oh well, it's working now at least.

For a further addition to the resources here for table markup.....there is a code contribution at by DavidDecotigny that works quite well in wikka (tested in both an earlier and the most recent version) IF $wiki->Format is changed to $wakka->Format in the code....and it's quite easy to add the code to wikka (it took me 10 minutes to install it and get it working, and that includes figuring out the small code change necessary). (Note: David didn't leave any instructions for copyright in his code, so I'm not comfortable posting it here.) -- GmBowen

There are 13 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki