[Home]WikiBugs/EmptyTableElements

UseModWiki | WikiBugs | RecentChanges | Preferences

Fixed in 1.0.3 --MarkusLude

Table elements that contain only white space look weird in most browsers.

x x   x
  x   
x   x x

A common workaround ist using & nbsp; instead. Here is the patch (you must copy from the edit page!):

+ sub table_nbsp {
+     my $elem = $_[0];
+     $elem =~ s/(?<=\|\|)(\s+)(?=\|\|)/ /g;
+     $elem =~ s/^(\s+)(?=\|\|)/ /;
+     $elem =~ s/(?<=\|\|)(\s+)$/ /;
+     return $elem;
+ }

sub WikiLinesToHtml {
  my ($pageText) = @_;
  my ($pageHtml, @htmlStack, $code, $codeAttributes, $depth, $oldCode);

  @htmlStack = ();
  $depth = 0;
  $pageHtml = "";
  foreach (split(/\n/, $pageText)) {  # Process lines one-at-a-time
    $code = '';
    $codeAttributes = '';
    $TableMode = 0;
    $_ .= "\n";
    if (s/^(\;+)([^:]+\:?)\:/<dt>$2<dd>/) {
      $code = "DL";
      $depth = length $1;
    } elsif (s/^(\:+)/<dt><dd>/) {
      $code = "DL";
      $depth = length $1;
    } elsif (s/^(\*+)/<li>/) {
      $code = "UL";
      $depth = length $1;
    } elsif (s/^(\#+)/<li>/) {
      $code = "OL";
      $depth = length $1;
    } elsif ($TableSyntax &&
             s/^((\|\|)+)(.*)\|\|\s*$/"<TR VALIGN='CENTER' "
                                      . "ALIGN='CENTER'><TD colspan='"
-                               . (length($1)\/2) . "'>$3<\/TD><\/TR>\n"/e) {
+                               . (length($1)\/2) . "'>" . table_nbsp($3) . "<\/TD><\/TR>\n"/e) {
      $code = 'TABLE';
      $codeAttributes = "BORDER='1'";
      $TableMode = 1;
      $depth = 1;
    } elsif (/^[ \t].*\S/) {
      $code = "PRE";
      $depth = 1;
    } else {
      $depth = 0;
    }
--StefanTrcek

UseModWiki | WikiBugs | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited August 31, 2007 5:06 pm by MarkusLude (diff)
Search: