diff --git a/Laminarize.scala b/Laminarize.scala index 7cbb06a..6241845 100644 --- a/Laminarize.scala +++ b/Laminarize.scala @@ -23,7 +23,20 @@ private var written: Boolean = false private val code: java.lang.StringBuilder = new java.lang.StringBuilder private val attrMap: Map[String, String] = - Map("class" -> "cls", "type" -> "tpe").withDefault(identity) + Map("class" -> "cls", "type" -> "tpe", "viewbox" -> "viewBox", "stroke-linecap" -> "strokeLineCap", "stroke-linejoin" -> "strokeLineJoin").withDefault { cls => + def toCap(words: List[String]): String = words match { + case h :: t => (h :: t.map(_.capitalize)).mkString("") + case _ => "" + } + + def dashToCap(c: String): String = toCap(c.split("-").toList) + + if (cls.startsWith("aria")) { + s"aria.${toCap(cls.split("-").toList.tail)}" + } else { + dashToCap(cls) + } + } override def head(node: Node, depth: Int): Unit = node match { case el: Element => Some(() => writeElement(el, depth))