Fix MD parser lazy evaluation

This commit is contained in:
Alexander Nozik 2022-05-05 21:50:42 +03:00
parent bc94e615be
commit 47634fecc5
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357

View File

@ -18,13 +18,16 @@ object SnarkMarkdownParser:SnarkParser<HtmlFragment> {
private val markdownFlavor = CommonMarkFlavourDescriptor() private val markdownFlavor = CommonMarkFlavourDescriptor()
private val markdownParser = MarkdownParser(markdownFlavor) private val markdownParser = MarkdownParser(markdownFlavor)
override suspend fun parse(bytes: ByteArray, meta: Meta): HtmlFragment = { override suspend fun parse(bytes: ByteArray, meta: Meta): HtmlFragment {
val src = bytes.decodeToString() val src = bytes.decodeToString()
div{
val parsedTree = markdownParser.buildMarkdownTreeFromString(src) val parsedTree = markdownParser.buildMarkdownTreeFromString(src)
val htmlString = HtmlGenerator(src, parsedTree, markdownFlavor).generateHtml()
return {
div{
unsafe { unsafe {
+HtmlGenerator(src, parsedTree, markdownFlavor).generateHtml() +htmlString
}
} }
} }
} }