}
}
-fun processColor(param: String?): Map<String, String> = param?.removePrefix("#")?.let { colorRaw ->
- when (colorRaw.length) {
- 6 -> colorRaw
- 3 -> {
- val (r, g, b) = colorRaw.toCharArray()
- "$r$r$g$g$b$b"
- }
-
- else -> null
+fun repeatColorDigits(color: String) = when (color.length) {
+ 6 -> color
+ 3 -> {
+ val (r, g, b) = color.toCharArray()
+ "$r$r$g$g$b$b"
}
-}?.toIntOrNull(16)?.toString(16)?.padStart(6, '0')?.let {
- mapOf("style" to "color:#$it")
-}.orEmpty()
+
+ else -> null
+}
+
+fun processColor(param: String?): Map<String, String> = param
+ ?.removePrefix("#")
+ ?.let(::repeatColorDigits)
+ ?.toIntOrNull(16)
+ ?.toString(16)
+ ?.padStart(6, '0')
+ ?.let { mapOf("style" to "color:#$it") }
+ .orEmpty()
private val VALID_ALIGNMENTS = mapOf(
"left" to "text-align:left",