You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by Christian Lerch <ch...@km-works.eu> on 2010/03/23 15:56:26 UTC

JSPWiki + MathML

Hi folks,

I recently did a little hack with JSPWiki 2.8.3 which I thought 
(encouraged by Janne) may be of interest.

My goal was to find a quick and easy way to turn a wiki into a 
mathematics notebook.
As it turned out it was even much easier with JSPWiki then I had expected.

What I did was:

1. I changed the ContentType in Wiki.jsp to "application/xhtml+xml" from 
"text/html"

2. I wrapped the StringWriter in class XHTMLRenderer

///-StringWriter out = new StringWriter();
Writer out = new AMathFilterWriter(new StringWriter()); ///+

with my FilterWriter, which in essence scans the Stream for a pair of 
backticks, where it expects an ascii math expression which it can 
translate into full-blown MathML 2.0 on-the-fly. The resulting MathML 
fragment will then get inserted directly into the page download. 
Mozilla, as you may be aware, can display this stuff without any add-on.

With these 2 little changes I already can do some very exciting things 
(see attached).

Of course that's a terrible hack, and the are certainly better ways of 
doing the same.

However, what I'm asking you to consider for v3.0 is to decide if you 
can switch to ContentType "application/xhtml+xml" in the core. This 
could be a basis to add this and other XML applications (like svg or 
rdf) to JSPWiki with ease. Of course there is some work to do to escape 
the then toxic user input like <, & and > (I think JDOM can do that) and 
sanitize some of the JavaScript directly embedded in jsp (I realized 
later on that there is some XML-incompatible stuff in there too, like 
"&&" etc.).

Please let me know what you think.

Regards,
Christian