peoppenheimer () wrote in 2012-12-09 09:43 am

### Support MathJax in Entries

Title:
Support MathJax in Entries

Area:
MathJax JavaScript support at site level

Summary:
I suggest that (in due time!) dw support MathJax <a href="http://www.mathjax.org/">MathJax</a> for mathematical/technical formatting in dw entries.

Description:
This suggestion is intended to make it easy for dw people to write beautiful and useful mathematical/technical content in our entries. MathJax is now a mature and well-supported FOSS extension of html via javascript, with healthy user and developer communities. We've been experimenting with MathJax for the Stanford Encyclopedia of Philosophy, and we've been very pleased with it so far. (This is not an official SEP endorsement.) Code can be written or displayed rendered or in TeX or MathML. This makes it useful also for gacking and modifying, and even for learning more about those markup languages. Anyone who has tried to do serious mathematical or technical typesetting in html will agree, I think, that html is *not* a typesetting language. MathJax goes a long way toward allowing decent technical typesetting in an html context.

If MathJax can be permitted as a tightly controlled JavaScript layer at the dw site level, which I think it can, then users will be able to write mathematical and technical fragments into their journal entries as easily as any other html. I don't envision putting MathJax support into the rich text editor -- I anticipate that anyone who wants to use MathJax will be comfortable editing their own markup. This is rather an extension of html markup into a wider domain.

It is possible that I'm overestimating the ease of implementing this suggestion, but I've experimented with MathJax support in my personal webpages and at the SEP site, and it looks as though MathJax makes this as easy as possible. Furthermore, the social/political aspects look promising, insofar as the MathJax user and developer communities look like just the sorts of folks dw wants to make alliance with, as far as I can tell.

Poll #12341 Support MathJax in Entries
Open to: Registered Users, detailed results viewable to: All, participants: 46

This suggestion:

Should be implemented as-is.
14 (30.4%)

Should be implemented with changes. (please comment)
1 (2.2%)

Shouldn't be implemented.
3 (6.5%)

(I have no opinion)
26 (56.5%)

2 (4.3%)

#### no subject

I've voted for, but my only reservation:

AIUI this would mean that some journals (those with MathJax markup) would require Javascript in order to display correctly. I don't think there's a way around this if we want to be able to display maths. And I think that being able to display maths is an excellent idea. Maybe we need to make sure that it fails to a polite message about how we can't display the maths without JS?

(I don't know how MathML is used, and whether that requires JS, and so whether direct MathML support would be an alternative, but AIUI browsers that support MathML are rather rare at the moment)

Re the "not in the RTE" part of the suggestion: Ideally I would like to see a way to put maths markup in the RTE. I wouldn't expect it to display as WYSIWYG, but it would be nice to be able to use maths without having to type raw HTML for everything else.
Edited (tyop.) 2012-12-16 09:07 (UTC)

#### no subject

I'm pretty sure I don't like the idea of any journal entries that need JS to display correctly.

#### no subject

Well, a Youtube embed needs JS (and/or Flash) to display correctly... is this substantially different?

#### no subject

I think it is. a video embed is a single piece of code. It's always the same (except for the target video file, which is in turn also a well-defined and well-understood format) and can be carefully vetted by the DW team to make sure it can't be misused.

Displaying math markup is a lot messier than that. I don't know anything about the particular app/library we're talking about here. But I assume it would have to be allowed to display arbitrary things all through the post in order to be useful. And that potentially leaves my reading page vulnerable to bad actors (maliciously or incompetently) displaying their garbage over my entire reading page. Does anyone but me remember the "feature" that let people display full-page ads over someone's MySpace page through a comment?

I really like the very very conservative nature of DW's approach to outside scripting. I think a richer math markup environment would be cool, but not at the expense of security from harmful or just plain annoying scripts.

#### no subject

From the MathJax documentation:

If you are using MathJax in a community setting, however, like a question-and-answer forum, a wiki, a blog with user comments, or other situations where your readers can enter mathematics, then your readers would be able to use such powerful tools to corrupt the page, or fool other readers into giving away sensitive information, or interrupt their reading experience in other ways. In such environments, you may want to limit these abilities so that your readers are protected form these kinds of malicious actions.

http://docs.mathjax.org/en/latest/safe-mode.html
http://docs.mathjax.org/en/latest/options/Safe.html

So, it does appear that it can be locked down so it can only be used as a rendering engine and not a tool to "corrupt" the experience of people reading the page.

#### no subject

I really like the idea of leveraging Dreamwidth's responsive development style to make it an especially good journaling system for smaller groups of people like this. It's something that Facebook can't do, as they have to cater to the mass market. LiveJournal clearly has no intention or ability to do anything like this. But because Dreamwidth is smaller and more flexible, this could be really good.

That said, is there any way for MathJax to generate readable HTML (even if ugly) as an alternate view for those without JavaScript? It seems like Stanford and all institutions would need that kind of accessibility.

#### no subject

don't feel like you have to do it! that's part of what we do when we decide whether to put the suggestion into bugzilla or not :)

#### no subject

MathJax "was design[ed] with accessibility in mind and has several powerful features to make math easier to see and read, both for ordinary users as well as those with print and learning disabilities. Two accessibility features, the ability to scale all math in a page or zoom in on a particular equation, are built in to MathJax. In addition, MathJax works with MathPlayer (http://www.dessci.com/en/products/mathplayer/) to make math accessible to screen readers, to screen magnifiers, and to learning disability software."

So, it actually seems like it (deliberately) has excellent accessibility support. I can't vouch for it though as I do not currently use those sorts of software features.

http://www.mathjax.org/resources/articles-and-presentations/accessible-pages-with-mathjax/
Edited 2013-09-26 03:44 (UTC)

#### no subject

In with the crowd who wants to know if it can be done without JS.

#### no subject

MathJax requires Javascript. It can work around browsers that don't support (or users that have not enabled) Web Fonts, but Javascript is an absolute requirement for this package.

#### no subject

I've been doing some quick skim-reading, and thought I'd relay some data-points:

1. Will MathJax work without JS? I can't answer authoratatively, but it seems unlikely given that the big headline text on www.mathjax.org is "MathJax is an open source JavaScript display engine for mathematics that works in all modern browsers".

3. As is this one on browser compatibility: http://www.mathjax.org/resources/browser-compatibility/

Wondering about other ways to implement maths support, some other means of editing MathML might be useful in the future, but it appears that browser support for MathML is not sufficiently widespread yet. See https://en.wikipedia.org/wiki/MathML#Web_browsers.
So it looks as though MathJax is still about the only widely-accessible cross-browser way of doing this, but it probably requires JS.

#### no subject

MathJax does require that Javascript be enabled on the browser of someone reading the page to see the content. One thought I had is for those who do not wish to enable Javascript, and who also do not want to be frustrated by MathJax content not displaying, that an option could be added to the user configuration that would allow someone to tell Dreamwidth not to show them any page containing MathJax code. This could be made a generic flag to exclude any page that requires Javascript to display properly, and that would allow future enhancements that require Javascript to be automatically included (by the developers) in the show/no-show setting for those users that do not want Javacript generated content (or content that requires Javacript enabled to work properly).

#### no subject

I have been posting my work in the social sciences on my Dreamwidth blog, but I desperately want to be able to post mathematical solutions I have developed in physics to the same blog. Without something like MathJax (from what I can see, the preferred solution these days as it is supported by organizations like the American Mathematical Society and the American Institute of Physics... and even a few international groups), it is an onerous and ultimately futile effort that requires the conversion of documents into HTML and a collection of unintegrated images of equations and such. It's not really blogging at that point (not quite sure exactly what, but it feels different from blogging). I am perfectly fine with the notion that Javascript be required to read such pages provided the platform is controlled directly by the Dreamwidth team. Given the fact that it's basically a rendering engine and not a generic content generation/management framework, it meshes well, imho, with the blogging paradigm. By using the "Safe Mode" configuration, malicious behaviour (such as linking to uncontrolled Javascript) can be prevented:

If you are using MathJax in a community setting, however, like a question-and-answer forum, a wiki, a blog with user comments, or other situations where your readers can enter mathematics, then your readers would be able to use such powerful tools to corrupt the page, or fool other readers into giving away sensitive information, or interrupt their reading experience in other ways. In such environments, you may want to limit these abilities so that your readers are protected form these kinds of malicious actions.

http://docs.mathjax.org/en/latest/safe-mode.html
http://docs.mathjax.org/en/latest/options/Safe.html

I personally would not need any support in the editor (I use HTML anyway), but it would probably be nice for some if there was a button that allowed the insertion of the raw LaTeX or MathML code into an entry without having to switch back and forth between rich and HTML modes (it could display in the rich editor as the raw text of the math code in a fixed-width font or something... again, just having the support in general would be wonderful even without any sort of editor support).

Keep up the great work!
Edited 2013-09-26 03:37 (UTC)

#### no subject

Actually, how about using forkosh.com's implementation (<- see link)? It doesn't require any JavaScript, and works well, for example:

$x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$

In fact, what we might desire, is just the installation of cgi-bin script on DW, so people can simply include LaTeX like this:

<img src="/cgi-bin/mimetex.cgi?
x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}">


Then, it just suffices to define a new tag, something like  that passes the expression into the CGI script, and you get math formulae as nice images...

Installation instructions are here.
Edited 2015-04-26 08:16 (UTC)