I'm at work on a MW extension that, among other things, uses LaTeXML [1] to make XHTML from full LaTeX documents. One feature is the option to render the equations in MathML, which requires the skins to be patched so that they output the page as Content-type: application/xhtml+xml instead of text/html.
Attached is a patch for the skins directory that allows changing the Content-type dynamically. After applying this patch, if any code sets the global $wgServeAsXHTML to true, the page will be output with the xhtml+xml content type. This seems to work fine with the existing MW XHTML pages.
This has been done before, for instance in the ASCIIMath4Wiki extension [2]. I don't want to change the Content-type unconditionally, though, only some of the time, so that we can serve texvc-style images to browsers or users that don't like the modified content type.
It should be possible to use this patch without breaking any existing systems (unless someone else's extension happens to use the same global variable name, I guess).
The patch is made on the 1:1.13.3-1ubuntu1 mediawiki package (from Ubuntu 9.04), and only modifies Monobook.php and Modern.php. There are other skins in my installation here, but they don't seem to work very well and I didn't see where to make the change.
Is there a better way to make MathML work in MW? Might this option be included in a future MW release? Any feedback or alternative suggestions is welcome.
Lee Worden McMaster University Dept of Biology
[1] http://dlmf.nist.gov/LaTeXML/ [2] http://www.mediawiki.org/wiki/Extension:ASCIIMath4Wiki
ps. I'm not sure if this list accepts attachments - if not I'll be happy to send it to people on request.
2009/3/19 lee worden wonder@riseup.net:
I'm at work on a MW extension that, among other things, uses LaTeXML [1] to make XHTML from full LaTeX documents. One feature is the option to render the equations in MathML, which requires the skins to be patched so that they output the page as Content-type: application/xhtml+xml instead of text/html.
Attached is a patch for the skins directory that allows changing the Content-type dynamically. After applying this patch, if any code sets the global $wgServeAsXHTML to true, the page will be output with the xhtml+xml content type. This seems to work fine with the existing MW XHTML pages.
It should be done with the Parser Output instead.
This mailing list does not accept attachments
What's to patch? This is already a configuration variable, just set it...
-- brion vibber (brion @ wikimedia.org)
On Mar 18, 2009, at 21:24, Andrew Garrett agarrett@wikimedia.org wrote:
2009/3/19 lee worden wonder@riseup.net:
I'm at work on a MW extension that, among other things, uses LaTeXML [1] to make XHTML from full LaTeX documents. One feature is the option to render the equations in MathML, which requires the skins to be patched so that they output the page as Content-type: application/xhtml+xml instead of text/html.
Attached is a patch for the skins directory that allows changing the Content-type dynamically. After applying this patch, if any code sets the global $wgServeAsXHTML to true, the page will be output with the xhtml+xml content type. This seems to work fine with the existing MW XHTML pages.
It should be done with the Parser Output instead.
This mailing list does not accept attachments
-- Andrew Garrett
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Le 19.3.2009 4:46, « lee worden » wonder@riseup.net a écrit :
Attached is a patch for the skins directory that allows changing the Content-type dynamically. After applying this patch, if any code sets the global $wgServeAsXHTML to true, the page will be output with the xhtml+xml content type. This seems to work fine with the existing MW XHTML pages.
Can't you set $wgMimeType = 'application/xhtml+xml'; in LocalSettings.php to serve pages with application/xhtml+xml content type?
Alexandre Emsenhuber (ialex)
2009/3/18 lee worden wonder@riseup.net:
Attached is a patch for the skins directory that allows changing the Content-type dynamically. After applying this patch, if any code sets the global $wgServeAsXHTML to true, the page will be output with the xhtml+xml content type. This seems to work fine with the existing MW XHTML pages.
This mailing list doesn't accept attachments. Patches should be submitted at bugzilla.wikimedia.org.
This has been done before, for instance in the ASCIIMath4Wiki extension [2]. I don't want to change the Content-type unconditionally, though, only some of the time, so that we can serve texvc-style images to browsers or users that don't like the modified content type.
Note that this will interfere with any kind of HTML caching, such as Squid or file cache, and with the parser cache as well. It won't work correctly in most well-configured MediaWiki installs unless you make sure to fragment the parser cache appropriately, at a minimum.
The patch is made on the 1:1.13.3-1ubuntu1 mediawiki package (from Ubuntu 9.04), and only modifies Monobook.php and Modern.php. There are other skins in my installation here, but they don't seem to work very well and I didn't see where to make the change.
Well, that's okay for a first stab at the implementation, if we want to include this at all (hard to say without seeing the patch). Not your fault our skin system is a complete mess. There are likely to be some merge conflicts, though -- 1.13 is very old. It's best to submit patches based on trunk.
Is there a better way to make MathML work in MW? Might this option be included in a future MW release? Any feedback or alternative suggestions is welcome.
Under "Math" in preferences on Wikipedia, there's already a "MathML if possible (experimental)" option. I'm not sure if it actually does anything, though . . . if not, I guess it should be removed.
This has been done before, for instance in the ASCIIMath4Wiki extension [2]. I don't want to change the Content-type unconditionally, though, only some of the time, so that we can serve texvc-style images to browsers or users that don't like the modified content type.
Note that this will interfere with any kind of HTML caching, such as Squid or file cache, and with the parser cache as well. It won't work correctly in most well-configured MediaWiki installs unless you make sure to fragment the parser cache appropriately, at a minimum.
The patch seems to work with the simple caching on the system I'm using to test. It changes more than just the content-type - the DOCTYPE is different and there's a <?xml string before the document, and a 'Vary: Accept' header.
I got all that from another author. I'll look further into how to do it without patches. It's true I can change the Content-type by setting $wgMimeTypes dynamically, but it only works on the first hit, and cached pages arrive as text/html.
wikitech-l@lists.wikimedia.org