summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-06-07 13:55:47 +0000
committerPaul Phillips <paulp@improving.org>2009-06-07 13:55:47 +0000
commitbd7bd8fb2719fd00401d8abaf07afa8f002c90a2 (patch)
tree8d0ac0cf8a693e29f7dbeff9c43e94a8a6224466
parent9bfc974222ffd380d530919c44956a981bc080e5 (diff)
downloadscala-bd7bd8fb2719fd00401d8abaf07afa8f002c90a2.tar.gz
scala-bd7bd8fb2719fd00401d8abaf07afa8f002c90a2.tar.bz2
scala-bd7bd8fb2719fd00401d8abaf07afa8f002c90a2.zip
Tightened up XHTML minimization logic - closes ...
Tightened up XHTML minimization logic - closes #2043.
-rw-r--r--src/library/scala/xml/Xhtml.scala12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/library/scala/xml/Xhtml.scala b/src/library/scala/xml/Xhtml.scala
index 70b9be93ed..744fe260c2 100644
--- a/src/library/scala/xml/Xhtml.scala
+++ b/src/library/scala/xml/Xhtml.scala
@@ -24,6 +24,12 @@ object Xhtml
*/
def toXhtml(nodeSeq: NodeSeq): String = sbToString(sequenceToXML(nodeSeq: Seq[Node], sb = _))
+ /** Elements which we believe are safe to minimize if minimizeTags is true.
+ * See http://www.w3.org/TR/xhtml1/guidelines.html#C_3
+ */
+ private val minimizableElements =
+ List("base", "meta", "link", "hr", "br", "param", "img", "area", "input", "col")
+
def toXhtml(
x: Node,
pscope: NamespaceBinding = TopScope,
@@ -31,7 +37,7 @@ object Xhtml
stripComments: Boolean = false,
decodeEntities: Boolean = false,
preserveWhitespace: Boolean = false,
- minimizeTags: Boolean = false): Unit =
+ minimizeTags: Boolean = true): Unit =
{
def decode(er: EntityRef) = XhtmlEntities.entMap.get(er.entityName) match {
case Some(chr) if chr.toInt >= 128 => sb.append(chr)
@@ -40,7 +46,7 @@ object Xhtml
def shortForm =
minimizeTags &&
(x.child == null || x.child.length == 0) &&
- !(List("div", "script", "textarea") contains x.label)
+ (minimizableElements contains x.label)
x match {
case c: Comment if !stripComments => c buildString sb
@@ -76,7 +82,7 @@ object Xhtml
stripComments: Boolean = false,
decodeEntities: Boolean = false,
preserveWhitespace: Boolean = false,
- minimizeTags: Boolean = false): Unit =
+ minimizeTags: Boolean = true): Unit =
{
if (children.isEmpty)
return