Parser 2011/Wikia Reverse Parser

Wikia Editor for developers (slides) - 128 kB

Parser & ReverseParser
Wikia Editor uses slightly modified MW parser to render HTML which can be edited in visual mode (we use CK editor as a core of visual mode).

class extends MW parser and adds attributes containing extra data used when processing HTML back wikitext. This process is handled by  - it goes recursively through HTML and returns wikitext which is then stored in database.

Custom HTML attributes
List of aforementioned custom attributes (with  prefix) can be found in README.txt file in Wikia code repository. Most of them are added by, few are added to the nodes created by CKeditor while modifying an article in visual mode.

Markers
In order to be able to parse template's HTML back to wikitext we add markers to the wikitext when its processed by the. When marker is added we store element's (e.g. template, image) wikitext in  stack. ID of added stack item is stored inside a marker. finds all markers, removes them and moves data stored on the stack to HTML attributes.