% ___________________________________________________________________________ % |#########################################################################| % | | % | The Manual for the LaTeX converter latex_to_html.tex | % | ------------------------------------------------------------- | % | | % | 30.07.1998 Lutz Kettner kettner@acm.org | % | Zurich, Switzerland | % | $Revision$ | % | $Date$ | % |_________________________________________________________________________| % |#########################################################################| \documentclass[11pt]{article} \usepackage{latexsym} \usepackage{amssymb} \usepackage{path} \usepackage{epsfig} \usepackage{cc_manual} \usepackage{latex_to_html} \usepackage{makeidx} \makeindex %\pagestyle{empty} \textwidth 15.4cm \textheight 24 cm \topmargin -14mm \evensidemargin 3mm \oddsidemargin 3mm \parindent0em \setlength{\parskip}{1.4ex} \sloppy { \begingroup \catcode`\|=0 \catcode`\[=1 \catcode`\]=2 \catcode`\{=12 \catcode`\}=12 \catcode`\\=12 |gdef|Open[[|tt {]] |gdef|Close[[|tt }]] |gdef|Backslash[[|tt \]] |endgroup } \newcommand{\Mindex}[1]{\index{#1@\protect\Backslash{\tt #1}}} \newcommand{\ccIndexEntry}[1]{\index{#1@\protect\Backslash{\tt #1}}} \newcommand{\lcIndex}[1]{\index{#1@\protect\Backslash{\tt #1}}} \newcommand{\TTindex}[1]{\index{#1@{\tt #1}}} \newcommand{\Dindex}[1]{#1\index{#1}} \def\ind{\hspace*{7mm}} % ---------------------------------------------------------------------- \title{\LaTeX\ to HTML Converter\\ {\tt cc\_manual\_to\_html} and {\tt latex\_converter.sty}} \author{Lutz Kettner} \date{\lcRevision. \lcDate} \begin{document} \maketitle \tableofcontents \thispagestyle{empty} \clearpage \thispagestyle{empty} ~\vfill \input{Manual_tools/disclaimer} \cleardoublepage\setcounter{page}{1} % ---------------------------------------------------------------------- \section{Introduction} This manual describes the \LaTeX\ to HTML converter {\tt cc\_manual\_to\_html}. The converter is accompanied by a \LaTeX\ style file, {\tt latex\_converter.sty}, that defines a couple of macros for HTML output which are then usually ignored in the \LaTeX\ formatting, for example, hyper-links. The converter is a full fledged \LaTeX\ interpreter and understands most of \LaTeX2e's language repertoire including user macro definitions and several additional style files. Examples for the additionally supported style files are {\tt alltt}, {\tt path}, {\tt cprog}, and {\tt cc\_manual}~\cite{k-clswr-99}. In fact, the converter is, similar to \TeX, realized as a macro-expansion engine and a set of style files. Currently, restrictions of the converter are mostly in the area of complex formulas, complex tables and figure environments. The converter does not repeat the layout of \LaTeX\ in HTML. Instead, it tries to find a logical translation into HTML which may result in a different layout. The following sections stretches from the documentation of the \LaTeX\ style file to the use, configuration, and some internal implementation details of the converter. We start with the new macros and environments to support HTML generation in the new style file. We continue with an introduction to the assumed structure of the manual and the induced output files using the converter. The use of the converter is subdivided into two section. The first section documents the usual converter call to translate a single document. The second section addresses how to convert a larger manual spread over several subdirectories. Such an organization of the manual helps in the case of name clashes, e.g., two concepts of the same name. Thereafter we discuss the part of \LaTeX\ covered with our converter and give a list of unsupported macros. In the remaining sections we go into some implementation details of the converter and its internal macros that can help to implement own style files for the converter. % ------------------------------------------------------- \section{\LaTeX\ Style File {\tt latex\_converter.sty}} \label{sectionHTMLsupport} The converter distinguishes different text coding standards: {\em text} for the usual \LaTeX\ source text, {\em ascii-text} for ASCII encoded text, {\em html-text} for HTML encoded text, and sometimes others. \def\lcIx #1\lcIxEnd{\lcIndex{#1}} \def\lcIxE #1\lcIxEnd{\index{#1 environment@{\tt #1} environment}} \newcommand{\plainitem}[1]{\item[{\normalfont {\tt #1}}] \lcIx #1\lcIxEnd~\par} \newcommand{\macroitem}[1]{\item[{\normalfont {\tt \Backslash #1}}] \lcIx #1\lcIxEnd~\par} \newcommand{\macroitemX}[2]{\item[{\normalfont {\tt \Backslash #1\Open}{\em #2\/}{\tt\Close}}]\lcIx #1\lcIxEnd~\par} \newcommand{\macroitemXX}[3]{\item[{\normalfont {\tt \Backslash #1\Open}{\em #2\/}{\tt\Close\Open}{\em #3\/}{\tt\Close}}]\lcIx #1\lcIxEnd~\par} \newcommand{\macroitemXXX}[4]{\item[{\normalfont {\tt \Backslash #1\Open}{\em #2\/}{\tt\Close\Open}{\em #3\/}{\tt\Close\Open}{\em #4\/}{\tt\Close}}] \lcIx #1\lcIxEnd~\par} \newcommand{\macroitemXOX}[4]{\item[{\normalfont {\tt \Backslash #1\Open}{\em #2\/}{\tt\Close[}{\em #3\/}{\tt]\Open}{\em #4\/}{\tt\Close}}] ~\par} \newcommand{\macroitemXXXX}[5]{\item[{\normalfont {\tt \Backslash #1\Open}{\em #2\/}{\tt\Close\Open}{\em #3\/}{\tt\Close\Open}{\em #4\/}{\tt\Close \Open}{\em #5\/}{\tt\Close}}]\lcIx #1\lcIxEnd~\par} \newcommand{\envitem}[2]{\item[{\normalfont {\tt \Backslash begin\Open #1\Close}{\em\ #2 }{\tt \Backslash end\Open #1\Close}}] \lcIxE #1\lcIxEnd~\par} \newcommand{\envitemX}[3]{\item[{\normalfont {\tt \Backslash begin\Open #1\Close\Open}{\em #2}{\tt\Close}{\em\ #3 }{\tt \Backslash end\Open #1\Close}}]\lcIxE #1\lcIxEnd~\par} \begin{description} \macroitemX{lcRawHtml}{html-text} Outputs {\em html-text\/} without any formatting, i.e., {\em html-text\/} is supposed to be in HTML format. \macroitemX{lcRawHtmlExpanded}{html-text} Outputs {\em html-text\/} without any formatting, i.e., {\em html-text\/} is supposed to be in HTML format, except that if {\em html-text\/} starts with a macro, this macro is expanded before the output. \macroitemX{lcAsciiToHtml}{ascii-text} Outputs {\em ascii-text\/} which is supposed to be in ASCII format. Creates the necessary conversions for the special characters of HTML. \macroitemX{lcTex}{text} Encapsulates {\em text\/} that is only meant to be formatted in \LaTeX. It is ignored during the conversion. \macroitemX{lcHtml}{text} Encapsulates {\em text\/} that is only meant to be formatted with the converter to HTML. \envitem{lcTexBlock}{text} Encapsulates {\em text\/} that is only meant to be formatted in \LaTeX. It is ignored during the conversion. \envitem{lcHtmlBlock}{text} Encapsulates {\em text\/} that is only meant to be formatted with the converter to HTML. \envitem{lcRawHtmlBlock}{html-text} Encapsulates {\em html-text\/} that is only meant to be formatted with the converter to HTML. The {\em html-text\/} is supposed to be in HTML and is written literally to the output. \macroitemXX{lcAnchor}{URL}{text} Formats text and surrounds it with an anchor pointing to {\em URL}. \end{description} The remainder of this section addresses possible customizations of the converter with respect to the {\tt cc\_manual.sty} style file (see~\cite{k-clswr-99}). The conversion usually creates a new file for each class with the class name as file name. In addition it adds an entry to the table of contents, to the index, and it links all occurences of this class name in all other places of the manual to point to its place of declaration. For a manual documenting classes in a single namespace this behavior is reasonable. For other purposes, more flexibility is provided here. One example are class requirements that can be documented like a class but they are nowhere implemented. The flexibility introduced here separates apart the creation of the file, the table of contents entry, the index entry, the automatic cross linking and the layout management of the class. The \verb+ccClass+ and \verb+ccClassTemplate+ environments are responsible for the layout and class name variable managment (e.g.~the \verb+\ccClassName+ variable). The other default mechanisms can be deactivated for a single environment with the following macros by placing them right before the environment. These macros also influence local declarations like \verb+\ccStruct+ within the class environment. Since \verb+\ccFunction+ denotes global functions, they are not involved. For this purpose and for global declarations the \verb+\ccHtmlNoLinks+ deactivates the automatic cross linking and \verb+\ccHtmlNoIndex+ deactivates the automatic index generation of the declaration following these macros. \index{table of contents} \ccIndexEntry{ccHtmlNoClassToc} \ccIndexEntry{ccHtmlNoClassFile} \ccIndexEntry{ccHtmlNoClassLinks} \ccIndexEntry{ccHtmlNoClassIndex} \ccIndexEntry{ccHtmlNoLinks} \ccIndexEntry{ccHtmlNoIndex} % \begin{tabbing} M \= CCimplementationNNNMM \= ImplementationMMMMM \= \kill \> \verb+\ccHtmlNoClassFile+ \> deactivates the creation of an own file\footnotemark.\\ \> \verb+\ccHtmlNoClassLinks+ \> deactivates the cross linking for this class name.\\ \> \verb+\ccHtmlNoClassToc+ \> no entry into the table of contents for this class. \\ \> \verb+\ccHtmlNoClassIndex+ \> no index entries for this class. \\ \> \verb+\ccHtmlNoLinks+ \> no cross linking for the following declaration. \\ \> \verb+\ccHtmlNoIndex+ \> no index entry for the following declaration. \end{tabbing} \footnotetext{A class without its own file will be formatted in the enclosing chapter file. The embedded layout within this chapter file may be not be optimal and might be customized with the {\tt HTML} specific macros.} The \verb+ccHtmlClassFile{+{\em filename\/}\verb+}{+{\em desc\/}\verb+}+ environment enclose parts of the manual that are written to their own file with name {\em filename}. The parameter {\em desc\/} contains a descriptive text that will be placed in the anchor in the chapter file and in the table of contents to refer to this new file. Note that class files cannot be nested and neither can this file. Within this environment new class environments will automatically be stopped to create own files. \index{htmlclassfile environment@{\tt ccHtmlClassFile} environment} \index{class files} \begin{tabbing} M \= CCimplementationNNNMM \= ImplementationMMMMM \= \kill \> \verb+\begin{ccHtmlClassFile}{My_point.html}{Declaration of \ccc{My_point}}+ \\ \> \ldots\\ \> \verb+\end{ccHtmlClassFile}+ \end{tabbing} \ccIndexEntry{ccHtmlCrossLink}\index{crosslinking} The macro \verb+\ccHtmlCrossLink{+{\em C-idfier\/}\verb+}+ activates the automatic cross linking for the given C identifier {\em C-idfier}. The generated links will point to the place where this macro is placed. The following example demonstrates the explicit coding to achieve the default cross linking for template classes including the option that the template argument {\tt R} is captured with the anchor's text if possible. \begin{tabbing} M \= CCimplementationNNNMM \= ImplementationMMMMM \= \kill \> \verb+\ccHtmlCrossLink{My_point}+ \\ \> \verb+\ccHtmlCrossLink{My_point}+ \end{tabbing} The index is organized in categories. The macros \verb+\ccHtmlIndex[+{\em category\/}\verb+]{+{\em key\/}\verb+}+ and \verb+\ccHtmlIndexC[+{\em category\/}\verb+]{+{\em C-idfier\/}\verb+}+ have an optional parameter to state the category for the {\em key\/} or the {\em C-idfier}. If the optional argument is missing the entry will be made for a class name. Possible categories are: {\tt class, nested\_type, struct, enum, enum\_tags, typedef, variable, function,} and {\tt member\_function}. An index entry will point to the place where its generating macro is placed. The difference between both macros is that \verb+\ccHtmlIndexC+ parses C code in its argument {\em C-idfier}. \ccIndexEntry{ccHtmlIndex}\ccIndexEntry{ccHtmlIndexC}\index{index} \begin{tabbing} M \= CCimplementationNNNMM \= ImplementationMMMMM \= \kill \> \verb+\ccHtmlIndex[function]{Style guides for functions}+ \\ \> \verb+\ccHtmlIndexC{My_point}+ \end{tabbing} % ------------------------------------------------------- \section{Manual Structure and Induced Output Files} \index{document structure}\index{structure of document}\index{online manual} The tools for the conversion to an online {\tt HTML} manual impose certain restrictions on the \LaTeX\ specification. Each chapter and each reference page or class defining environment ({\tt ccRef}{\em Category}, {\tt ccClass}, {\tt ccClassTemplate}, and {\tt ccHtmlClassFile} from {\tt cc\_manual.sty}, see~\cite{k-clswr-99}) opens a new file. For a chapter, the new file gets the filename of the current \LaTeX\ file with the prefix {\tt Chapter\_} and the file suffix {\tt .html}. For a reference page, the new file gets the filename of the item documented in this page with a prefix according to its {\em Category} (avoiding name clashes) and the file suffix {\tt .html}. For a class defining environment, the new file gets the name of the class as filename with the postfix {\tt .html} added. These conventions make hyper-linking easier. A set of requirements and recommendations follow from these conventions. \begin{itemize} \item All files in one directory. \item No two chapters in one file. A chapter macro should be located at the beginning of a file. \item No nesting, i.e., no chapter or class definition within a class defining environment. (The conventions impose a two-level file hierarchy.) Class defining environments within a reference page are allowed, but they will not create a new file in this case. \item No two classes, concepts, etc., of the same name in one manual. \end{itemize} Section~\ref{sectionHtmlExtended} describes an extended conversion model using multiple directories to overcome the filename problem. Section~\ref{sectionHTMLsupport} explains how the file generation of reference pages and class environments can be customized with \verb+\ccHtmlNoClassFile+ and the environment {\tt ccHtmlClassFile} to gain more flexibility. \index{title page}\index{show\_main@{\tt -show\_main}} By default, a \LaTeX\ file is assumed to start with a chapter macro or a class defining environment. Any pieces of \LaTeX\ code in front of it are most probably definitions and not meant for conversion. For example a complete manual starts with a title page and the table of contents. These are provided by other means for the online {\tt HTML} manual, i.e., the title page, {\tt title.html}, has to be written manually, and the table of contents, {\tt contents.html}, is automatically generated. In the case of a file without a chapter macro or a class defining environment the conversion result for this part can be directed to the stdout using the command line option {\tt -show\_main}, see below. % ------------------------------------------------------- \section{Conversion Tools} The conversion of a specification to an online {\tt HTML} manual is a two step process. In the first step, all \LaTeX\ files are converted to {\tt HTML} files. Meanwhile auxiliary information about \Dindex{hyper-links} are collected. In the second step, the hyper-links are added to all {\tt HTML} files. The {\tt csh}-script {\tt cc\_manual\_to\_html} integrates the first and the second step. It uses the program {\tt cc\_extract\_html}, which does the first part, the program {\tt flex}, which generates the filter program to add the hyper-links, the standard C compiler {\tt cc}, and the program {\tt cc\_index\_sort}, which sorts the index case-insensitive. The synopsis for the script {\tt cc\_manual\_to\_html} is: \ind{\tt cc\_manual\_to\_html [] } This command translates all LaTeX files in its command-line to {\tt HTML} files. All files included with the \verb+\input+ or \verb+\include+ macros of \LaTeX\ are converted as well. The converter {\em does not\/} understand the \verb+\includeonly+ macro. In summary, the converter can translate a complete manual at once if it is called only with the main \LaTeX\ file. \Mindex{input}\Mindex{include}\Mindex{includeonly} \index{bibliography}\TTindex{BiBTeX}\index{auxiliary file} \Mindex{bibcite}\Mindex{bibitem} The converter supports the generation of an {\tt HTML} bibliography called {\tt biblio.html}. If the bibliography is generated using BiB\TeX\ the {\tt *.bbl} file should be given to the converter. If the bibliography is written by hand using the \verb+thebibliography+ environment the file containing this environment also should be in the list of conversion files. In both cases, the related {\tt *.aux} will contain \verb+\bibcite+ entries that are needed to generate proper labels instead of the internally used citation keys. However, if the bibliography is written by hand with optional arguments in the bibitem entries the {\tt *.aux} file is not necessary (these optional arguments also will be used by \LaTeX\ to label the citations). The \verb+\+\verb+ref+ macros in \LaTeX\ will be instrumented with \Dindex{hyper-links} to the bibliography. A table of contents {\tt contents.html} and an index {\tt manual\_index.html} are always automatically generated. A handwritten title page {\tt title.html} is assumed, but not supplied. A common page layout on all pages guarantees easy navigation through the different files. \index{title page}\index{table of contents}\index{index} Available command line options for {\tt cc\_manual\_to\_html} are: \begin{tabular}{ll} {\tt -defaults} & show the settings of the internal variables.\\ {\tt -extended} & extended conversion model, see Section~\ref{sectionHtmlExtended} \\ {\tt -ref\_manual} & for manuals split into user and reference parts, see Section~\ref{sectionHtmlExtended} \\ {\tt -show\_main} & print the translation result for the main file to stdout.\\ {\tt -date } & set a date for the manual. Default: system date.\\ {\tt -release } & set a release number for the manual. Default: empty\\ {\tt -title } & set a title text for the manual.\\ & Default: ``Reference Manual''.\\ {\tt -author } & set an author address (email) for the manual. \\ & Default: ``The \cgal\ Project''. \\ {\tt -config } & path to the configuration files.\\ {\tt -tmp } & temporary directory to keep all intermediate files.\\ {\tt -header } & set the path where the C headers are.\\ {\tt -o } & output directory for the generated {\tt HTML} manual.\\ {\tt -aux } & \LaTeX\ auxiliary file with the \verb+\bibcite+ entries.\\ {\tt -bbl } & bibliography file produced by BiB\TeX.\\ {\tt -sty