diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-08-25 09:41:01 +0200 |
---|---|---|
committer | Marcin Aman <marcin.aman@gmail.com> | 2021-08-25 09:41:01 +0200 |
commit | 3d416fec95e741289b02bf4a4b2e0fdf06de0aea (patch) | |
tree | e65f0a0a84c3a380d8d20f7ee5bd7f1ec05100bb /plugins/base/src/main | |
parent | 9044761979d08b3b116c9f8416dfb42ae216898c (diff) | |
download | dokka-3d416fec95e741289b02bf4a4b2e0fdf06de0aea.tar.gz dokka-3d416fec95e741289b02bf4a4b2e0fdf06de0aea.tar.bz2 dokka-3d416fec95e741289b02bf4a4b2e0fdf06de0aea.zip |
Fix breakable labels and icon on single module project
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 4 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt | 10 |
2 files changed, 6 insertions, 8 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 362447d1..3086b82d 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -734,8 +734,6 @@ open class HtmlRenderer( super.render(root) } - private fun PageNode.root(path: String) = locationProvider.pathToRoot(this) + path - override fun buildPage(page: ContentPage, content: (FlowContent, ContentPage) -> Unit): String = buildHtml(page, page.embeddedResources) { div("main-content") { @@ -755,7 +753,7 @@ open class HtmlRenderer( meta(name = "viewport", content = "width=device-width, initial-scale=1", charset = "UTF-8") title(page.name) templateCommand(PathToRootSubstitutionCommand("###", default = pathToRoot)) { - link(href = page.root("###images/logo-icon.svg"), rel = "icon", type = "image/svg") + link(href = "###images/logo-icon.svg", rel = "icon", type = "image/svg") } templateCommand(PathToRootSubstitutionCommand("###", default = pathToRoot)) { script { unsafe { +"""var pathToRoot = "###";""" } } diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt index d77426da..c77a6e94 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt @@ -12,7 +12,7 @@ fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String, hasLastEleme } buildBreakableText(withOutSpaces.last()) } else { - val content = name.replace(Regex("(?!^)([A-Z])"), " $1").split(" ") + val content = name.replace(Regex("(?<=[a-z])([A-Z])"), " $1").split(" ") joinToHtml(content, hasLastElement) { it } @@ -35,13 +35,13 @@ private fun FlowContent.joinToHtml(elements: List<String>, hasLastElement: Boole elements.dropLast(1).forEach { buildBreakableHtmlElement(onEach(it)) } - elements.last().takeIf { it.isNotBlank() }?.let { + elements.takeIf { it.isNotEmpty() && it.last().isNotEmpty() }?.let { if (hasLastElement) { span { - buildBreakableHtmlElement(it, last = true) + buildBreakableHtmlElement(it.last(), last = true) } } else { - buildBreakableHtmlElement(it, last = false) + buildBreakableHtmlElement(it.last(), last = false) } } } @@ -59,4 +59,4 @@ private fun FlowContent.buildBreakableHtmlElement(element: String, last: Boolean fun FlowContent.buildBreakableText(name: String) = if (name.contains(".")) buildBreakableDotSeparatedHtml(name) - else buildTextBreakableAfterCapitalLetters(name)
\ No newline at end of file + else buildTextBreakableAfterCapitalLetters(name, hasLastElement = true)
\ No newline at end of file |