Welcome! » Log In » Create A New Profile

Implementation of MathML DTD3

Posted by Abdul Ahmady 
Abdul Ahmady
Implementation of MathML DTD3
October 19, 2016 06:21PM

Hello everyone, first of all let me say that im impressed with how beautifully HTMLPurifier is written. Now back to the important stuff. I am in need to implement MathML definitions to be able to verify the supplied code on the server-side. I started imagining that it wouldn't be more than a day job, but soon it blew my mind, looking at the https://www.w3.org/Math/DTD/mathml3/mathml3.dtd it looks like i need some help here. I don't wanna start working on it just to find myself doing it all wrong. So here are my questions/needed assistance:

1. Is there anyone already working on this? (if so i would love to help out to get this out faster)

2. Is there an easy way (step by step guide of some sort) that can help me convert this DTD file to a Plugin, Function, or Class that could extend HTMLPurifier?

Any help would be very appreciated in advance Cheers!

Re: Implementation of MathML DTD3
October 20, 2016 03:35AM

Hello Abdul,

As far as I know, no one is working on this.

MathML is indeed going to be quite a trial. There may also be cases where HTML Purifier may not have enough knobs for you, and you are going to have to go in and make changes.

It probably makes the most sense to do this as a patchset on top of HTML Purifier. To add a new "module", look at the existing HTMLModules (e.g., HTMLPurifier_HTMLModule_Tables), also referencing http://htmlpurifier.org/docs/enduser-customize.html which gives a high level overview of the APIs in question.

But otherwise, yes, you're going to have to write some code for every definition. This is by design; an automated process might end up accidentally allowing an element that shouldn't be allowed. Everything should be looked at before being put on the whitelist.

This being said, the DTD isn't terribly user friendly. Perhaps consider working off the human readable spec instead.

A Touzel
Re: Implementation of MathML DTD3
January 26, 2018 05:00PM

Hi Abdul,

More than a year later, I am facing the same need. I was wondering if you had worked out something for Math ML to work with HTMLPurifier?


A Touzel

Re: Implementation of MathML DTD3
January 26, 2018 05:14PM

No, not to my knowledge.

Sorry, you do not have permission to post/reply in this forum.