aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers
diff options
context:
space:
mode:
authorMarcin Aman <maman@virtuslab.com>2020-09-15 11:34:54 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-09-17 11:08:38 +0200
commitbea6d7d6ad691ca3db180d4cbd5dfb6575ecda03 (patch)
tree87c52e3ad2e94e2af192879ad46cb8dbf2acbc57 /plugins/base/src/main/kotlin/renderers
parentd810c7782814697bb65d078432cd2ace84748a21 (diff)
downloaddokka-bea6d7d6ad691ca3db180d4cbd5dfb6575ecda03.tar.gz
dokka-bea6d7d6ad691ca3db180d4cbd5dfb6575ecda03.tar.bz2
dokka-bea6d7d6ad691ca3db180d4cbd5dfb6575ecda03.zip
Mobile header font size #1475
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt34
3 files changed, 32 insertions, 6 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 93a20157..01f4ed6d 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -633,7 +633,7 @@ open class HtmlRenderer(
consumer.onTagContentEntity(Entities.nbsp)
text(textNode.text)
}
- textNode.hasStyle(TextStyle.Cover) -> buildBreakableDotSeparatedHtml(textNode.text)
+ textNode.hasStyle(TextStyle.Cover) -> buildBreakableText(textNode.text)
else -> text(textNode.text)
}
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
index 24065e57..bc414e23 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
@@ -26,7 +26,7 @@ class NavigationPage(val root: NavigationNode) : RendererSpecificPage {
id = navId
attributes["pageId"] = node.dri.toString()
div("overview") {
- buildLink(node.dri, node.sourceSets.toList()) { buildBreakableDotSeparatedHtml(node.name) }
+ buildLink(node.dri, node.sourceSets.toList()) { buildBreakableText(node.name) }
if (node.children.isNotEmpty()) {
span("navButton pull-right") {
onClick = """document.getElementById("$navId").classList.toggle("hidden");"""
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
index 1102b86d..65bf59fa 100644
--- a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
@@ -3,15 +3,41 @@ package org.jetbrains.dokka.base.renderers.html
import kotlinx.html.FlowContent
import kotlinx.html.span
+fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String) {
+ if (name.contains(" ")) {
+ val withOutSpaces = name.split(" ")
+ withOutSpaces.dropLast(1).forEach {
+ buildBreakableText(it)
+ +" "
+ }
+ buildBreakableText(withOutSpaces.last())
+ } else {
+ val content = name.replace(Regex("(?!^)([A-Z])"), " $1").split(" ")
+ joinToHtml(content){
+ it
+ }
+ }
+}
+
fun FlowContent.buildBreakableDotSeparatedHtml(name: String) {
val phrases = name.split(".")
- phrases.dropLast(1).forEach {
+ joinToHtml(phrases){
+ "$it."
+ }
+}
+
+private fun FlowContent.joinToHtml(elements: List<String>, onEach: (String) -> String) {
+ elements.dropLast(1).forEach {
span {
- +"$it."
+ +onEach(it)
}
wbr { }
}
span {
- +phrases.last()
+ +elements.last()
}
-} \ No newline at end of file
+}
+
+fun FlowContent.buildBreakableText(name: String) =
+ if (name.contains(".")) buildBreakableDotSeparatedHtml(name)
+ else buildTextBreakableAfterCapitalLetters(name) \ No newline at end of file