File: mhtxttsv.pl

package info (click to toggle)
mhonarc 2.6.18-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 8,748 kB
  • sloc: perl: 279,542; makefile: 33
file content (58 lines) | stat: -rw-r--r-- 2,171 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
##---------------------------------------------------------------------------##
##  File:
##	$Id: mhtxttsv.pl,v 2.5 2003/01/19 01:35:59 ehood Exp $
##  Author:
##      Earl Hood       mhonarc@mhonarc.org
##  Description:
##	Library defines routine to filter text/tab-separated-values body
##	parts to HTML
##	for MHonArc.
##	Filter routine can be registered with the following:
##              <MIMEFILTERS>
##              text/tab-separated-values:m2h_text_plain'filter:mhtxttsv.pl
##              </MIMEFILTERS>
##---------------------------------------------------------------------------##
##    MHonArc -- Internet mail-to-HTML converter
##    Copyright (C) 1998-2001	Earl Hood, mhonarc@mhonarc.org
##
##    This program is free software; you can redistribute it and/or modify
##    it under the terms of the GNU General Public License as published by
##    the Free Software Foundation; either version 2 of the License, or
##    (at your option) any later version.
##
##    This program is distributed in the hope that it will be useful,
##    but WITHOUT ANY WARRANTY; without even the implied warranty of
##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##    GNU General Public License for more details.
##
##    You should have received a copy of the GNU General Public License
##    along with this program; if not, write to the Free Software
##    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
##    02111-1307, USA
##---------------------------------------------------------------------------##

package m2h_text_tsv;

##---------------------------------------------------------------------------##
##	Text/tab-separated-values filter for mhonarc.
##
sub filter {
    my($fields, $data, $isdecode, $args) = @_;
    my($field, $line, $ret);
    local($_);

    $$data =~ s/^\s+//;
    $ret  = "<table border=1>\n";
    foreach $line (split(/\r?\n/, $$data)) {
	$ret .= "<tr>";
	foreach $field (split(/\t/, $line)) {
	    $ret .= '<td>' . mhonarc::htmlize($field) . '</td>';
	}
	$ret .= "</tr>\n";
    }
    $ret .= "</table>\n";
    ($ret);
}

##---------------------------------------------------------------------------##
1;