Fix #223: `demoteHeaders` should not modify anything in the document, apart from the headers

See #223