Coverage Summary for Class: MathExtension (io.heapy.kotmark.ext.math)
| Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| MathExtension |
83.3%
(5/6)
|
|
85.7%
(6/7)
|
100%
(20/20)
|
| MathExtension$Companion |
100%
(1/1)
|
|
100%
(1/1)
|
100%
(5/5)
|
| Total |
85.7%
(6/7)
|
|
87.5%
(7/8)
|
100%
(25/25)
|
package io.heapy.kotmark.ext.math
import io.heapy.kotmark.Extension
import io.heapy.kotmark.ExtensionsBuilder
import io.heapy.kotmark.ext.math.internal.MathBlockParser
import io.heapy.kotmark.ext.math.internal.MathInlineParser
import io.heapy.kotmark.ext.math.internal.mathNodeRenderers
import io.heapy.kotmark.parser.Parser
import io.heapy.kotmark.renderer.html.HtmlRenderer
import io.heapy.kotmark.renderer.markdown.MarkdownRenderer
import io.heapy.kotmark.renderer.text.TextContentRenderer
import kotlin.jvm.JvmStatic
/** Dollar-delimited math with opaque content; see this module's README for the grammar. */
class MathExtension private constructor() :
Parser.ParserExtension,
HtmlRenderer.HtmlRendererExtension,
TextContentRenderer.TextContentRendererExtension,
MarkdownRenderer.MarkdownRendererExtension {
override fun extend(parserConfiguration: Parser.Configuration) {
parserConfiguration.customInlineContentParserFactory(MathInlineParser.Factory())
parserConfiguration.customBlockParserFactory(MathBlockParser.Factory())
}
override fun extend(rendererConfiguration: HtmlRenderer.Configuration) {
rendererConfiguration.mathNodeRenderers()
}
override fun extend(rendererConfiguration: TextContentRenderer.Configuration) {
rendererConfiguration.mathNodeRenderers()
}
override fun extend(rendererConfiguration: MarkdownRenderer.Configuration) {
rendererConfiguration.mathNodeRenderers()
}
companion object {
@JvmStatic
fun create(): Extension = MathExtension()
}
}
/** Creates and appends [MathExtension]. */
fun ExtensionsBuilder.math() {
add(MathExtension.create())
}