Wikia/app — pull request #298 by relwell (2013-01-05 00:48:09+00:00)
Title: bugid: 52072 -- insert a newline before an explicit HTML tag only if it ...

...does not follow an explicit HTML tag or parser hook tag

The reverse parser could not recognize parser hooks, which appear as their own externally defined HTML tags (e.g. ). It was treating them as

tags, and therefore inserting newlines in weird places -- namely, in cases where an explicit HTML tag followed it.

Here, we introduce flat array storage for DOM nodes iterated over and their individual outputs, so that we can match up a node with its output later on. In this way, we can extract

tags that have had their text output reverse-parsed to the appropriate child tag as its text, since we remove

tags and treat the contents like raw wikitext (e.g.

--> ).

So now, we only insert a newline before overt HTML in source if the previous sibling fails a match for the hooks that have been registered in the parser.