Make text processor work on initial text, not on processed one.
This commit is contained in:
parent
16ca24d329
commit
62da832db1
@ -1,3 +1,3 @@
|
||||
kotlin.code.style=official
|
||||
|
||||
toolsVersion=0.12.1-kotlin-1.7.20-Beta
|
||||
toolsVersion=0.13.1-kotlin-1.7.20
|
@ -9,13 +9,13 @@ val ktorVersion = space.kscience.gradle.KScienceVersions.ktorVersion
|
||||
dependencies {
|
||||
api(projects.snarkCore)
|
||||
|
||||
api("org.jetbrains.kotlinx:kotlinx-html:0.7.5")
|
||||
api("org.jetbrains.kotlinx:kotlinx-html:0.8.0")
|
||||
api("org.jetbrains.kotlin-wrappers:kotlin-css")
|
||||
|
||||
api("io.ktor:ktor-utils:$ktorVersion")
|
||||
|
||||
api("space.kscience:dataforge-io-yaml:$dataforgeVersion")
|
||||
api("org.jetbrains:markdown:0.3.1")
|
||||
api("org.jetbrains:markdown:0.3.5")
|
||||
}
|
||||
|
||||
readme {
|
||||
|
@ -48,16 +48,14 @@ internal object SnarkMarkdownParser : SnarkTextParser<HtmlFragment>() {
|
||||
private val markdownFlavor = CommonMarkFlavourDescriptor()
|
||||
private val markdownParser = MarkdownParser(markdownFlavor)
|
||||
|
||||
override fun parseText(text: String, meta: Meta): HtmlFragment {
|
||||
val parsedTree = markdownParser.buildMarkdownTreeFromString(text)
|
||||
val htmlString = HtmlGenerator(text, parsedTree, markdownFlavor).generateHtml()
|
||||
override fun parseText(text: String, meta: Meta): HtmlFragment = HtmlFragment { page ->
|
||||
val transformedText = SnarkHtmlParser.transformText(text, meta, page)
|
||||
val parsedTree = markdownParser.buildMarkdownTreeFromString(transformedText)
|
||||
val htmlString = HtmlGenerator(transformedText, parsedTree, markdownFlavor).generateHtml()
|
||||
|
||||
return HtmlFragment { page ->
|
||||
|
||||
div {
|
||||
unsafe {
|
||||
+SnarkHtmlParser.transformText(htmlString, meta, page)
|
||||
}
|
||||
div {
|
||||
unsafe {
|
||||
+htmlString
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public fun interface TextProcessor {
|
||||
*/
|
||||
public object BasicTextProcessor : TextProcessor {
|
||||
|
||||
private val regex = """\$\{([\w.]*)(?>\("([\w.]*)"\))?}""".toRegex()
|
||||
private val regex = """\$\{([\w.]*)(?>\("(.*)"\))?}""".toRegex()
|
||||
|
||||
context(WebPage) override fun process(text: String): String = text.replace(regex) { match ->
|
||||
when (match.groups[1]!!.value) {
|
||||
|
Loading…
Reference in New Issue
Block a user