aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-10-01 09:59:52 +0200
committerKamil Doległo <9080183+kamildoleglo@users.noreply.github.com>2020-10-01 12:06:21 +0200
commitfbee5a49ee4c21bf0f31362bf1f9af46adba7a44 (patch)
treeb12c6671d39445fcf1b4389e8a5d59a5973d1095 /plugins/base/src/main/kotlin/renderers
parent407105fbc9ecd455e675740e444a57917ab3a5d0 (diff)
downloaddokka-fbee5a49ee4c21bf0f31362bf1f9af46adba7a44.tar.gz
dokka-fbee5a49ee4c21bf0f31362bf1f9af46adba7a44.tar.bz2
dokka-fbee5a49ee4c21bf0f31362bf1f9af46adba7a44.zip
Escape urls in anchors
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 01f4ed6d..3eb1c030 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -21,6 +21,7 @@ import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.query
import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.utilities.htmlEscape
+import org.jetbrains.dokka.utilities.urlEncoded
import java.io.File
import java.net.URI
@@ -365,7 +366,7 @@ open class HtmlRenderer(
.filter { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }
.takeIf { it.isNotEmpty() }
?.let {
- val anchorName = node.dci.dri.first().toString()
+ val anchorName = node.dci.dri.first().anchor
withAnchor(anchorName) {
div(classes = "table-row") {
if (!style.contains(MultimoduleTable)) {
@@ -498,7 +499,7 @@ open class HtmlRenderer(
override fun FlowContent.buildHeader(level: Int, node: ContentHeader, content: FlowContent.() -> Unit) {
- val anchor = node.extra[SimpleAttr.SimpleAttrKey("anchor")]?.extraValue
+ val anchor = node.extra[SimpleAttr.SimpleAttrKey("anchor")]?.extraValue?.urlEncoded()
val classes = node.style.joinToString { it.toString() }.toLowerCase()
when (level) {
1 -> h1(classes = classes) { withAnchor(anchor, content) }
@@ -759,3 +760,6 @@ private val PageNode.isNavigable: Boolean
get() = this !is RendererSpecificPage || strategy != RenderingStrategy.DoNothing
fun PropertyContainer<ContentNode>.extraHtmlAttributes() = allOfType<SimpleAttr>()
+
+private val DRI.anchor: String
+ get() = toString().urlEncoded()