GNOME Bugzilla – Bug 685998
Add MathJax to Adium Themes
Last modified: 2018-05-22 15:49:06 UTC
Created attachment 226293 [details] Modified Template.html that loads mathjax I was thinking that it would be nice to have formulas. When adium themes are used, this can be easily achived by using mathjax. I am attaching my modified Template.html file which makes this work. Note that I had to load mathjax dynamically as it would interfere with the rest of the javascript code otherwise. Works great in my initial tests.
MathJax looks pretty cool, integrating in Empathy's chat would be awesome. Any chance you could provide a proper set of patches? We'd be happy to review and merge them. :)
One thing to keep in mind is that some adium themes provide their own Template.html. I don't know if that's possible, but it would be nice to "inject" the mathjax support into the chat page without having to touch the template html. Also that would make easier to make it optional, since it could have performance impact probably. What's the syntax of the message to trigger a math equation replacement? TeX?
Hm, it should be possible to inject MathJax directly from C, instead of patching the template. However, that makes it much harder to only reevaluate newly send messages instead of the whole history in the window. MathJax works by searching for certain strings. formulas will usually be entered using tex and inside $$ $$ or \[ \]. MathJax provides multiple ways, but AFAIK the pidgin math infrastructure only supports $$ formula $$. It would make sense to make the MathJax URL configurable by the distribution (and maybe the user). Distributions may install a local version of it, that way one can save some bandwidth and offline viewing works too.
A few points: 1) What happens if you're offline? That template is used for showing chat history as well, so it should still work offline. I'm fine if formulas are just not replaced in that case, but it should still work. 2) The message passed to the template is escaped using g_markup_escape_text(). Won't that break most of Tex formulas? 3) The template you attached uses MathJax.Hub.Typeset(); which will reparse the whole document as I understand. You should pass the added element to that function, I think.
1. Not sure about the attached version; I guess it will fail because of javascript errors; the attached version will probably not scroll correctly. 2. I don't see why escaping would be a problem. The LaTeX code should be normal text, and that is enforced by the escape_text (ie. there are no XML tags). MathML would obviously not work. 3. I don't remember the details. I probably didn't manage to hook things up properly for the partial reparse, and then settled for that.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/empathy/issues/601.