clarified treatment of empty markup;
authorwenzelm
Thu, 27 Jun 2024 23:18:28 +0200
changeset 80431 c748adebc67f
parent 80430 89cd8fedefa7
child 80432 b42f95f18a71
clarified treatment of empty markup;
src/Pure/PIDE/xml.scala
--- a/src/Pure/PIDE/xml.scala	Thu Jun 27 22:39:20 2024 +0200
+++ b/src/Pure/PIDE/xml.scala	Thu Jun 27 23:18:28 2024 +0200
@@ -63,8 +63,10 @@
         list match {
           case Nil =>
           case Text(s) :: rest => text(s); trav(rest)
-          case Elem(markup, Nil) :: rest => elem(markup, end = true); trav(rest)
-          case Elem(markup, body) :: rest => elem(markup); trav(body ::: End(markup.name) :: rest)
+          case Elem(markup, body) :: rest =>
+            if (markup.is_empty) trav(body ::: rest)
+            else if (body.isEmpty) { elem(markup, end = true); trav(rest) }
+            else { elem(markup); trav(body ::: End(markup.name) :: rest) }
           case End(name) :: rest => end_elem(name); trav(rest)
           case _ :: _ => ???
         }