An enhancement, not a bugfix. This enables usemod to render simple tables. Tables are handled somewhat like text within "<pre> </pre>".
| Col1 | Col2 | Col3gets formatted as
<TABLE BORDER=0> <TR><TD> Col1</TD> <td> Col2 </td> <td> Col3 </td> </TR> </table>The Patch:
sub CommonMarkup {
...
## Tables:
s/^\|([^|]+)[^|]/<TR><TD>$1<\/TD>\n/g; # start of line: new table-row
s/\|([^|]+)[^|]/<td>$1<\/td>\n/g; # new field
}
return $_;
}
sub WikiLinesToHtml {
...
my ($tag);
...
} elsif (/^[ \t].*\S/) {
$code = "PRE";
$depth = 1;
#%% Table => PRE:
} elsif (/^[\|\+].*\S/) {
$code = "TABLE";
$depth = 1;
#
} else {
$depth = 0;
}
while (@htmlStack > $depth) { # Close tags as needed
# $pageHtml .= "</" . pop(@htmlStack) . ">\n";
#%%
$tag = pop(@htmlStack);
if ($tag eq "TABLE") {
$pageHtml .= "</TR>\n";
$tag = "table"
};
$pageHtml .= "</" . $tag . ">\n";
}
if ($depth > 0) {
$depth = $IndentLimit if ($depth > $IndentLimit);
...#!
while (@htmlStack < $depth) {
push(@htmlStack, $code);
#%%
if ($code eq "TABLE") {
$pageHtml .= "<TABLE BORDER=0>\n";
} else {
$pageHtml .= "<$code>\n";
};
}
}
Next project: Specify different styles, like FONT and BGCOLOR, for each row, column and/or cell :-)
By the way, the original code at "...#!" above can be left out.
I think that will fix a bug with mixed / nested lists :
# Foo ** Ding ** Dong # Bar ** Ping ** Pong ---- * Foo ## Ding ## Dong * Bar ## Ping ## Pongwill then look like:
1. Foo
+ Ding
+ Dong
2. Bar
+ Ping
+ Pong
----
* Foo
1. Ding
2. Dong
* Bar
1. Ping
2. Pong
--HaJoGurt