# [tex2html.pm] 15.02.1997 R.Scholz <mrz@informatik.uni-jena.de>
#
# This Module is used by: texpro-doc2html.pl

# it does: translate TeX-Commands to HTML or to TEXT, whatever
#          looks better in a Web Browser.


# Bitte nicht ändern, bei Erweiterungswünschen erst Kontakt mit
# mrz@informatik.uni-jena.de aufnehmen !!


sub tex2html
# translate TeX commands to HTML
{
    local ($_) = @_;

    s/[ \t]+/ /g; # compress spaces
#    s/^ //; s/ $//;
    s|\\&|&amp;|g;                               # \&     ->  &amp;
    s|~| |g;                                     # ~      ->  " "


    s|\\\\(\[\d+\w\w\])?|<BR>|g;                 # \\           ->  <BR>
    s|\\medskip|<BR><BR>|g;                      # \medskip     ->  <BR><BR>
    s|\\smallskip|<BR><BR>|g;                    # \smallskip   ->  <BR><BR>
    s|\\bigskip|<BR><BR><BR>|g;                  # \bigskip     ->  <BR><BR><BR>
    s|\\noindent||g;                             # \noindent    ->  ""
    s|\\protect||g;                              # \protect     ->  ""
    s|\\narrowitem||g;                           # \narrowitem  ->  ""
    s/\\parindent\d+(mm|in|cm|pt)?//g;           # \parindentxmm -> ""
    s|\\ | |g;                                   # "\ "         ->  " "
    s|\\,| |g;                                   # "\,"         ->  " "
    s|\\quad| |g;                                # \quad        ->  " "
    s|\\qquad| |g;                               # \qquad       ->  " "

    s|\\BibTeX|BibTeX|g;                         # \BibTeX      ->  "BibTeX"
    s|\\LaTeXe|LaTeX2e|g;                        # \LaTeXe      ->  "LaTeX2e"
    s|\\LaTeX|LaTeX|g;                           # \LaTeX       ->  "LaTeX"
    s|\\TeX|TeX|g;                               # \TeX         ->  "TeX"


    # Umlaute:
    s|\{\\"a\}|&auml;|g;
    s|\{\\"A\}|&Auml;|g;
    s|\{\\"o\}|&ouml;|g;
    s|\{\\"O\}|&Ouml;|g;
    s|\{\\"u\}|&uuml;|g;
    s|\{\\"U\}|&Uuml;|g;
    s|\{\\"s\}|&szlig;|g;
    s|\\ss|&szlig;|g;

    s|ä|&auml;|g;
    s|Ä|&Auml;|g;
    s|ö|&ouml;|g;
    s|Ö|&Ouml;|g;
    s|ü|&uuml;|g;
    s|Ü|&Uuml;|g;
    s|ß|&szlig;|g;


    s|\\"a|&auml;|g;  s|"a|&auml;|g;
    s|\\"A|&Auml;|g;  s|"A|&Auml;|g;
    s|\\"o|&ouml;|g;  s|"o|&ouml;|g;
    s|\\"O|&Ouml;|g;  s|"O|&Ouml;|g;
    s|\\"u|&uuml;|g;  s|"u|&uuml;|g;
    s|\\"U|&Uuml;|g;  s|"U|&Uuml;|g;
    s|\\"s|&szlig;|g;  s|\\ss|&szlig;|g; s|"s|&szlig;|g;

    s|\\/||g;                                    # \/     ->  ""
    s|\\-||g;                                    # \-     ->  ""
    s|\{\}||g;                                   # {}     ->  ""
    s|(\\cite\s*\{[^}]+\})||g;                   # \cite  ->  ""

    s|\\'{\\i}|&iacute;|g;                       # \'{\i} ->  &iacute;
    s|\\'{a}|&aacute;|g;                         # \'{a}  ->  &aacute;
    s|{\\`e}|&eacute;|g;                         # {\`e}  ->  &eacute;
    s|é|&eacute;|g;                              # é      ->  &eacute;

    s|\$\\mu\$|&#181;|g;                         # \mu    ->  &#181;
    s|\$\\Psi\$|Psi|g;                           # $\Psi$ ->  Psi
    s|\$\\psi\$|psi|g;                           # $\psi$ ->  psi


#    s|\\centerline\s*(\{.+\})|<CENTER>$1</CENTER>|g; # \centerline -> <CENTER>
    s|\\centerline\s*(\{.+\})|<DIV align="center">$1</DIV>|g; # \centerline -> <DIV align="center">


    # Fonts:
    # old LaTeX2.09:
    s|\{\s*\\em\s+([^}]+)\}|<EM>$1</EM>|g;          # \em    ->  <EM>
    s|\{\s*\\it\s+([^}]+)\}|<EM>$1</EM>|g;          # \it    ->  <EM>
    s|\{\s*\\bf\s+([^}]+)\}|<STRONG>$1</STRONG>|g;  # \bf    ->  <STRONG>
    s|\{\s*\\tt\s+([^}]+)\}|<TT>$1</TT>|g;          # \tt    ->  <TT>
    # new LaTeX2e:
    s|\\textbf\s*\{([^}].+)\}|<STRONG>$1</STRONG>|g; # \textbf{} ->  <STRONG>
    s|\\texttt\s*\{([^}].+)\}|<TT>$1</TT>|g;        # \texttt{}  ->  <TT>
    s|\\emph\s*\{([^}].+)\}|<EM>$1</EM>|g;          # \emph{}    ->  <EM>

    s|\{\s*\\small\s+([^}]+)\}|<SMALL>$1</SMALL>|g; # \small ->  <SMALL>
    s|\{\s*\\footnotesize\s+([^}]+)\}|<SMALL>$1</SMALL>|g; # \footnotesize ->  <SMALL>
    s|\{\s*\\underline\s+([^}]+)\}|<U>$1</U>|g;     # \underline ->  <U>
    s/\\path\|([^|]+)\|/<TT>$1<\/TT>/g;             # \path  ->  <TT>
    s/\\verb\|([^|]+)\|/<TT>$1<\/TT>/g;             # \verb  ->  <TT>



    # itemize      --> <UL>
    # description  --> <UL type="square">
    # item         --> <LI>
    s|(\\begin\s*\{itemize\})|<UL>|g;
    s|(\\end\s*\{itemize\})|</UL>|g;
    s|(\\begin\s*\{description\})|<UL type="square">|g;
    s|(\\end\s*\{description\})|</UL>|g;
    s|(\\item)|<LI>|g;

    s/\{(.+)\}/$1/g;       # {text} -> text, klappt nicht bei mehreren { {}{} }
    s/[ \t]+/ /g;          # compress spaces
    s/^[ \t]+//g; s/[ \t]+$//g;  # rm whitespace at beginning and end

    return($_);
}

# END
1;