[l2h] Example of Perl do_cmd_* implementation

Ross Moore ross@ics.mq.edu.au
Fri, 15 Mar 2002 07:54:22 +1100 (EST)

> Could someone please send me a sample implementation of a Perl
> implementation of a \def of the following form?
>     \def\foo#1{A\bar{#1}B},

The problem here is that  \bar{#1}  can only be represented in an HTML
page by constructing an image. You are then faced with the choice of
do you want the  A and B  within the image as well?

If yes, then it will be appropriate to implement a  do_cmd_foo
subroutine; but if not, then a LaTeX macro definition is enough
to allow LaTeX2HTML to "get it right" by itself.

> where A and B are specific strings which can be included verbatim in
> the HTML output, and \bar is a predefined LaTeX macro.  An example:
>     \def\program#1{`\texttt{#1}'}

For this, the LaTeX definition is enough.
You just have to ensure that LaTeX2HTML actually sees the definition.

I'm guessing that you have this definition already, within your own
.sty or .cls file; but LaTeX2HTML is not reading this file.
Is that correct ?

Then the easiest thing to do is to make a copy of that .sty file,
and use a .tex extension. Remove all complicated macro definitions,
of things that are not relevant to HTML, or see below ....

Your documents can have "conditional coding", as follows:


 \input mystyles.tex

Rather than removing coding from mystyles.tex , 
it is better to just surround blocks of coding with conditional comments:


If you do this, then  mystyles.tex  and  mystyles.sty  can be
 *the same file*. It will now work correctly with both LaTeX
and LaTeX2HTML. Just let  mystyles.tex  be a symbolic link to the  .sty .
You can even define the same macro in 2 different ways; one for LaTeX,
the other for HTML.

> I tried to find an example of this kind of do_cmd_* implementation,
> but I had no luck.

It's generally much easier to think in LaTeX, with alternate definitions
for the kind of output that you want, than to think in Perl for a way
to implement it, which dovetails with the LaTeX2HTML method of processing.

HGope this helps

	Ross Moore
> -- 
> Florian Weimer 	                  Weimer@CERT.Uni-Stuttgart.DE
> University of Stuttgart           http://CERT.Uni-Stuttgart.DE/people/fw/
> RUS-CERT                          +49-711-685-5973/fax +49-711-685-5898
> _______________________________________________
> latex2html mailing list
> latex2html@tug.org
> http://tug.org/mailman/listinfo/latex2html