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. staff). It was treating them as p 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 p tags that have had their text output reverse-parsed to the appropriate child tag as its text, since we remove p tags and treat the contents like raw wikitext. The the parser takes advantage of that fact, and eventually dumps the text value of the p tag out without the wrapping tags, which is how we get the value for the staff tag in the first place.

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.