Parser 2011/Wikia Reverse Parser
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).
RTEParser class extends MW parser and adds attributes containing extra data used when processing HTML back wikitext. This process is handled by
ReverseParser - it goes recursively through HTML and returns wikitext which is then stored in database.
Custom HTML attributes
List of aforementioned custom attributes (with
data-rte- prefix) can be found in README.txt file in Wikia code repository. Most of them are added by
RTEParser, few are added to the nodes created by CKeditor while modifying an article in visual mode.
In order to be able to parse template's HTML back to wikitext we add markers to the wikitext when its processed by the
Preprocessor. When marker is added we store element's (e.g. template, image) wikitext in
RTEData stack. ID of added stack item is stored inside a marker.
RTEParser finds all markers, removes them and moves data stored on the stack to HTML attributes.