mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-14 15:52:18 +00:00
fix rendering of code blocks escaped with multiple backticks or containing backslashes
#KT-12998 Fixed #KT-12999 Fixed
This commit is contained in:
@@ -154,7 +154,13 @@ object KDocRenderer {
|
||||
sb.trimEnd()
|
||||
wrapChildren("p", newline = true)
|
||||
}
|
||||
MarkdownElementTypes.CODE_SPAN -> wrapChildren("code")
|
||||
MarkdownElementTypes.CODE_SPAN -> {
|
||||
val startDelimiter = node.child(MarkdownTokenTypes.BACKTICK)?.text
|
||||
if (startDelimiter != null) {
|
||||
val text = node.text.substring(startDelimiter.length).removeSuffix(startDelimiter)
|
||||
sb.append("<code>").append(text.htmlEscape()).append("</code>")
|
||||
}
|
||||
}
|
||||
MarkdownElementTypes.CODE_BLOCK,
|
||||
MarkdownElementTypes.CODE_FENCE -> {
|
||||
sb.trimEnd()
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
* Single stars embedded in a word like Embedded*Star have to be preserved as well.
|
||||
*
|
||||
* Exclamation marks are also important! Also in `code blocks!`
|
||||
*
|
||||
* bt+ : ``prefix ` postfix``
|
||||
* backslash: `\`
|
||||
*/
|
||||
fun testMethod() {
|
||||
|
||||
@@ -30,3 +33,4 @@ fun test() {
|
||||
//INFO: <p><a href="psi_element://C">See <strong>this</strong> class</a></p>
|
||||
//INFO: <p>This is <em>emphasized text</em> but text_with_underscores has to preserve the underscores. Single stars embedded in a word like Embedded*Star have to be preserved as well.</p>
|
||||
//INFO: <p>Exclamation marks are also important! Also in <code>code blocks!</code></p>
|
||||
//INFO: <p>bt+ : <code>prefix ` postfix</code> backslash: <code>\</code></p>
|
||||
|
||||
Reference in New Issue
Block a user