#!/usr/bin/perl # # Converting MSWord to HTML for use with MHonArc. # Written by Frank Ronny Larsen June 2000 # # Uses wvHtml from the wv package. # Supports: Converting MSWord to HTML # Downloading of original MSWORD # # TODO?: Images in Word-doc. Currently the version of wvHtml that I use # do not convert the images, due to lack of libraries. Therefore # this is not implemented here either. # package m2h_application_msword; require 'mhmimetypes.pl'; $wvHtml = "/usr/local/bin/wvHtml -c iso-8859-15"; sub filter { local($header, *fields, *data, $decoded, $args) = @_; my $txt = ""; # Require MHonArc to decode the data. if(!$decoded) { return ("MHonArc did not manage to decode the MSWord data. Probably weird encoding of the e-mail transmission."); }; ## Get content-type my ($ctype) = split ';', $fields{'content-type'}; $ctype =~ tr/A-Z/a-z/; # Write file so users can download the Worddoc itself. my $filename = mhonarc::write_attachment( $ctype, \$data ); # Run wvHtml on the .doc file. open C, "$wvHtml $mhonarc::OUTDIR/$filename |"; @Html = ; close C; # Strip HTML header. (Maybe use MHonArcs mh_text_html code for this?) $txt = join ' ', @Html; $txt =~ s|\n| |g; $txt =~ s|^.*(.*).*$|$1|i; # Add a link to the Word-file, so people may download it. $txt = "

$filename


$txt
"; # Return array with 1. HTML and 2. files ($txt, $filename); } ## True. stupid construct. 1;