[TW5] TW5-TeXZilla plugin: latex to mathml via TeXZilla

226 views
Skip to first unread message

Joe Renes

unread,
Feb 4, 2015, 5:41:47 AM2/4/15
to tiddl...@googlegroups.com
Hi all,

I've made a plugin for using LaTeX in TW5 based on the TeXZilla latex parser (https://github.com/fred-wang/TeXZilla). It's available here (https://github.com/joerenes/TW5-TeXZilla). 

TeXZilla is fast, more like KaTeX than MathJax, but supports a wider set of LaTeX commands than KaTeX, though not as extensive as MathJax. (Having aligned equations with \begin{aligned} ... \end{aligned} was the ultimate reason for writing the plugin.) I also included the ability to define LaTeX macros and incorporated a block environment delimited by \[ ... \]. The plugin is based entirely on the existing KaTeX plugin, so I believe it integrates into TiddlyWiki better than just running MathJax on top. 

However, latex input is converted to mathml, so the plugin is only immediately useful in firefox and safari (and I'm not really sure about the latter). I believe one could run mathjax on top again, converting mathml into html+css, but I haven't tried it. 

Perhaps someone else will find it useful! I also ported the macro support back to the KaTeX plugin in my fork of TW5 on github in case anyone is interested. 

Best,

-joe


Tobias Beer

unread,
Feb 4, 2015, 5:58:31 AM2/4/15
to tiddl...@googlegroups.com
Hi Joe,

Nice stuff. If it's not too much trouble it would be great to see some demo / example wiki.
Some say one can even use GitHub pages for that... although I haven't tried yet myself.

Best wishes, Tobias.

Joe Renes

unread,
Feb 4, 2015, 3:40:58 PM2/4/15
to tiddl...@googlegroups.com
Hi Tobias,

thanks for your interest. I attempted to make a demo site at tiddlyspot: tw5-texzilla.tiddlyspot.com

But I haven't done it quite right, since my attempts to import the plugin to an empty tiddlywiki have been less than successful...
I'm running TW5 via node, so my experience with importing plugins is mainly copying files and updating tiddlywiki.info.

Best,

-joe

Joe Renes

unread,
Feb 4, 2015, 5:23:45 PM2/4/15
to tiddl...@googlegroups.com
hmm, now the importing works. I think I didn't save/refresh when I tried it before...

-joe

Jed Carty

unread,
Feb 4, 2015, 5:25:01 PM2/4/15
to tiddl...@googlegroups.com
This looks awesome!

I will certainly find it useful, both for my own notes and for helping to make math textbooks.

One of the most annoying parts of using TiddlyWiki for my thesis reference is that I had to use SVG images for multi-line equations.

Does it require an internet connection? I am hoping that since it is based on KaTeX it doesn't, but I am not in a position to test that at the moment.

Tobias Beer

unread,
Feb 4, 2015, 6:20:01 PM2/4/15
to tiddl...@googlegroups.com
Hi Joe,

Thanks for taking the time...
 
But I haven't done it quite right, since my attempts to import the plugin to an empty tiddlywiki have been less than successful...
I'm running TW5 via node, so my experience with importing plugins is mainly copying files and updating tiddlywiki.info.

I can see it working in Firefox but in Chrome it looks like this...

Best wishes, Tobias.

 

Joe Renes

unread,
Feb 5, 2015, 4:12:23 AM2/5/15
to tiddl...@googlegroups.com
right, I get the same thing --- chrome doesn't support much of mathml at the moment.  According to the their development team, support won't be happening anytime soon... (see https://code.google.com/p/chromium/issues/detail?id=152430#c43)

-joe

Jeremy Ruston

unread,
Feb 5, 2015, 4:22:35 AM2/5/15
to TiddlyWiki, Joe Renes
Hi Joe

Great stuff, it looks like a solid piece of work. I hadn't come across TeXZilla but it looks a good choice for TW5. In terms of the poor browser support for MathML, I wonder if it could somehow include a warning for browsers that can't display MathML? I guess better yet is to include a smaller polyfill than MathJax?

Can you put up a demo wiki that I can link to from tiddlywiki.com?

Looking at the contribution of KaTeX, it looks like the initial enthusiasm has worn off a little


If KaTeX's limitations are not going to be addressed soon I'd very much like to find a more comprehensive maths renderer.

Best wishes

Jeremy.


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Joe Renes

unread,
Feb 5, 2015, 4:25:42 AM2/5/15
to tiddl...@googlegroups.com
Thanks! 

The plugin shouldn't require an internet connection. The TeXZilla code is in the file TeXZilla-min.js, which is part of the plugin itself. (This file could probably be made smaller if that matters, since the TeXZilla code includes all sorts of stream processing functions that the plugin doesn't use.) Another goal in writing the plugin was to be able to ditch my local copy of mathjax, which is gigantic collection of font files that are not fun to backup. 

Regarding multi-line equations, note that instiki has support for numbering and referencing equations. I haven't had a big need for this yet, but I'd imagine their methods can be implemented in tiddlywiki. 

Best,

-joe

Joe Renes

unread,
Feb 5, 2015, 11:54:30 AM2/5/15
to tiddl...@googlegroups.com, jeremy...@gmail.com
Hi Jeremy,

thanks for your interest! 

A warning for no mathml support sounds like a good idea. Perhaps something like the message that shows up when saving the wiki? I'll have to look at how that works.

I'm not sure there is a smaller (good) polyfill than MathJax. I looked around a bit, but didn't find much. A good source of info on this stuff seems to be the author of TeXZilla, Frederic Wang. His blog is http://www.maths-informatique-jeux.com/blog/frederic/? The following post is a bit dated, but discusses the roadmap for efforts in webkit: http://www.maths-informatique-jeux.com/blog/frederic/?post/2013/10/12/Funding-MathML-Developments-in-Gecko-and-WebKit

I should also add that I came across TeXZilla from padawanphysicist's github page, https://github.com/padawanphysicist. He had a plugin for markdown + latex in TW5, but now I don't see it anymore. Parts of the macro parsing came from there. 

I created a demo at http://tw5-texzilla.tiddlyspot.com, and also linked this from the plugin's github readme. 

Finally, I was always impressed with the latex support in instiki, which is used for serious math(s). See,  for instance,  http://ncatlab.org/johnbaez/show/Circuit+theory+I . So the fact that TeXZilla closely follows itex2mml (the parser for instiki) seemed like a good sign to me. As I mentioned in my message to Jed Carty, it would be interesting to look at implementing numbered equations with referencing. Another nice feature of instiki is latex export, which takes the page and outputs a tex file that one can use to generate pdfs in the usual manner. I'm looking forward to learning more about how TW5 works by trying to implement some of these features!

Best,

-joe

Jeremy Ruston

unread,
Feb 6, 2015, 12:05:57 PM2/6/15
to Joe Renes, TiddlyWiki
Hi Joe

That's great, thanks. I've added a tiddler here:


Feel free to send pull requests with any subsequent updates.

Best wishes

Jeremy.

Reply all
Reply to author
Forward
0 new messages