MathML in s9y

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Little Hamster
Regular
Posts: 62
Joined: Thu Oct 07, 2004 3:16 pm

MathML in s9y

Post by Little Hamster »

I'd like to display equations using MathML within the blog entries. With some not so pretty hacks, I can display equations correctly on the blog frontpage, but not in the entry preview. I'd like some help with this one. FYI, I'm using 0.8 beta 4.

To use MathML, s9y has to be patched to:
1. serve pages with

Code: Select all

header("Content-Type: application/xhtml+xml");
2. begin pages with the following

Code: Select all

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
              "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
My questions are:
1. where should I put the PHP header code in s9y?
2. is there a way to add the doctype + html snippet to all the pages created by s9y? I can see the index.tpl for the front page, but couldn't find the one for the preview.
3. s9y puts <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />, should I remove all these meta tags?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: MathML in s9y

Post by garvinhicking »

1. The PHP header code can be put into a plugin using the frontend_configure hook. Or within the config.inc.php file inside your template directory.

2. No, you'll need to edit the index.tpl page. The preview uses non-templatable code inside the file 'include/functions_config.inc.php' function serendipity_is_iframe(). Efforts have been made in the past to easy that up, and Evan Nemerson wanted to work on XHTMLoutput. On the mailinglist there'd been a patch to use it, though.

3. I think those meta-tags shouldn't interfer with your doctype, so no need to remove it AFAIK.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

I'm not sure what your requirements are, but you might also look at http://cvs.sourceforge.net/viewcvs.py/p ... t_mimetex/

It is a plugin which acts as a wrapper for the mimetex executable (http://www.forkosh.com/mimetex.html) and should display most TeX strings as a gif... the gifs are referenced as images with a php page as the source, and the TeX string as a query string.

I don't think it is as nice as MathML, but I found it easier to support...

I haven't really explored MathML as much as I'd like, and would love to see the results of your labor!

Matt
Little Hamster
Regular
Posts: 62
Joined: Thu Oct 07, 2004 3:16 pm

Post by Little Hamster »

Gavin, I couldn't find the xhtml patch you mentioned. For the admin page, I tried editing serendipity_admin.php. The main admin page is well formed XML, but some of the subpages aren't, mostly relating to javascripts with && and <=. (For example, in personal settings and the entry preview). There's also minor stuff like some of the styles have "Author: Kaustubh Srikanth & Tom Sommer<br />".

I've also edited serendipity_is_iframe() include/functions_config.inc.php'. But this doesn't seem to do anything.

Matt, I'll have a look at your plugin. If it converts equations written in LaTeX to gifs, then it'll suit what I want. I wonder about whether it's a sane thing to write a plugin using MathML, since it requires patching s9y, and every new release will need a new patch.
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

When I wrote the mimetex plugin I looked at a couple of different solutions... I didn't like the MathML stuff for three reasons (two of which are personal problems, not technical *grin*).

MathML support is poor: IE has a thridparty plugin to make it work, and even Firefox has to download Math fonts to use it...

I didn't see a nice way to input MathML into posts (a personal problem): I don't know the MathML structure and it looks like it would take a while to learn.

I don't know XHTML/MathML (a personal problem): I'd love to learn the XHTML and MathML specs, but I don't have the time.. And trying to do a plugin without understand those specs would have hurt.

I did look at some ideas, though:

MimeTex is pretty poor resolution.. eveyone who knows such things says that using latex and imagemagick will produce better results. An example is latexrender (http://www.mayer.dial.pipex.com/tex.htm#latexrender), which actually has a number of plugins for various packages (including Wordpress). I ruled this out because it would require two executables to be called and I didn't want to have to learn/code conversion process. Latexrender does have a class file which might be useful.. it might be easy to modify the event_mimetex plugin to use it.

itex2mml looks very promising... http://pear.math.pitt.edu/mathzilla/itex2mml.html
I plan to come back to this solution this summer sometime... It is an executable which looks like it can parse html with itex syntax strings in it and convert the appropriate portions to MathML. I believe one could write a markup plugin for serendipity which would be a wrapper for this... if this is the case (and I understand XHTML to any degree, which I'm not sure on) you could send the appropriate headers using frontend_configure and dynamically do the markup... which should work in the preview, etc....

Like I said, I'm not sure on itex2mml since I don't know anything about xhtml.. But I do plan to look at it, since it offers a sane way to enter data directly to a post and still use MathML... And I think getting MathML as a commonly used standard makes tons of sense.

Hope that helped..
Little Hamster
Regular
Posts: 62
Joined: Thu Oct 07, 2004 3:16 pm

Post by Little Hamster »

MathML support is poor: IE has a thridparty plugin to make it work, and even Firefox has to download Math fonts to use it...
I agree with the IE bit. It's a bummer if your readers prefers IE over firefox, and there are a lot of IE supporters. As for support in firefox, even though you need to install extra fonts to get 100% out of mathML, you can pretty much see most of the symbols with standard fonts (in linux at least). As far as I can see, only \sqrt isn't displayed properly.
I didn't see a nice way to input MathML into posts (a personal problem): I don't know the MathML structure and it looks like it would take a while to learn.
I'm using itex2mml :) Haven't cracked the cryptic mathml syntax yet.
I don't know XHTML/MathML (a personal problem)
To get XMHTML working, we should ideally get the support of the s9y team. For example, in the admin suite, it loads the info.txt and some javascripts. Some of them contain text that aren't allowed in XML (& &lt, the usual suspects), and should be changed to the corresponding entity references. Also, some javascript functions aren't allowed in XHTML, like document.write() (google for an explanation).

By the way, I've installed your mimetex plugin, it works like a charm.
Beau
Posts: 1
Joined: Thu Oct 05, 2006 12:23 pm

status?

Post by Beau »

Hello,

Any progress for MathML or LaTeX support? I would love the LaTeX support similar to http://www.mayer.dial.pipex.com/tex.htm#latexrender

Greetings,
Beau
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

I haven't come back to the latexrender solution... Let me try to get the various components installed on my server and see what I can do.

Do you have the mimetex plugin working? Because I will probably just roll any changes into that plugin...
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

Ok, I have a rough out of the plugin, but I am having significant problems getting tetex installed on my server... (OpenBSD 3.8, no X11... I might have to upgrade to get it up, or I might just be able to update my ports... I'm still deciding.)

So, I will pursue getting tetex working, but I can send a copy of the plugin to anyone willing to test it in the mean time. I am using a modified version of the latexrender php (to set paths, etc, nicely), but I have no idea how solid the modifications are (ie, it isn't going to work out of the box, so you might have to fiddle with the php code a bit... particularly paths).
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

Ok, I have a working version of teTeX (Yay ports!), and I just commited a version of the mimetex plugin which allows the user to choose the render engine they would like to use.

It is version 0.8, and should be available in spartacus within 24 hours.

The difference is pretty clear:
MimeTex:
Image

LaTeX:
Image

Please let me know if you have an comments/questions/problems.
Post Reply