wiki.pl: Port some fixes from upstream
[Orgmuse.git] / modules / csv.pl
blob0e2166cd1172c1c6a09d9193589a1d8b984e6d13
1 # Copyright (C) 2007 Alex Schroeder <alex@emacswiki.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
19 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/csv.pl">csv.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Comments_on_Long_Table_Markup_Extension">Comments on Long Table Markup Extension</a></p>';
21 push(@MyRules, \&CsvRule);
23 my $RowCount;
25 sub CsvRule {
26 # tables using <csv> -- the first row of a table
27 if ($bol && m/\G&lt;csv&gt;\n/cg) {
28 $RowCount = 1;
29 return OpenHtmlEnvironment('table',1,'user csv')
30 . AddHtmlEnvironment('tr', 'class="odd first"')
31 . AddHtmlEnvironment('td');
33 # end of the row and beginning of the next row
34 elsif (InElement('td') && m/\G[ \t]*\n([ \t]*)/cg) {
35 my $type = ++$RowCount % 2 ? 'odd' : 'even';
36 return qq{</td></tr><tr class="$type"><td>};
38 # an ordinary table cell
39 elsif (InElement('td') && m/\G[ \t]*,[ \t]*/cg) {
40 return "</td><td>";
42 # an empty line will end the table automatically; no closing tag is required
43 return undef;