in reply to spaces wont be displayed

In your anonymous hashref's for the font attributes, add in -style=>'white-space: pre'. I have not tested this, but it should work.