Skip to content

Commit

Permalink
Handle escaped markdown characters in KDoc
Browse files Browse the repository at this point in the history
Summary:
We never encountered that until now, so all it required was handling this case as well.

Fixes #329

Reviewed By: cgrushko

Differential Revision: D37038044

fbshipit-source-id: 21d89dc7186f6e46369980d94a97da8548a0f793
  • Loading branch information
strulovich authored and facebook-github-bot committed Jun 9, 2022
1 parent 0b5d3d1 commit 5f7b063
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ object KDocFormatter {
KDocTokens.MARKDOWN_LINK -> {
tokens.add(KDocToken(MARKDOWN_LINK, tokenText))
}
KDocTokens.MARKDOWN_ESCAPED_CHAR,
KDocTokens.TEXT -> {
var first = true
for (word in tokenizeKdocText(tokenText)) {
Expand Down
8 changes: 8 additions & 0 deletions core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,14 @@ class FormatterTest {
| */
|""".trimMargin())

@Test
fun `formatting kdoc with markdown errors`() =
assertFormatted(
"""
|/** \[ */
|fun markdownError() = Unit
|""".trimMargin())

@Test
fun `return statement with value`() =
assertFormatted(
Expand Down

0 comments on commit 5f7b063

Please sign in to comment.