[l2h] web-user on-demand latex2html

Franco Bagnoli bagnoli@dma.unifi.it
Tue, 4 Dec 2001 11:57:03 +0100 (CET)


On Mon, 3 Dec 2001, COLE KEVIN wrote:

> Hello,
>
> I have been using latex2html for about 2 years as the primary means to
> post mathematical content (Green's functions) on the web.
>
> Does anyone have experience with "on demand" LaTeX-to-html
> conversion?  I am interested in taking input from a user through menus
> (or something similar), constructing math expressions ("answers"), and
> making them visible to the user by posting them, all in the background in
> response to a web user's request.  Since my math content already exists in
> LaTeX form, it would be helpful if an existing conversion program could be
> adapted to this use.
>
> Thanks in advance for any suggestions.

I set up a wiki system allowing users to enter latex expressions and
converting them to html on the fly. I tried tth, which is handy since it
produces "pure" html (no gifs), but then switched to latex2html which is
by far more accurate.

The approach I followed is the following:

Suppose the math you intend to convert is embedded in <math> </math> tags,
say

This is a simple document with <b>math expressions</b> inside:
<math>
\begin{equation}
  f(x) = \int_-3^x g(t) dt
\end{equation}
</math>

(which is not good xml...)

- replace <math> with \end{rawhtml} and </math> with \begin{rawhtml}
- add the necessary header (macros, declarations, \begin{rawhtml}) and
footer (\end{rawhtml} \end{document}
- save it using a given filename (generally a unique filename)
- call latex2html with the necessary options with respect to paths
- check the output for errors
- read the generated html and returns it to the browser

The problem with latex2html are:

1) it needs a directory for each text, so the cgi has to manage the
creation of directories which have to be deleted by a cron job (I assume
some kind of unix, actually I'm using linux).

2) image creation is rather slow.

I though I could partially overcome these problems by separating the html
conversion from the image generation. The first step would be that of
setting up an math image server: given a tex fragments it returns the name
of the gif file, which can be present or created on the fly. In this way
one can easily recycle the images on a per-web basis (instead of the
present per-document). Using a database, maximum image fragmentation and
the same options for all documents would give the best results. This
approach has and also some other advantages, like an easy transition to
mathml.

3) It would be simpler from the program point of view if latex2html could
be called as a function (instead of like an external program)

4) It should be re-written so to run under mod_perl, using an object
syntax in order to isolate the global variables (and dynamical
programming) and also to be able to recycle common parts:
suppose all my documents starts with some predefined packages. It would
speed a lot their processing if I could do something like:

#this is the initialization part

$persistent_l2h_object = latex2html->new($common_header);

.....
#this happens after a request

$request_handler = $persistent_l2h_object->clone();
$request_handler->process($variable_text);

print "Content-type: text/html\n\n",
	$request_handler->print_html();

5) It would be also nice to have an apache module to serve latex files in
a transparent way, so that users have only to put their latex file in a
public directory, and they could be retrieved in latex or pdf just by
fetching them:

http://server/~user/file.tex  returns the tex file
http://server/~user/file.pdf  returns the pdf file (if the pdf file is not
actually present)
http://server/~user/file.html returns the html file (if...)


At present I have no time to dedicate to this, but I hope my situation
will change next year (it may even be worse).

Bye.

-- 
Franco Bagnoli (franchino) <bagnoli@dma.unifi.it>
Dipartimento di Matematica Applicata "G. Sansone" - Universita' di Firenze
Via S. Marta, 3 I-50139 Firenze, Italy. Tel. +39 0554796422, fax: +39 055471787
GPG Key fingerprint = 169D 9EA5 8FD3 7EDA E43A  9830 255F BCEC 0D63 3728