diff --git a/src/main/scala/com/phasmidsoftware/core/SmartBuffer.scala b/src/main/scala/com/phasmidsoftware/core/SmartBuffer.scala
index 0a9f1c0..5a9694d 100644
--- a/src/main/scala/com/phasmidsoftware/core/SmartBuffer.scala
+++ b/src/main/scala/com/phasmidsoftware/core/SmartBuffer.scala
@@ -38,7 +38,27 @@ case class SmartBuffer(sb: StringBuilder) {
s
}
- def result: String = sb.result()
+ /**
+ * Get the resulting String.
+ *
+ * NOTE: this method contains a hack which collapses output of the form <tag ...></tag> into <tag .../>
+ * As such, it is useful for e.g. hotSpot which has no children.
+ *
+ * NOTE: the method assumes there is at most one newline character at the beginning of the string.
+ *
+ * @return
+ */
+ def result: String = {
+ val str = sb.result()
+ if (str.isEmpty) str
+ else {
+ val regex = """(\s*)<([a-zA-Z0-9 ="]+)>(\w+)>""".r
+ str.substring(1) match {
+ case regex(p, q, _) => str.substring(0, 1) + p + "<" + q + "/>"
+ case _ => str
+ }
+ }
+ }
override def toString: String = sb.toString
diff --git a/src/main/scala/com/phasmidsoftware/render/Renderer.scala b/src/main/scala/com/phasmidsoftware/render/Renderer.scala
index 2d2f45d..6a7b0c7 100644
--- a/src/main/scala/com/phasmidsoftware/render/Renderer.scala
+++ b/src/main/scala/com/phasmidsoftware/render/Renderer.scala
@@ -163,7 +163,7 @@ object Renderer {
*
* @param maybeName an optional String.
* @param attributes a (private) SmartBuffer: accessible via addAttribute or getAttributes.
- * @param interior false if we are at the top level of an element; false if we have been invoked from above.
+ * @param interior false if we are at the top level of an element; true if we have been invoked from above.
*/
case class StateR(maybeName: Option[String], private val attributes: SmartBuffer, interior: Boolean) extends AutoCloseable {
diff --git a/src/test/scala/com/phasmidsoftware/kmldoc/KmlSpec.scala b/src/test/scala/com/phasmidsoftware/kmldoc/KmlSpec.scala
index 6e55472..6efd612 100644
--- a/src/test/scala/com/phasmidsoftware/kmldoc/KmlSpec.scala
+++ b/src/test/scala/com/phasmidsoftware/kmldoc/KmlSpec.scala
@@ -702,9 +702,9 @@ class KmlSpec extends AnyFlatSpec with should.Matchers {
|
| https://www.gstatic.com/mapspro/images/stock/22-blue-dot.png
|
- |
+ |
|""".stripMargin
- private val iconStyleText = "\n 1.1\n \n https://www.gstatic.com/mapspro/images/stock/22-blue-dot.png\n \n \n "
+ private val iconStyleText = "\n 1.1\n \n https://www.gstatic.com/mapspro/images/stock/22-blue-dot.png\n \n \n "
private val balloonStyleText = "\n \n$[name]]]>\n\n "
private val labelStyleText = "\n 0\n "
private val stylesText = s"\n $labelStyleText\n $iconStyleText\n $balloonStyleText\n"
@@ -744,7 +744,7 @@ class KmlSpec extends AnyFlatSpec with should.Matchers {
|
| https://www.gstatic.com/mapspro/images/stock/22-blue-dot.png
|
- |
+ |
|""".stripMargin)
case Failure(x) => fail(x)
}
@@ -850,7 +850,7 @@ class KmlSpec extends AnyFlatSpec with should.Matchers {
|
| https://www.gstatic.com/mapspro/images/stock/22-blue-dot.png
|
- |
+ |
|
|
| $cdata