| 1 | ##---------------------------------------------------------------------------## | ||
| 2 | ## File: | ||
| 3 | ## $Id: mhtxttsv.pl,v 2.5 2003/01/19 01:35:59 ehood Exp $ | ||
| 4 | ## Author: | ||
| 5 | ## Earl Hood mhonarc@mhonarc.org | ||
| 6 | ## Description: | ||
| 7 | ## Library defines routine to filter text/tab-separated-values body | ||
| 8 | ## parts to HTML | ||
| 9 | ## for MHonArc. | ||
| 10 | ## Filter routine can be registered with the following: | ||
| 11 | ## <MIMEFILTERS> | ||
| 12 | ## text/tab-separated-values:m2h_text_plain'filter:mhtxttsv.pl | ||
| 13 | ## </MIMEFILTERS> | ||
| 14 | ##---------------------------------------------------------------------------## | ||
| 15 | ## MHonArc -- Internet mail-to-HTML converter | ||
| 16 | ## Copyright (C) 1998-2001 Earl Hood, mhonarc@mhonarc.org | ||
| 17 | ## | ||
| 18 | ## This program is free software; you can redistribute it and/or modify | ||
| 19 | ## it under the terms of the GNU General Public License as published by | ||
| 20 | ## the Free Software Foundation; either version 2 of the License, or | ||
| 21 | ## (at your option) any later version. | ||
| 22 | ## | ||
| 23 | ## This program is distributed in the hope that it will be useful, | ||
| 24 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 25 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 26 | ## GNU General Public License for more details. | ||
| 27 | ## | ||
| 28 | ## You should have received a copy of the GNU General Public License | ||
| 29 | ## along with this program; if not, write to the Free Software | ||
| 30 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
| 31 | ## 02111-1307, USA | ||
| 32 | ##---------------------------------------------------------------------------## | ||
| 33 | |||
| 34 | package m2h_text_tsv; | ||
| 35 | |||
| 36 | ##---------------------------------------------------------------------------## | ||
| 37 | ## Text/tab-separated-values filter for mhonarc. | ||
| 38 | ## | ||
| 39 | sub filter { | ||
| 40 | my ($fields, $data, $isdecode, $args) = @_; | ||
| 41 | my ($field, $line, $ret); | ||
| 42 | local ($_); | ||
| 43 | |||
| 44 | $$data =~ s/^\s+//; | ||
| 45 | $ret = "<table border=1>\n"; | ||
| 46 | foreach $line (split(/\r?\n/, $$data)) { | ||
| 47 | $ret .= "<tr>"; | ||
| 48 | foreach $field (split(/\t/, $line)) { | ||
| 49 | $ret .= '<td>' . mhonarc::htmlize($field) . '</td>'; | ||
| 50 | } | ||
| 51 | $ret .= "</tr>\n"; | ||
| 52 | } | ||
| 53 | $ret .= "</table>\n"; | ||
| 54 | ($ret); | ||
| 55 | } | ||
| 56 | |||
| 57 | ##---------------------------------------------------------------------------## | ||
| 58 | 1; |