Kotlin / kotlinx.html

Kotlin DSL for HTML
Apache License 2.0
1.63k stars 133 forks source link

Documents are written with mixed line endings on Windows #104

Open sschuberth opened 5 years ago

sschuberth commented 5 years ago

At least on Windows, Document.serialize() writes out documents with mixed line endings: The first line containing <!DOCTYPE html> always has Unix line endings, but lines written by Java's XML transformer have platform-specific line endings (i.e. all following lines in the document). According to this answer a possible solution is to use LSSerializer instead.

As several tests use multi-line strings for expected results and Kotlin always uses Unix line endings in multi-line strings, it would probably most convenient to always use Unix line endings on any platform. This would also allow to get rid of several .replace("\r\n", "\n") calls in the tests.

cy6erGn0m commented 5 years ago

It's quite funny that the default LSSerializer implementation does handle configured line ending only if pretty print is enabled otherwise it is always ignored

cy6erGn0m commented 5 years ago

Since the first DOCTYPE line is written in our codebase, the easiest solution is to fix \n right there.

sschuberth commented 5 years ago

@cy6erGn0m, please see PR #106.

sigmanil commented 2 years ago

We've run into this bug now, was there a reason the PR was never accepted?