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()
|
sb.trimEnd()
|
||||||
wrapChildren("p", newline = true)
|
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_BLOCK,
|
||||||
MarkdownElementTypes.CODE_FENCE -> {
|
MarkdownElementTypes.CODE_FENCE -> {
|
||||||
sb.trimEnd()
|
sb.trimEnd()
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
* Single stars embedded in a word like Embedded*Star have to be preserved as well.
|
* Single stars embedded in a word like Embedded*Star have to be preserved as well.
|
||||||
*
|
*
|
||||||
* Exclamation marks are also important! Also in `code blocks!`
|
* Exclamation marks are also important! Also in `code blocks!`
|
||||||
|
*
|
||||||
|
* bt+ : ``prefix ` postfix``
|
||||||
|
* backslash: `\`
|
||||||
*/
|
*/
|
||||||
fun testMethod() {
|
fun testMethod() {
|
||||||
|
|
||||||
@@ -30,3 +33,4 @@ fun test() {
|
|||||||
//INFO: <p><a href="psi_element://C">See <strong>this</strong> class</a></p>
|
//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>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>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