Is there a MediaWiki/WikiText live previewer available?


I’m looking for a way to create documents using the WikiText syntax used by MediaWiki. I found a MediaWiki language package, but no previewer. Does one exist, and if not, is there any comprehensive documentation on how to make a live previewer?


You need some JavaScript or CoffeeScript code that takes the syntax, processes it, and spits out HTML. Once you have that, it would be relatively easy to pull open an existing previewer and slot that script in.


I took a look at the source for some of the other previewers, but I’m new to CoffeeScript and couldn’t find where the actual syntax processing was happening. What files should I be looking at?


For a package like atom-preview, the trick is that the actual syntax processing doesn’t happen in the package itself. atom-preview has a list of grammars it supports, and each of those cases links to a Node package that parses the code. Let’s look at Pug, since it’s an abstraction for HTML (just like WikiText is). atom-preview calls it here and the information in that block informs what happens here.

The easy part of adding a new language to a package like atom-preview is just creating a new case in and testing to make sure it works. The hard part would be developing a package that actually processes the code into HTML output, if there isn’t one already.


Very interesting. It looks like there’s already a node package for WikiText that’s maintained by MediaWiki, called Parsoid. I’ll have to see what I can do with that…it’s at least recognizing the package and attempting to load the previewer, albeit with errors.


Errors are to be expected. Good luck.


I do have one other question - since atom-preview is so simplified and everything runs through node packages, theoretically if I can get Parsoid working independently of Atom, it SHOULD work with atom-preview, correct?


Theoretically, yes.