Moved the highlighting pre code to its own function. Fixed some bugs.

A separator is no required before any flags. This fixes the Gemara and Mishna Torah problems mentioned in chat. 
Tooltips no longer flicker in chat.