#!/usr/bin/perl -w # # latex2utf8txt, Jun 18 2005 Peter Csizmadia # use strict; if($#ARGV < 0) { print <) { chomp; s/^\\documentclass\{.*//; s/^\\usepackage\{.*\}//; s/^\\def\\.*//; s/^\\maketitle$//; s/^\\begin\{abstract\}$//; s/^\\end\{abstract\}$//; s/^\\begin\{document\}$//; s/^\\end\{document\}$//; s/^%.*//g; s/^[ \t]+//g; s/[ \t]+$//g; if(/^$/) { if(!($paragraph eq "")) { printf("%s\n\n", convert($paragraph)); $paragraph = ""; } } elsif(/^\\begin\{[a-z]+\}$/ || /^\\end\{[a-z]+\}$/) { my $line = $_; if(!($paragraph eq "")) { printf("%s\n", convert($paragraph)); $paragraph = ""; } printf("%s\n", $line); } elsif(/^\\item / || /^\\bibitem\{/) { my $line = $_; if(!($paragraph eq "")) { printf("%s\n", convert($paragraph)); $paragraph = ""; } $paragraph = $line; } elsif($paragraph eq "") { $paragraph = $_; } else { $paragraph .= " ".$_; } } if(!($paragraph eq "")) { printf("%s\n", convert($paragraph)); }