On Mon, Nov 25, 2002 at 11:58:03PM +0100, Tomasz Wegrzanowski wrote:
On Mon, Nov 25, 2002 at 11:47:27PM +0100, Jens Frank wrote:
Hi,
I already hacked something similar, and I render "simple" formulas as HTML if possible (e.g. only letters, +, -, *, /, exponents and indices). At the moment I don't have the time to get it to a production level quality (and I think as long as we have these performance problems we should not add the load of generating lots of little images to the poor server). Are you interested in taking a look at the code?
Sure, send it to me.
Here you are. It works like this:
- Formulas are given in the normal article as [[math:a+b]]. - The PHP-Render-Code checks whether the formula is "simple", whether it only contains constructs like letter, +, -, *, /, exponents and indices. If yes, the formula is rendered as HTML, => Exit. - The PHP-Render-Code checks whether an image for this formula exists. As filename a MD5-Hash of the formula is used. - If it does not exist, a TeX-File containing some header and footer is generated and passed to a skript generating a PNG. - The image link is added.
I do not parse the TeX-code. There are *much* to many allowed constructs. I just grep for two not allowed constructs.
Both the HTML-Formula or the image are stored to the database for caching purposes.
If latex fails to parse the file, I start up latex to render the error message into a PNG. So only the tex2png-Skript has to handle exceptions.
Regards,
JeLuF