DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:exttab1

Extended Table Syntax Plugin

Compatible with DokuWiki

2006-11-06 and later

plugin Mediawiki style tables inside DokuWiki

Last updated on
2013-03-23
Provides
Syntax
Repository
Source

Similar to exttab2, exttab3

Tagged with mediawiki, tables

After I saw that the wish for the Wikimedia way of table syntax became so urgent that there was even a bounty given to to its adoption ;-) to DokuWiki – and I want to use this syntax by myself, too – I finally decided to give it a try. Here you see the result. I did not do so much – just visited http://www.mediawiki.org/wiki/Help:Tables and modified my code after each sample so that the result looked like a table ;-).

Anyone feel free to modify the code – and please tell me what and why you did so that I can be happy about these modifications in my own wiki :-) Werner Flamme 2006-10-16

I added the code at github.com to offer better access. Maybe someone still uses this plugin instead of the (better working) exttab2 ;-) Werner Flamme 2013-03-23

Example

When you want to see the results (on a sample page) in my wiki: look at my wiki.

Source

You see the source code on page exttab1:source.

Installation

Just

  • create the folder lib/plugins/exttab1/
  • and copy the source code to lib/plugins/exttab1/syntax.php

Or use the plugin manager and enter the URL mentioned at the top of this page

Usage

Infos about the supported syntax can be found in http://www.mediawiki.org/wiki/Help:Tables.

You may use the syntax mentioned on that MediaWiki page when you put an <exttab1> tag before and an </exttab1> tag behind your code. DokuWiki will not recognize the foreign table syntax without those tags!

If I try to put H1…H6 into the tables, the formatting chaos will overwhelm me ;-). Hunting for the correct nesting of HR, TD, and CAPTION tags was quite a game… Maybe the fact that the alignment does not always work correctly is caused by the template. Following the produced code it should be aligned correctly :-/ BTW, you should add some formatting info into the CSS files you use for the caption item, it won't look nice without. In the meantime, I added class=“exttab1” to the <table> tag to have a difference between DokuWiki's standard tables and the extended ones. But I still did not write the corresponding CSS tags :-( lazy me! FIXME

Warning

Please be careful with this plugin! When you use the formatting abilities, these pieces of HTML or CSS are neither parsed nor checked. The plugin trusts you to write clean code! ;-) The plugin just looks whether there are 2 parts of the line – if yes, the first part is used as formatting info, and the second becomes content. When you mix it up, you may get strange looking pages :-/

And: I plan not to change this, because it will slow down the rendering process enormously…

Updates

Today I extended the code to insert <thead> and <tbody> tags at the right places. — Werner Flamme 2006-12-02 15:30 CET

Discussion

Werner, is there any way that normal dokuwiki syntax would work from within the tables? Currently only HTML seems to work. For example, the following is not functional:

{| width=80% align=center
|align=center|[[page|{{wiki:dokuwiki-128.png}}]]
|}

Eric-Sebastien Lachance 2006-10-17 05:44 EST

Eric-Sebastien, I am sorry, but the type of the plugin (protected) does not allow DokuWiki to scan inside the code that is coming back from the plugin. Maybe it works when the type is 'container' (see Syntax Plugins), I will look for it soon. — Werner Flamme 2006-10-19 20:13 CEST
Correcting myself (or being more precise): your example works with the 2 modifications of the code I just added: first, function getType() returns 'container' instead of 'protected', and second I allowed 2 modes inside the container by adding function getAllowedTypes(). I think I finally got the sense of Syntax Plugins :-) Werner Flamme 2006-10-19 20:43 CEST
I am sad :-( – making your example work causes that the data passed to the plugin is pre-rendered. It is not rendered afterward. The allowed type 'substition' causes your example picture to be displayed, but all the table code vanishes. The allowed type 'formatting' works not in the sense I would like – in the last example there is ''Food complements''. This text appears, but the table disappears. Taking away the '' marks causes the display of the table and of the text. Writing ** marks instead has those ** marks displayed along with the text :-(… Finally I'd say you must decide if you want MediaWiki's table syntax or DokuWiki's features :-( I see no way to put the together – unless I find a way to have “code snippets” parsed by DokuWiki initialized from inside the plugin. — Werner Flamme 2006-10-19 21:23 CEST
Hopefully this is the last remark ;-). Sometimes one gets the best results when sleeping ;-)… I added a function _parseDisplayData that uses DokuWiki's rendering engine to parse elements of text. Because this really slows down the wiki, there is a variable $allowedTags where one can store the signalling tags for parsing. When (at least) one of these tags is found, the data is parsed, otherwise the function returns the data unchanged. At least on my test page I get the original samples as well as the sample from Eric-Sebastien :-) Werner Flamme 2006-10-20 07:39 CEST
Awesome, Werner, that works great! Really nice job there. I know there's already a bounty on this plugin, but I want to add to it, since you kindly fixed this critical problem for me. Just send me an email with PayPal info, I'll send ya a little something! But, just so you know, I got the following warning from PHP on my own installation (admittedly, I have ~E_ALL in my php.ini for the error display, this wouldn't happen in a production environment):
Warning: Call-time pass-by-reference has been deprecated - argument passed by value;
 If you would like to pass it by reference, modify the declaration of p_render().
 If you would like to enable call-time pass-by-reference, you can set
 allow_call_time_pass_reference to true in your INI file. However, future versions may not
 support this any longer. in D:\Web\dokuwiki\lib\plugins\exttab1\syntax.php on line 284

Eric-Sebastien Lachance 2006-10-23 3:58 EST

Thank you Eric-Sebastien 8-o. The warning you show is a good example of the internal changes of PHP. In order to always provide enough work for PHP programmers ;-), the PHP coordinators create new standards, additional parameters or change some conventions. Like “Call-time pass-by-reference has been deprecated”. I think to avoid this, you have to have a “version switch” for PHP 8-) since old versions may not support the new methods :-( Werner Flamme 2006-10-24 09:51 CEST
You can also just put an '@' before p_render. Doesn't solve the problem, but suppresses the 5 lines of warning on each page ;-)konstantin baierer 2006-12-16 21:01
I removed the ampersand sign in the p_render function call in the github version… — Werner Flamme 2013-03-23 11:16 CET

Thanks for the useful plugin. I've found that backlinks are not detected for links inside an <exttab1> tag — Brad Schick 2006-11-14 0:33 PST

Brad, that is correct since the content of <exttab1> tags is hidden from DokuWiki's view (by selecting protected in function getType()). I do not want to change this – I had some experiments before ;-) Werner Flamme 2006-11-14 12:12 CET

Plugin not working with (2006-11-06) version of DokuWiki.

Hi anonymous user, would you please give some details? The plugin worked with the devel versions before this stable version and it works with the current devel. So I am curious why it will not work with DokuWiki-2006-11-06. Any errors in apache.log, phperror.log or elsewhere? — Werner Flamme 2007-02-01 13:20 CET

I installed the plugin as described and it shows correctly on the plugin-page of my DokuWiki. But the only thing I see are some of the first letters in plain text i.E. {| The rest is omitted. My test-case:

{|
|Orange
|Apple
|-
|Butter
|Ice cream 
|}

I'm using the current stable xampplite-win32-1.6.0a under WinXP SP2. I've tried it with the stable DokuWiki 2006-11-06 and with the newest dev-snapshot of Dokuwiki 2007-03-14: Both return the same bogus way. Nothing shows up in the error.log of apache, unfortunately I can't seem to bring xampp to write a phperror.log. Contact me if you want me to test something. — MadMike 2007-03-14 13:07 CET

Mike, did you put the <exttab1>….</exttab1> tags around your sample? When I use your lines from {| to |} inside those tags, I get a table with 2 cols and 2 rows as expected (current devel). BTW, when I edit /opt/lampp/etc/php.ini (%program files%/xampp/etc/php.ini for you?), I get a php error log (look for the line reading ;error_log = filename, change it to error_log = c:/log/xampp_php.log (for example) and restart xampp). — Werner Flamme 2007-03-14 14:37 CET
Nope, I didn't use <exttab1>….</exttab1>. Now that I'm looking through your usage section, I can spot what I missed. So much time wasted for nothing :-(. Maybe the instructions should mention <exttab1>….</exttab1> more prominently at the beginning of the section? But in the end still blaming myself for not RTFUS (… usage section) ;-)MadMike 2007-03-15 17:21 CET

I tried your plugin and it works, but when I open the page with Firefox Browser, the Table will not display centered. align=“left” and align=“right” will work but not align=“center” With IE Browser it will be ok :?:Heiko 2007-06-18 09:13 CET

Heiko, I can confirm that align=“center” sometimes does not work with Firefox. I get no errors by HTML Validator (http://www.html-validator.org/), so I do not know where to search. Maybe this is because of the CSS properties of the parent element? I do not rely upon IE to display (X)HTML correctly 8-) The syntax seems to be OK. Since I use Linux, I cannot test IE – but I am not sad about that ;-)Werner Flamme 2007-06-18 22:31 CEST

Hello. Is their any way to include either multiple paragraphs or lists inside a cell? That's a feature I'd really like to have as it opens up a whole new world of organization. I'm asking this hear because I think it would be a great addition to the plugin if possible. Hitchcock

Hitchcock, AFAIK this will not work. Following the way the data is parsed, I must look for the first character in a line. If this is not a “table formatting” character (but e. g. a blank or some letter for a new paragraph), I cannot convert it into a table cell because I can't do a look-forward. And allowing special markups inside a cell will slow down the rendering of the page significantly.

Maybe you find a way to work it out – you're welcome ;-)Werner Flamme 2007-07-04 09:46 CEST

Hello, First nice work. but i get a problem with the the links working where i set my own name e.x. localhost but http://127.0.0.1 works fine. greets — Jan-Philipp Warmers 2007-07-05 14:25

Thanks :-) Jan-Philipp, this is because of the separator: The | separates the “dirty” URL from the “nice” Text to be shown. But it also separates (in MediaWiki's table syntax) the content of a cell from its formatting. I do not know how to make a difference between those cases inside the code. :-(Werner Flamme 2007-07-05 15:01 CEST

I appear to have found a generation problem in the syntax.php function _handleHeaderLine($linedata) line ~277 (my source lines might not match). In this function strpos($pick, '|', 1)) is called when it should use strpos($pick, '!', 1)) otherwise misses format information and assumes it is part of the content string. This looks like a copy 'n paste bug. example failing code

{|
!class="test1"!test
!test1
|}

will generate code with the class in the text block instead of in the column header format block. (sorry, not an HTML programmer so not sure what you call it)
verci 2007-07-30 23:00 CEST

Hi verci, AFAIK the HTML source and the content are separated by | and not by !. As I say in the Warningabove, be careful what you write ;-). I think your piece of code will work when you replace the 2nd ! in the 2nd line by a |. At least in the current version this is necessary. I just left hospital and at the moment I'm not capable to modify the code since I do not understand what I wrote then ;-)Werner Flamme 2007-07-31 15:35 CEST

Hello, I have used your code for a while. I like it, but it doesn't handle some dokuwiki syntax very well (footnote, image link with alt …). So I decided to write a new one. Please have a look at exttab2.
disorder chang 2007-10-04 20:50 Taiwan

Hi disorder chang, you did much better work than I did! Congratulations! And thank you for taking my code as footstep ;-)Werner Flamme 2007-10-07 12:47 CEST

Hi! is there a possibility to have multiline cells in the table? I tried linebreaks after | but it only shows the first line (works in Wikimedia). — Benny Wegner 2008/07/02 11:33

Hi Benny, I'm sorry :-( but it is not. I'm parsing the input line by line, so this won't work. Maybe you better try the exttab2 plugin? Or you try to include the linebreak signs (double backslash) in function __parseDisplayDat by adding them to $allowedTags (maybe as quad backslash) — Werner Flamme 2008-07-03 11:25 CEST

Hello Werner, I have released the exttab3 plugin which has further developed from exttab2. There is indeed no new additional feature in extended tables, of which mediawiki-like syntax is fully translated to call instuctions in the handle() method in the exttab3. The render() method simply converts those instructions to table html. This approach might be consistent better with DokuWiki parser process. — s.saharas.sahara

Makuhari, Chiba, Japan
2014/03/31 12:29

Hi, thank you very much! Your plugin looks good, I'll see if I can use it on my own site :-)Werner Flamme 2014/03/31 17:43 CEST
plugin/exttab1.txt · Last modified: 2014/03/31 17:43 by 2001:4dd0:ff00:8eb9:41d0:2b0e:d025:a13