fix rendering of code blocks escaped with multiple backticks or containing backslashes

#KT-12998 Fixed
 #KT-12999 Fixed
This commit is contained in:
Dmitry Jemerov
2016-07-06 15:07:44 +02:00
parent 801a128547
commit 216d548e98
2 changed files with 11 additions and 1 deletions

View File

@@ -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()

View File

@@ -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>