aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src')
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt6
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt4
2 files changed, 8 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
index 3d0ced06..47180042 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -15,6 +15,7 @@ import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.renderers.Renderer
import org.jetbrains.dokka.transformers.pages.PageTransformer
+import java.io.File
abstract class DefaultRenderer<T>(
protected val context: DokkaContext
@@ -223,3 +224,8 @@ internal typealias SerializedBeforeAndAfter = Pair<String, String>
internal typealias InstanceWithSource = Pair<ContentDivergentInstance, DisplaySourceSet>
fun ContentPage.sourceSets() = this.content.sourceSets
+
+fun ContentEmbeddedResource.isImage(): Boolean {
+ val imageExtensions = setOf("png", "jpg", "jpeg", "gif", "bmp", "tif", "webp", "svg")
+ return File(address).extension.toLowerCase() in imageExtensions
+} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 83af968d..e10672a6 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -9,6 +9,7 @@ import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.renderers.DefaultRenderer
import org.jetbrains.dokka.base.renderers.TabSortingStrategy
+import org.jetbrains.dokka.base.renderers.isImage
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.model.properties.PropertyContainer
@@ -346,8 +347,7 @@ open class HtmlRenderer(
node: ContentEmbeddedResource,
pageContext: ContentPage
) { // TODO: extension point there
- val imageExtensions = setOf("png", "jpg", "jpeg", "gif", "bmp", "tif", "webp", "svg")
- return if (File(node.address).extension.toLowerCase() in imageExtensions) {
+ return if (node.isImage()) {
//TODO: add imgAttrs parsing
val imgAttrs = node.extra.allOfType<SimpleAttr>().joinAttr()
img(src = node.address, alt = node.altText)