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
|
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 {
|
dependencies {
|
||||||
api(projects.snarkCore)
|
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("org.jetbrains.kotlin-wrappers:kotlin-css")
|
||||||
|
|
||||||
api("io.ktor:ktor-utils:$ktorVersion")
|
api("io.ktor:ktor-utils:$ktorVersion")
|
||||||
|
|
||||||
api("space.kscience:dataforge-io-yaml:$dataforgeVersion")
|
api("space.kscience:dataforge-io-yaml:$dataforgeVersion")
|
||||||
api("org.jetbrains:markdown:0.3.1")
|
api("org.jetbrains:markdown:0.3.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
readme {
|
readme {
|
||||||
|
@ -48,16 +48,14 @@ internal object SnarkMarkdownParser : SnarkTextParser<HtmlFragment>() {
|
|||||||
private val markdownFlavor = CommonMarkFlavourDescriptor()
|
private val markdownFlavor = CommonMarkFlavourDescriptor()
|
||||||
private val markdownParser = MarkdownParser(markdownFlavor)
|
private val markdownParser = MarkdownParser(markdownFlavor)
|
||||||
|
|
||||||
override fun parseText(text: String, meta: Meta): HtmlFragment {
|
override fun parseText(text: String, meta: Meta): HtmlFragment = HtmlFragment { page ->
|
||||||
val parsedTree = markdownParser.buildMarkdownTreeFromString(text)
|
val transformedText = SnarkHtmlParser.transformText(text, meta, page)
|
||||||
val htmlString = HtmlGenerator(text, parsedTree, markdownFlavor).generateHtml()
|
val parsedTree = markdownParser.buildMarkdownTreeFromString(transformedText)
|
||||||
|
val htmlString = HtmlGenerator(transformedText, parsedTree, markdownFlavor).generateHtml()
|
||||||
|
|
||||||
return HtmlFragment { page ->
|
div {
|
||||||
|
unsafe {
|
||||||
div {
|
+htmlString
|
||||||
unsafe {
|
|
||||||
+SnarkHtmlParser.transformText(htmlString, meta, page)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public fun interface TextProcessor {
|
|||||||
*/
|
*/
|
||||||
public object BasicTextProcessor : 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 ->
|
context(WebPage) override fun process(text: String): String = text.replace(regex) { match ->
|
||||||
when (match.groups[1]!!.value) {
|
when (match.groups[1]!!.value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user