Extension 07 / kotmark-ext-highlight
Highlight
Highlight parsing supports nested inline Markdown inside the marked span.
- Artifact
- io.heapy.kotmark:kotmark-ext-highlight:0.1.0
- Package
- io.heapy.kotmark.ext.highlight
Usage
Enable highlighted text
import io.heapy.kotmark.ext.highlight.highlight
import io.heapy.kotmark.extensions
import io.heapy.kotmark.parser.parser
import io.heapy.kotmark.renderer.html.htmlRenderer
fun renderWithHighlight(markdown: String): String {
val extensions = extensions { highlight() }
val document = parser { extensions(extensions) }.parse(markdown)
return htmlRenderer { extensions(extensions) }.render(document)
}Example
INPUT · Markdown
==important **text**==OUTPUT · HTML
<p><mark>important <strong>text</strong></mark></p>Output
The HTML renderer wraps the highlighted inline content in <mark>. The syntax extension is opt-in and is also available to the Markdown renderer.