Problems with the use of GRAMMAR
As to the message preview, there is a special case of preview for specific *.js and *.css pages already. Did you check it for hints hat could be useful for us at twn?
The third point is indeed hard to tackle. I've been at closely related issues for various reasons once in a while, and I believe fixing them all together in one go is easier than trying to solve them individually. My current idea is to convert every rendered string to an ordered list of tupels for internal processing, with each tupel at least having a locale (i.e. language, variant(s), script), directionality, joining behavior, and content. That would also require attaching those properties to wiki pages proper, offering an opportunity to do away with "title/xzz" hacks if a wiki chooses to do so.