Skip Menu |

This queue is for tickets about the HTML-WikiConverter-MediaWiki CPAN distribution.

Report information
The Basics
Id: 28402
Status: resolved
Worked: 10 min
Priority: 0/
Queue: HTML-WikiConverter-MediaWiki

Owner: diberri [...]
Requestors: webmaster [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Subject: Suggestion for Mediawiki convert table
Date: Fri, 20 Jul 2007 16:35:33 +0200
To: bug-html-wikiconverter-mediawiki [...]
From: Webmaster <webmaster [...]>
Download (untitled) / with headers
text/plain 1.4k
Hello, first let me thank you for creating HTML::WikiConverter suite which is really useful ! While using HTML::WikiConverter rev 0.61 and HTML::WikiConverter::MediaWiki rev 0.55, i had found a strange result when submitting the resulting table, to wikipedia for example, after converting it from html. the first row of td appeared on the same line than the headings (see wikipedia_table_rendering.jpg image attached). In fact this arrised because The first row '|-' or the tr series (after headings) was not generated during the conversion from html to mediawiki This is because of the tbody element of the table which cause the line 274: return '' unless $node->left or $attrs; of to return, thus ignoring the first tr start. "$h->left() In scalar context: returns the node that’s the immediate left sibling of $h. If $h is the leftmost (or only) child of its parent (or has no parent), then this returns undef." I first tried to hack the code of until I realised that there were already an option for this in HTML::WikiConverter in the form of "passthrough_naked_tags" ! So I used passthrough_naked_tags=>[qw(tbody div span font)] , and everything worked well :the missing |- appeared. So I would suggest to add tbody (and thead to be complete) in the __default_passthrough_naked_tags list of; P.S : I also wrote a test to be used with and without the tbody in the passthrough_naked_tags list Best Regards Pascal Sternis
text/x-perl 1.2k
#!/usr/bin/perl use strict; use HTML::WikiConverter; my $MW_ROW_START = '|-'; my $test_reg = '!\s+heading last col\s+'.quotemeta($MW_ROW_START).'\s+\|\s+data first col first row'; my $wc = new HTML::WikiConverter( dialect => 'MediaWiki' , ( encoding => 'latin1') ); my $html_table = join '',<DATA>; my $wiki_table = $wc->html2wiki($html_table); print "wiki table result:\n"; print $wiki_table; if ( $wiki_table =~ qr($test_reg)s) { print "\nPASS\nThere is '$MW_ROW_START' between 'heading last col' and 'data first col first row\n"; } else { print "\nFAIL\nThere should be a '$MW_ROW_START' between 'heading last col' and 'data first col first row' to indicate the start of a new row\n"; } ##################### # table for testing # ##################### __DATA__ <table border="1"> <colgroup> <col /> <col /> <col /> </colgroup> <thead> <tr> <th>heading col 1</th> <th>heading col 2</th> <th>heading last col</th> </tr> </thead> <tbody> <tr> <td>data first col first row</td> <td>data c2 r1</td> <td>data c3 r1</td> </tr> <tr> <td>data c1 r2</td> <td>data c2 r2</td> <td>data c3 r2</td> </tr> <tr> <td>data c1 r3</td> <td>data c2 r3</td> <td>data c3 r3</td> </tr> </tbody> </table>
Thanks for the report. This is fixed in 0.56 which I'll be releasing shortly. -- David Iberri

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to