Skip to content

Commit

Permalink
feat: add support for other html-encoded entities i've found
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoverth authored and jherkenhoff committed Oct 6, 2024
1 parent 4aa2dbd commit ca21ca1
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import androidx.compose.ui.unit.em
fun mathExpressionFormatter(
text: String
): AnnotatedString {
val tokens = Regex("""<.*?>|(&nbsp;)+|([^<&]+)?""").findAll(text)
val tokens = Regex("""<.*?>|(&[a-z]+;)+|([^<&]+)?""").findAll(text)

// TODO: Implement <small> tags. (Apparently only used for base designation? https://github.com/Qalculate/libqalculate/blob/21f28b27bf99dc6d9f3325c4960a92ec9ee8934d/libqalculate/MathStructure-print.cc#L3604 )

Expand All @@ -33,6 +33,9 @@ fun mathExpressionFormatter(
"<sub>" -> pushStyle(SpanStyle(baselineShift = BaselineShift.Subscript, fontSize = 0.7.em))
"</sub>" -> pop()
"&nbsp;" -> append("")
"&lt;" -> append("<")
"&gt;" -> append(">")
"&amp;" -> append("&")
else -> append(token.value)
}
}
Expand Down

0 comments on commit ca21ca1

Please sign in to comment.