Fix #1146 -- add dir=rtl to <html> tag where necessary

This is #1146.

cc @Aeyoun