I had assumed that having managed to make the code in this chunk display sensibly the task would be over. Attempts to run code in other chunks made me revisit it though and the realisation that all the line feeds, including those in the code, were being converted to breaks dawned. It's a shame there's no facility to suspend that just for blocks marked with <pre> and <code>. However, hopefully it should now be possible to copy and paste the code included here with its intended formatting. The changes are made in Settings | Formatting if anyone hasn't yet discovered that.