Closed
Description
This issue migrated from https://issues.scala-lang.org/browse/SI-3062.
Please note: There is discussion there which is not reproduced here clarifying the needed algorithmic change.
Reproduced here is just the original description of the issue.
if Text("My name is ")
followed by Text("Harry")
the space following the word "is" will be incorrectly trimmed. Adjacent Text nodes need to be combined before whitespace is removed.
scala> import scala.xml._
import scala.xml._
scala> <div>{Text("My name is ")}{Text("Harry")}</div>
res0: scala.xml.Elem = <div>My name is Harry</div>
scala> Utility.trim(res0)
res1: scala.xml.Node = <div>My name isHarry</div>
This is important when modifying XML and then trimming it. For example we might start with <div>My name is <user:name/></div>
and then replace the <user:name/>
Elem with "Harry"
thus leading to the adjacent Text nodes.
Metadata
Metadata
Assignees
Labels
No labels