Is there a MediaWiki/WikiText live previewer available?


#1

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?


#2

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.


#3

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?


#4

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 renderer.coffee 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.


#5

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.


#6

Errors are to be expected. Good luck.


#7

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?


#8

Theoretically, yes.