scala / scala-xml

The standard Scala XML library
Apache License 2.0
297 stars 92 forks source link

PrettyPrinter removes newlines #75

Open mbeckerle opened 9 years ago

mbeckerle commented 9 years ago

Migrated from https://issues.scala-lang.org/browse/SI-4543.

There is discussion there that is not reproduced here.

Original description is:

What steps will reproduce the problem (please be specific and

scala> <foo>{PCData("hello\nworld")}</foo>
res51: scala.xml.Elem =
<foo><![CDATA[hello
world]]></foo>

scala> (new PrettyPrinter(Int.MaxValue, 2)).format(res51)
res52: String = <foo><![CDATA[hello world]]></foo>

What is the expected behavior?

Should print "hello\nworld"

scala> (new PrettyPrinter(Int.MaxValue, 2)).format(res51)
res52: String = <foo><![CDATA[hello\nworld]]></foo>

What do you see instead? prints "hello world"

What versions of the following are you using? Scala: 2.8.1

themerius commented 6 years ago

Any news on that issue?

ashawley commented 6 years ago

I've never looked in to the issue, myself. Did you run in to this problem or similar?

themerius commented 6 years ago

Yesterday I stumbled across this issue. Now I'm using .toString which produces now correct XML, but the XML is now quite ugly.

techncl commented 8 months ago

Any news on this issue? It's still happening in Scala 2.13.12 and it also converts multiple spaces into 1 space.