From db27cfaab86a5b7b6b8790b9d7cc15aaa3a207f1 Mon Sep 17 00:00:00 2001 From: WooJin Kong Date: Fri, 3 May 2024 14:35:39 +0900 Subject: [PATCH] feat: Don't parse background-color Sometime background-color make content unreadable --- .../com/kongjak/koreatechboard/util/CssParser.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/kongjak/koreatechboard/util/CssParser.kt b/app/src/main/java/com/kongjak/koreatechboard/util/CssParser.kt index 5d91ec01..aeb6428c 100644 --- a/app/src/main/java/com/kongjak/koreatechboard/util/CssParser.kt +++ b/app/src/main/java/com/kongjak/koreatechboard/util/CssParser.kt @@ -78,19 +78,21 @@ fun parseSpanStyle(css: String?, isDarkMode: Boolean): SpanStyle { key.trim() to value.trim() }.toMap() + val hasBackgroundColor = cssMap.containsKey("background-color") + var color = Color.Unspecified - var backgroundColor = Color.Unspecified var fontWeight: FontWeight? = null var textDecoration = TextDecoration.None for ((key, value) in cssMap) { when (key) { "color" -> { - color = parseColor(value, isDarkMode) - } - - "background-color" -> { - backgroundColor = parseColor(value, isDarkMode) + /* + * If the background color is set, don't parse color. + */ + if (!hasBackgroundColor) { + color = parseColor(value, isDarkMode) + } } "font-weight" -> { @@ -105,7 +107,6 @@ fun parseSpanStyle(css: String?, isDarkMode: Boolean): SpanStyle { return SpanStyle( color = color, - background = backgroundColor, fontWeight = fontWeight, textDecoration = textDecoration )