#!/usr/bin/perl -w $generator="<meta name=\"generator\" content=\"tex2html.pl 1.0\">\n<meta name=\"author\" content=\"Dmitry\@Agafonov.pp.ru\">"; $table=0; $pre=0; $document=0; $toc_id=0; $toc=""; $title=""; $date=""; $author=""; while (<>) { s/"/&quot;/g; s/</&lt;/g; s/>/&gt;/g; if (/\\title{(.*[^\\][^}])}/) { $title=$1; } if (/\\date{(.*[^\\][^}])}/) { $date=$1; } if (/\\author{(.*[^\\][^}])}/) { $author=$1; } if (/\\author{\s*$/) { $author=<>; } if ($table==1) { s/\\\\/<\/td><\/tr><tr><td>/g; s/([^\\])[&%]([^qlg])/$1<\/td><td>$2/g; } else { s/\\\\/<br>/g; } if ($pre!=1) { s/^\s+//g; s/ +/ /g; } if (/begin{tabular}/) { $table=1; s/\\begin{tabular}{\w+}/<table cellpadding=5><tr><td>/g; } if (/end{tabular}/) { $table=0; s/\\end{tabular}/<\/table>/g; } if (/begin{verbatim}/) { $pre=1; s/\\begin{verbatim}/<pre>/g; } if (/end{verbatim}/) { $pre=0; s/\\end{verbatim}/<\/pre>/g; } if (/\\section{(.*[^\\])}/) { $toc.="<li><a href=\"#href$toc_id\">$1</li>\n"; $_="</p><a name=\"href$toc_id\"><h2>$1</h2></a><p>"; $toc_id++; } if (/\\subsection{(.*[^\\])}/) { $toc.="<ul><li><a href=\"#href$toc_id\">$1</li></ul>\n"; $_="</p><a name=\"href$toc_id\"><h2>$1</h2></a><p>"; $toc_id++; } if (/\\subsubsection{([^}]*)}/) { $toc.="<ul><ul><li><a href=\"#href$toc_id\">$1</li></ul></ul>\n"; $_="</p><a name=\"href$toc_id\"><h2>$1</h2></a><p>"; $toc_id++; } if (/\\begin{document}/) { $document=1; } s/\\end{document}//g; s/\\htmladdnormallink{([^}]*)}{([^}]*)}/<a href="$1">$2<\/a>/g; s/{\\tt ([^}]*)}/<tt>$1<\/tt>/g; s/{\\bf ([^}]*)}/<b>$1<\/b>/g; s/{\\em ([^}]*)}/<em>$1<\/em>/g; s/{\\it ([^}]*)}/<i>$1<\/i>/g; s/^\s*$/<\/p><p>/g; s/\\([ \$#%{}^&_~-])/$1/g; s/\\bf (\w*)/<b>$1<\/b>/g; s/\\(hline|(no)?indent|verb|maketitle)//g; s/\\\w+(\[[^\]]*\])?{[^}]*}({[^\]]*})?//g; if ($document==1) { $text.=$_; } } $toc =~ s/\\([ \$#%{}^&_~-])/$1/g; $author =~ s/\\\\//g; $text =~ s/^\s*<\/p>//g; $text =~ s/<p>\s*<\/p>//g; $text =~ s/<br>\s*<\/p>/<\/p>/g; $text =~ s/<\/(p|h\d|body|pre|tr)>/<\/$1>\n/g; $text =~ s/\\tableofcontents/<ul>$toc<\/ul>\n/g; print "<html>\n<head>\n$generator\n<title>$title</title>\n</head>\n"; print "<body text=black bgcolor=white>\n"; print "<h1 align=center>$title</h1>\n" if ($title ne ""); print "<h3 align=center>$author</h3>\n" if ($author ne ""); print "<p align=center>$date</p>\n" if ($date ne ""); print "$text\n</body>\n</html>";