Coverage Summary for Class: ImageAttributesAdapterKt (io.heapy.kotmark.renderer.kotlinxhtml.adapters)

Class Method, % Branch, % Line, % Instruction, %
ImageAttributesAdapterKt 100% (5/5) 75% (3/4) 100% (7/7) 100% (27/27)
ImageAttributesAdapterKt$imageAttributesAdapter$1$1$1$1 100% (2/2) 50% (1/2) 66.7% (2/3) 80% (12/15)
ImageAttributesAdapterKt$imageAttributesAdapter$1$2$1 50% (1/2) 66.7% (2/3) 100% (9/9)
Total 88.9% (8/9) 66.7% (4/6) 84.6% (11/13) 94.1% (48/51)


 package io.heapy.kotmark.renderer.kotlinxhtml.adapters
 
 import io.heapy.kotmark.ext.image.attributes.ImageAttributes
 import io.heapy.kotmark.node.AbstractVisitor
 import io.heapy.kotmark.node.CustomNode
 import io.heapy.kotmark.node.Image
 import io.heapy.kotmark.node.Node
 import io.heapy.kotmark.renderer.NodeRenderer
 import io.heapy.kotmark.renderer.html.AttributeProvider
 import io.heapy.kotmark.renderer.kotlinxhtml.KotlinxHtmlAdapter
 
 /** Merges image dimensions without unlinking metadata or otherwise mutating the AST. */
 fun imageAttributesAdapter(): KotlinxHtmlAdapter = KotlinxHtmlAdapter { configuration ->
     configuration.attributeProviderFactory {
         AttributeProvider { node, tag, attributes ->
             if (node is Image && tag == "img") {
                 node.accept(object : AbstractVisitor() {
                     override fun visit(customNode: CustomNode) {
                         if (customNode is ImageAttributes) attributes.putAll(customNode.attributes)
                         else super.visit(customNode)
                     }
                 })
             }
         }
     }
     configuration.nodeRendererFactory {
         object : NodeRenderer {
             override val nodeTypes = setOf(ImageAttributes::class)
             override fun render(node: Node) = Unit
         }
     }
 }