[OS X TeX] texti2html

Bob Kerstetter bkerstetter at mac.com
Sun May 22 14:07:55 CEST 2005


On May 21, 2005, at 7:38 PM, Rene Borgella wrote:


>
> Greetings:
>
>
>
>
>> At 3:32 PM -0500 5/21/05, Bob Kerstetter wrote:
>>
>>
>
>
>
>> try:
>>
>> htlatex yourlatexdoc  "html"
>>
>>
>
>
> I didn't know about adding the "html" after htlatex latexdoc
>
> I tired it and saw the html output had slightly different (better)  
> formatting.  Could you please tell me a bit more about what it does?
>
>

html makes tex4ht produce html 4 output with css mark up, i believe.  
you can actually specify the level of html like this:

htlatex yourlatexdoc "html,3.2"

or

htlatex yourlatexdoc "html,4"



>
>
>>
>> Add the info option:
>>
>> htlatex yourtexdoc  "html,info"
>>
>> to put about 60K worth of options and execution info--sort of like  
>> a user manual--into the yourlatexdoc.log file.
>>
>>
>
>
> Also, I didn't know about the info option.
>

Yes, Eitan has been trying to get me to read that for years now. So I  
have finally started doing it. :)


>
>
>
>
>> TeX4ht is very configurable and flexible.
>>
>>
>
>
>  What other kind of things like this exist?
>

I don't know of anything else.

TeX4ht has output options for open office, xml, xhtml, docbook and  
probably other things. The home page is here:

http://www.cse.ohio-state.edu/~gurari/TeX4ht/

The documentation is very thorough, but a bit over my head.

Basically I use it with custom configuration files. Output of one  
file is mostly html 3.2 with no CSS. The other as some CSS. You put  
these config files in the local texmf and call them in place of  
"html" for example, a config file named simplehtml.cfg is called like  
this:

htlatex yourlatexdoc "simplehtml,3.2"

You can break up your output into separate files by adding numbers to  
the command line:

htlatex yourlatexdoc "simplehtml,3.2,2"

creates new files for each \section and \subsection, i think.

htlatex yourlatexdoc "simplehtml,3.2,3"

creates new files for each \section, \subsection and \subsubsection.

Here is the souce for simplehtml.cfg and howto.cfg, the later uses  
some CSS. Both of these config files are for specialized use and  
probably of limited value other than being examples. I am not an  
expert at this. But reading along with the "info" output may be of  
some value.  Eitan provides me with more support than he probably  
should, for which i am very grateful.


BEGIN simplehtml.cfg

\Preamble{html,no-DOCTYPE}

    \Configure{HTML}
      {\IgnorePar\HCode{<html>}}
      {\HCode{</html>}}

\Configure{HEAD}
       {\IgnorePar\NoFonts\HCode {<head>}}
       {\HCode{</head>}\EndNoFonts}

\begin{document}

\Configure{HtmlPar}
    {\EndP\HCode{<p>}}
    {\EndP\HCode{<p>}}
    {\HCode{</p>}}
    {\HCode{</p>}}

\Configure{@HEAD}{}

\Configure{@HEAD}
   {\HCode{<meta http-equiv="Content-Type"
                 content="text/html; charset=iso-8859-1">\Hnewline
    <meta name="generator"  content="TeX4ht
     (http://www.cis.ohio-state.edu/\string
                                ~gurari/TeX4ht/mn.html)">\Hnewline
    <!--\Preamble-->\Hnewline
   }}

\Configure{BODY}
       {\ifvmode \IgnorePar\fi  \HCode{<body>}\ShowPar}
       {\ifvmode \IgnorePar\fi \EndP  \HCode{</body>}}

\Configure{maketitle}
    {\Tag{TITLE+}{\@title}}
    {}
    {\HCode{<p align="center"><strong>}}
    {\HCode{</strong></p>}}

\Configure{thanks author date and}
    {}{}
    {\HCode{<p align="center"><strong>}} {\HCode{</strong></p>}}
    {\HCode{<p align="center"><strong>}} {\HCode{</strong></p>}}
    {} {}

\ConfigureEnv{abstract}
    {\ifvmode \IgnorePar\fi
     \HCode{<p><strong>Abstract</strong></p><blockquote>}%
     \bgroup
        \let\abstractname=\empty
        \ConfigureEnv{center}{}{}{}{}%
        \Configure{HtmlPar}{}{}{}{}%
    }
    {\HCode{</blockquote>}\egroup  }
    {}{}

\HAssign\Vcount = 0
\HAssign\Hcount = 0
\ConfigureEnv{minipage}
    {\ifvmode \HAdvance \Vcount by 1
              \HAssign\Hcount = 1
     \else    \HAdvance \Hcount by 1 \fi
     \HAssign\miniBefore=\Hcount  \HAdvance\miniBefore by -1
     \HAssign\miniAfter=\Hcount   \HAdvance\miniAfter by 1
     \let\EndMinis\empty
     \Tag{minipage-\Vcount-\Hcount}{}%
     \ifvmode \IgnorePar\fi \EndP
     \ifTag{minipage-\Vcount-\miniBefore}{%
          \HCode{</td><td>}%
          \ifTag{minipage-\Vcount-\miniAfter}{}{%
             \def\EndMinis{\HCode{</td></tr></table>}%
                           \csname par\endcsname}%
          }%
     }{%
          \ifTag{minipage-\Vcount-\miniAfter}{%
             \HCode{<table><tr><td>}%
          }{}%
     }%
    }
    {\ifvmode \IgnorePar\fi \EndP \EndMinis}
    {}{}


\let\contentsname=\empty
\Configure{tableofcontents}
    {\ifvmode \IgnorePar\fi \EndP
     \let\EndSecToc=\empty
     \HCode{<p>}\Link{}{Contents}\EndLink
     \HCode{<strong>Contents</strong></p>}}
    {\EndSecToc}
    {}{} {}


\ConfigureToc{section}
   {\EndSecToc\def\EndSecToc{\HCode{</p>\Hnewline}}%
    \HCode{<p><strong>}}
   { }{}
   {\HCode{</strong>}}

\ConfigureToc{subsection}
   {\HCode{\Hnewline<br />}}  {\HCode{  }}{}{}

\ConfigureToc{subsubsection}
   {\HCode{\Hnewline<br />}}  {\HCode{    }}{}{}


\Configure{section}
    {\ifvmode \IgnorePar\fi \EndP}
    {}
    {\ifvmode \IgnorePar\fi \EndP \HCode{<h1>}}
    {\HCode{</h1>}\par\ShowPar}

\Configure{subsection}
    {\ifvmode \IgnorePar\fi \EndP}
    {}
    {\ifvmode \IgnorePar\fi \EndP \HCode{<h2>}}
    {\HCode{</h2>}\par\ShowPar}


\Configure{subsubsection}
    {\ifvmode \IgnorePar\fi \EndP}
    {}
    {\ifvmode \IgnorePar\fi \EndP \HCode{<h3>}}
    {\HCode{</h3>}\par\ShowPar}



\ConfigureEnv{itemize}
    {\ifvmode \IgnorePar\fi \EndP}{}{}{}


\ConfigureList{itemize}%
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<ul>}\let\EndLI=\empty}
    {\HCode{</li></ul>}\ShowPar}
    {\DeleteMark}
    {\EndLI \def\EndLI{\HCode{</li>}}\HCode{<li>}}

\ConfigureEnv{enumerate}
    {\ifvmode \IgnorePar\fi \EndP}{}{}{}

\ConfigureList{enumerate}%
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<ol>}\let\EndLI=\empty}
    {\HCode{</li></ol>}}
    {\DeleteMark}
    {\EndLI \def\EndLI{\HCode{</li>}}\HCode{<li>}\AnchorLabel}


\ConfigureEnv{description}
    {\ifvmode \IgnorePar\fi \EndP}{}{}{}

\ConfigureList{description}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<dl>}}
    {\HCode{</dd></dl>}}
    {\HCode{<dt><strong>}}
    {\HCode{</strong></dt><dd>}}

\Configure{crosslinks+}
    {}{}
    {}{\Link{Contents}{}Contents\EndLink}

\Configure{crosslinks}{}{}{}{}{}{}{}{}


\ConfigureEnv{center}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<p align="center">}}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{</p>}\par\ShowPar}
    {\relax}{}

\ConfigureEnv{flushright}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<p align="right">}}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{</p>}\par\ShowPar}
    {\relax}{}

\ConfigureEnv{figure}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<p align="left">}}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{</p>}\par\ShowPar}
    {\relax}{}

%\Configure{wrapfloat}
%    {\getWFplace
%     \bgroup
%       \Configure{graphics*}
%         {png}
%         {\Picture[pict]{\csname Gin at base\endcsname.png \WFplace}}%
%    }
%    {\egroup}



\EndPreamble

\Configure{@HEAD}{}

%Definitions

    \let\oldSec=\section
    \def\section#1{%
       \setfilename #1 //%
       \oldSec{#1}%
    }
    \def\setfilename#1//{%
       \let\temp=\empty
       \setname#1//%
       \NextFile{\temp.html}%
    }
    \def\setname#1 #2//{%
       \edef\temp{\temp#1}%
       \if !#2!\let\next=\empty
       \else \def\next{\setname#2//}\fi
       \next
    }

   \let\oldSubsec=\subsection
   \def\subsection#1{%
      \setfilename #1 //%
      \oldSubsec{#1}%
   }


\endinput



END simplehtml.cfg

**********

BEGIN howtos.cfg

\Preamble{html,no-DOCTYPE}

    \Configure{HTML}
      {\IgnorePar\HCode{<html>}}
      {\HCode{</html>}}

\Configure{HEAD}
       {\IgnorePar\NoFonts\HCode {<head>}}
       {\HCode{</head>}\EndNoFonts}

\begin{document}

\Configure{HtmlPar}
    {\EndP\HCode{<p>}}
    {\EndP\HCode{<p>}}
    {\HCode{</p>}}
    {\HCode{</p>}}

\Configure{@HEAD}{}

\Configure{@HEAD}
   {\HCode{<meta http-equiv="Content-Type"
                 content="text/html; charset=iso-8859-1">\Hnewline
    <meta name="generator"  content="TeX4ht
     (http://www.cis.ohio-state.edu/\string
                                ~gurari/TeX4ht/mn.html)">\Hnewline
     <link rel="stylesheet" href="howtos.css2" type="text/css">\Hnewline
    <!--\Preamble-->\Hnewline
   }}

\Configure{BODY}
       {\ifvmode \IgnorePar\fi  \HCode{<body>}\ShowPar}
       {\ifvmode \IgnorePar\fi \EndP  \HCode{</body>}}

\Configure{maketitle}
    {\Tag{TITLE+}{\@title}}
    {}
    {\HCode{<p class="title">}}
    {\HCode{</p>}}

\Configure{thanks author date and}
    {}{}
    {\HCode{<p class="subtitle">}} {\HCode{</p>}}
    {\HCode{<p class="subtitle">}} {\HCode{</p>}}
    {} {}

\ConfigureEnv{abstract}
    {\ifvmode \IgnorePar\fi
     \HCode{<blockquote>}%
     \bgroup
        \let\abstractname=\empty
        \ConfigureEnv{center}{}{}{}{}%
        \Configure{HtmlPar}{}{}{}{}%
    }
    {\HCode{</blockquote>}\egroup  }
    {}{}


\ConfigureEnv{quotation}
    {\ifvmode \IgnorePar\fi
     \HCode{<blockquote>}%
     \bgroup
        \ConfigureEnv{center}{}{}{}{}%
        \Configure{HtmlPar}{}{}{}{}%
    }
    {\HCode{</blockquote>}\egroup  }
    {}{}


%\Configure{IMG}{<img\Hnewline src="}{" alt="}{" }{ />}

\HAssign\Vcount = 0
\HAssign\Hcount = 0
\ConfigureEnv{minipage}
    {\ifvmode \HAdvance \Vcount by 1
              \HAssign\Hcount = 1
     \else    \HAdvance \Hcount by 1 \fi
     \HAssign\miniBefore=\Hcount  \HAdvance\miniBefore by -1
     \HAssign\miniAfter=\Hcount   \HAdvance\miniAfter by 1
     \let\EndMinis\empty
     \Tag{minipage-\Vcount-\Hcount}{}%
     \ifvmode \IgnorePar\fi \EndP
     \ifTag{minipage-\Vcount-\miniBefore}{%
          \HCode{</td><td>}%
          \ifTag{minipage-\Vcount-\miniAfter}{}{%
             \def\EndMinis{\HCode{</td></tr></table>}%
                           \csname par\endcsname}%
          }%
     }{%
          \ifTag{minipage-\Vcount-\miniAfter}{%
             \HCode{<table><tr><td>}%
          }{}%
     }%
    }
    {\ifvmode \IgnorePar\fi \EndP \EndMinis}
    {}{}


\let\contentsname=\empty
\Configure{tableofcontents}
    {\ifvmode \IgnorePar\fi \EndP
     \let\EndSecToc=\empty
     \HCode{<p>}\Link{}{Contents}\EndLink
     \HCode{</p>}}
    {\EndSecToc}
    {}{} {}

\ConfigureEnv{itemize}
    {\ifvmode \IgnorePar\fi \EndP}{}{}{}


\ConfigureList{itemize}%
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<ul>}\let\EndLI=\empty}
    {\HCode{</li></ul>}\ShowPar}
    {\DeleteMark}
    {\EndLI \def\EndLI{\HCode{</li>}}\HCode{<li>}}

\ConfigureEnv{enumerate}
    {\ifvmode \IgnorePar\fi \EndP}{}{}{}

\ConfigureList{enumerate}%
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<ol>}\let\EndLI=\empty}
    {\HCode{</li></ol>}}
    {\DeleteMark}
    {\EndLI \def\EndLI{\HCode{</li>}}\HCode{<li class="numberlist">} 
\AnchorLabel}


\ConfigureEnv{description}
    {\ifvmode \IgnorePar\fi \EndP}{}{}{}

\ConfigureList{description}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<dl>}}
    {\HCode{</dd></dl>}}
    {\HCode{<dt><strong>}}
    {\HCode{</strong></dt><dd>}}

\Configure{crosslinks}{}{\HCode{   }}{\HCode{<span  
class="nav">Next</span>}}{\HCode{<span class="nav">Previous</span>}}{} 
{}{}{\HCode{<span class="nav">Contents</span>}}

\ConfigureEnv{center}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<p align="center">}}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{</p>}\par\ShowPar}
    {\relax}{}

\ConfigureEnv{flushright}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<p align="right">}}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{</p>}\par\ShowPar}
    {\relax}{}

\ConfigureEnv{figure}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{<p align="left">}}
    {\ifvmode \IgnorePar\fi \EndP
     \HCode{</p>}\par\ShowPar}
    {\relax}{}

\Configure{TITLE+}
   {\ifTag{TITLE+}{\Ref{TITLE+}}{\jobname.html}}
%\Configure{chapterTITLE+}{#1}
\Configure{sectionTITLE+}{#1}
\Configure{subsectionTITLE+}{#1}
\Configure{subsubsectionTITLE+}{#1}

%\ConfigureToc{chapter}
%  {\EndSecToc\def\EndSecToc{\HCode{</p>\Hnewline}}%
%   \HCode{<p><big><strong>}}
%  { }{}
%  {\HCode{</strong></big>}}


\ConfigureToc{section}
   {\EndSecToc\def\EndSecToc{\HCode{</p>\Hnewline}}%
    \HCode{<p class="sectiontoc">}}
   { }{}
   {\HCode{}}

\ConfigureToc{subsection}
   {\HCode{\Hnewline</p>}}  {\HCode{<p class="subsectiontoc">}}{}{}

\ConfigureToc{subsubsection}
   {\HCode{\Hnewline</p>}}  {\HCode{<p class="subsubsectiontoc">}}{}{}

\Configure{section}{}{}
    {\ifvmode\IgnorePar\fi \EndP \HCode{<h1>}}
    {\HCode{</h1>}\IgnoreIndent \par}
\Configure{subsection}{}{}
    {\bgroup \IgnorePar\HCode{<h2>}}
    {\HCode{</h2>}\IgnoreIndent\egroup}
\Configure{subsubsection}{}{}
    {\bgroup \IgnorePar\HCode{<h3>}}
    {\HCode{</h3>}\IgnoreIndent\egroup}

%\Configure{makeindex}{\HCode{&\#x25A0;}}

\Configure{LNK}
    {\Link}
    {\EndLink}
    {\HCode{&\#x25A0;}}


\EndPreamble

%% \endinput

%% \endinput

\newtoks\tk
\def\setfilename#1{%
     \tk={#1}%
     \immediate\openout15=tmp.tmp
     \immediate\write15{\string\tk{\the\tk}}
     \immediate\closeout15
     \bgroup
       \csname no:catcodes\endcsname{32}{47}{9}%
       \csname no:catcodes\endcsname{58}{64}{9}%
       \csname no:catcodes\endcsname{91}{91}{9}%
       \csname no:catcodes\endcsname{93}{96}{9}%
       \csname no:catcodes\endcsname{126}{126}{9}%
       \input tmp.tmp
       \xdef\temp{\the\tk}%
     \egroup
     \NextFile{\temp.html}%
}
\let\oldSec=\section
\def\section#1{%
   \setfilename{#1}%
   \oldSec{#1}%
}
\let\oldSubsec=\subsection
\def\subsection#1{%
    \setfilename{#1}%
    \oldSubsec{#1}%
}


\endinput


END howtos.cfg



--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the macostex-archives mailing list