Thanks for your help. I had a slightly older version of Calibre (0.7.34) which did not have the Heuristics option. If you deselect everything but the "replace entity indents with CSS indents" it doesn't solve the indentation problem. But if you keep all the options selected, it does.
Also thanks to Idolse for the information.