After having set `comment-style` to 'multi-line in nxml-mode, I found out it tries to pad comments with `!--`. The details why that happens are described in the first patch. The two hyphens are invalid both in XML¹ and HTML², so the patch makes it stop produce such padding. The second patch is just a simple refactoring to reduce the amount of code, but feel free to ignore it if you don't like it. ----------------- 1: https://softwareengineering.stackexchange.com/questions/198481/why-cant-an-xml-comment-contain-two-hyphens#:~:text=Double%20dash%20indicates%20a%20change,does%20not%20end%20the%20comment . 2: https://stackoverflow.com/questions/26600092/why-are-double-hyphens-invalid-in-html-comments