Dear Graham,
it seems that the process of "formatting the document" is getting into your way. As you may have read, Notebooks currently uses Markdown, a few simple rules for plain text that describe how a document should be converted to HTML. When you use any of the formatting buttons that insert **bold** or *italic* styles, NB will automatically convert your document as soon as you hide the keyboard. - A side effect of this is that newlines or tabs may get lost (you need to add two spaces at the end of a line to enforce a newline).
If your document was converted accidentally, you can select "Copy as Plain Text" to revert back to your original version, which will correctly display the tabs and spaces at the beginning of a line.
I hope that helps.
Alfons