Thursday, 21 January 2010

MathML on the Clipboard

I got a new machine at work with Windows 7 on it.

One of the more interesting applications coming with Windows 7 is the Math Input Panel. This is designed for pen input on a tablet-style device and performs pretty impressively accurate recognition of mathematical expressions. While designed for a tablet, it also works pretty well if you are just “writing” the expression with a finger on a small laptop trackpad, which is how I have been using it.

The Math Input Panel is designed with a very simple interface with virtually no customisation options. It offers no way of saving the expressions generated and just offers a simple insert button that tries to insert the math expression at the insertion point in a currently open application. This works well for Word 2007 which accepts MathML from the clipboard and transparently converts it to its internal form and renders it, but other more generic tools such as XML editors that could use the MathML do not accept MathML from the clipboard in this way. Unlike MathPlayer or Word, The Math Input Panel doesn't offer fallback text representations of the XML markup on the clipboard. Marko Panic, the program manager for the development of this tool confirmed to me that this was a design decision as they didn't want the end user to be faced with raw XML. This is not unreasonable but not what I wanted personally (I like to see my XML raw:-). Marko confirmed that the MathML is on the clipboard and it should be possible to extract it with a few lines of code, or if I wanted a more extensive customisation there was documentation of the API offered by the underlying DLL available at
http://msdn.microsoft.com/en-us/library/dd317324(VS.85).aspx
and
http://msdn.microsoft.com/en-us/library/dd317311(VS.85).aspx.

I decided to brush up my C# forms programming and produced a small form that shows any MathML on the clipboard. The main code (everything apart from the boilerplate Visual Studio files) is available on google code While it's particularly useful to see the MathML generated by the Math Input panel, it also works with other applications, notably MathPlayer and Word, that place MathML on the clipboard.

While looking via Google for some programming tips on my form, I came across a very similar blog posting from last year. That form had some differences though (displaying the IE folding tree view of the XML) so I completed my form here. The screenshot shows the Math Input Panel interpreting my appalling handwriting, and the mmlclipboard form displaying the generated MathML.



Sunday, 20 December 2009

XSLT for Presentation MathML in a Browser

Back in 2002 at the MathML Conference I presented a stylesheet, pmathml.xsl, that detected the browser being used and inserted whatever was necessary to enable MathML on that platform. The stylesheet is distributed, along with the slides from the conference presentation, from the W3C Math/XSL area.

The stylesheet is showing its age, in particular a large part of its complexity is due to the fact that that it encodes two completely separate languages in one file, XSLT, and the ‘wd-xslt’ language used in IE5. IE 5 is not an important platform these days, and for some years MathPlayer has been able to act as a MIME Filter in Internet Explorer, and so automatically insert the needed object references into the document without using an XSL stylesheet. However the XSL stylesheet mechanism still has uses, and may be adapted to other browsers. An updated version of this stylesheet has been in use for the NAG Library documentation.

I have placed an updated version of pmathml.xsl on google code. This loses all the wd-xsl code so requires IE6 or later, but it detects Opera and Safari and in that case inserts some extra elements to make it more likely that the documents meets the conditions of the MathML profile for CSS, and links to some CSS to render the resulting elements. The CSS is a combination of some old CSS of mine and George Chavchanidze's CSS developed as part of the MathML profile for CSS.

Unfortunately xlink links no longer work in Firefox 3, and so this version uses some javascript to give link behaviour to any element with an xlink:href attribute. Since it is doing this it also enables links for unprefixed href attributes, in anticipation of MathML3's href attribute for linking.

I hope to extend this to enhance MathML3 support, rendering the new MathML3 features as far as possible in existing browsers. The current check in is mainly to form a baseline in google code before adding any new MathML3 features.

Friday, 18 December 2009

MathML as ASCII Art

Normally one wants to use a full typesetting system, and access to fonts with a rich variety of symbols to typeset mathematics. But sometimes you don't.

Plain text, restricted to ASCII, still has its uses. It is possible to lay out the 2-dimensional mathematical notations as a kind of ‘ASCII-art’. Historically in the days before GUI workbook-style interfaces most Computer Algebra systems would use this kind of layout, and they can usually still be persuaded to use this style even in current versions.

I've just made available a very old stylesheet, it was I think one of the first XSLT 2 stylesheets that I wrote, which renders MathML in this style. It still does not do all of MathML3 (or 2) presentation MathML, but I intend to extend it as time permits.

The stylesheet is available on google code and some examples running against the MathML test suite are shown below.

The google code project also has the htmlparse styesheet discussed previously in this blog, and a perhaps more serious XSLT stylesheet to render MathML via TeX, again that will be extended to cover most of MathML3, as part of the MathML CR implementation phase – something to do over the Christmas break. Documentation of exactly what's in the project will be added eventually, it's only been running a day.


sum1
test suite image
infinity  
  ----    
   \      
    )   x 
   /     i
  ----    
 i = 0    

msubsup1
test suite image

 1    
/  x  
| e dx
/     
 0    

mtable2
test suite image

                                                     2          2                          
1                     x + y                         x  + 2yx + y                           
                       2          2                  3      2     2     3                  
x + y                 x  + 2yx + y                  x  + 3yx  + 3y x + y                   
 2          2          3      2     2     3          4      3     2 2     3     4          
x  + 2yx + y          x  + 3yx  + 3y x + y          x  + 4yx  + 6y x  + 4y x + y           
 3      2     2     3  4      3     2 2     3     4  5      4      2 3      3 2     4     5
x  + 3yx  + 3y x + y  x  + 4yx  + 6y x  + 4y x + y  x  + 5yx  + 10y x  + 10y x  + 5y x + y 

mfrac4
test suite image
       _ 
1 +  \|5 
---------
    2    

Wednesday, 16 December 2009

MathML3 article at IBM developerWorks

IBM developerWorks have just published an article that I wrote on on MathML3, http://www.ibm.com/developerworks/xml/library/x-mathml3. I doubt that it has any information new to readers of this blog, but perhaps it may reach a new audience and spread the word about MathML3.

Tuesday, 15 December 2009

Candidate Recommendations

I'm pleased to be able to announce that the Candidate Recommendation drafts of MathML3 and the MathML for CSS profile are available at http://www.w3.org/TR/2009/CR-MathML3-20091215/ and http://www.w3.org/TR/2009/CR-mathml-for-css-20091215/.

It is during this Candidate Recommendation phase that implementation work needs to begin in earnest as we need to show via the test suite that all the features are implemented by two implementations.

Friday, 11 December 2009

Thoughts on Revising DSRL

A while ago now, I posted an article on DSDL. In it I commented that part 8, DSRL, had a lot of problems. The new Project Editor, Francis Cave, has recently posted the first cut at a revised draft of DSRL, and also posted some thoughts from me suggesting some more extensive revisions that could be made.

The posting can be seen in the public archives of dsdl-discuss at http://lists.dsdl.org/dsdl-discuss/2009-12/0002.html. dsdl-discuss is a closed list for members of SC 34/WG 1, however comments are welcome on the public list dsdl-comment 'at' dsdl.org archived at http://lists.dsdl.org/dsdl-comment/.

Tuesday, 17 November 2009

XML Entity Definitions for Characters

I'm pleased to announce that the last call draft of XML Entity Definitions for Characters has been published:

http://www.w3.org/TR/2009/WD-xml-entity-names-20091117/

Comments are welcome on www-math@w3.org, please put the text
[last-call...
in the subject line, preferably like this:
[Entities-last-call] - summary of comment