appendTextRaw(newline)
}
+ protected fun lastParagraph() {
+ if (!internalState.suppressEndParagraph)
+ appendTextRaw("</p>")
+ }
+
protected fun cancelEndParagraph() {
internalState.suppressEndParagraph = true
}
protected fun cancelStartParagraph() {
if (scope.write.endsWith("<p>"))
- scope.write.deleteRange(scope.write.length - 3, scope.write.length)
+ scope.write.deleteRange(scope.write.length - "<p>".length, scope.write.length)
}
class Initial<TContext>(scope: TextParserScope<TContext>) : TextParserState<TContext>(scope, listOf(), TextParserInternalState()) {
override fun processEndOfText() {
appendText(text.removeSuffix("\n"))
if (text.isNotBlank())
- appendTextRaw("</p>")
+ lastParagraph()
}
}
override fun processEndOfText() {
appendText(text.removeSuffix("\n"))
if (text.isNotBlank())
- appendTextRaw("</p>")
+ lastParagraph()
}
}
override fun processEndOfText() {
appendText("[$tag")
- appendTextRaw("</p>")
+ lastParagraph()
}
}
override fun processEndOfText() {
appendText("[$tag=$param")
- appendTextRaw("</p>")
+ lastParagraph()
}
}
override fun processEndOfText() {
appendText("[/$tag")
- appendTextRaw("</p>")
+ lastParagraph()
}
}
CODE(
TextParserTagType.Direct(
false,
- { _, _ -> "<span style='font-family: JetBrains Mono'><pre>" },
- { _ -> "</pre></span>" },
+ { _, _ -> "<span style='font-family: JetBrains Mono'>" },
+ { _ -> "</span>" },
+ )
+ ),
+ CODE_BLOCK(
+ TextParserTagType.Direct(
+ true,
+ { _, _ -> "<div style='font-family: JetBrains Mono'><pre>" },
+ { _ -> "</pre></div>" },
)
),
H1(