On Mon, Nov 25, 2002 at 11:30:09PM +0100, Tomasz Wegrzanowski wrote:
My idea is like this: string render_math(string text) { tree parse_tree = parse_and_validate (text); if (parse_tree != NULL) { string new_text = render_tex(parse_tree); string hash = md5(new_text); string file_name = file_prefix + hash; if (file_exists(file_name)) return "<img ... alt=" + htmlattr_escape(text) + ">"; else if (tex_render(new_text, file_name)) return "<img ... alt=" + htmlattr_escape(text) + ">"; else return "<b>Warning: couldn't render: " + wiki_escape(text) + "</b>"; } else { return text; } }
Where: md5() - obvious file_prefix - obvious httmlattr_espace() - obvious wiki_escape() - obvious file_exists() - obvious tex_render() - call external tex rendering program parse_and_validate() - generated LALR parser which checks if TeX is safe. If it doesn't understand it, then it's NOT safe. render_tex() - render TeX string from tree. Place to add all extra features, alternative syntaxes etc. In easiest version just copies first text.
What do you think ?
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?
Regards,
JeLuF