-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unpaired ``` not gracefully handled #235
Comments
Here's a similar example, in which the triple quotes are not unpaired: Before: /**
* Title ```block```.
* More text.
*/ After formatting once: /**
* Title ```block```.
* ```
* ```
* More text.
* ```
* ```
*/ Each time the file is formatted, 2 more lines of triple quotes are added before and after. |
I started looking into this, and it looks like the problem stems from kdoc lexer tagging whatever token follows " Not sure if we can fix kdoc lexer. But also not sure what an appropriate workaround would be. |
Update: the first issue is indeed fixed, but the second case is still not ideal. Original: /**
* Title ```block```.
* More text.
*/ Formatted: /**
* Title
* ```block```.
* More text.
* ```
*/ Adding a new triple quote seems wrong in this case. That said, this is likely a poor usage of Markdown where single backticks would be better. |
Just ran into this today as well, happy to share more repro cases |
(But not the comments. There isn't a way to turn that off with ktfmt, so manually run kdocformat afterwards, and remove any damaged comments such as extra ``` due to facebook/ktfmt#235 (This also means you should run ./gradlew test, not check, since the test target applies formatting that doesn't match the sources.) To format, run ./gradlew ktfmtFormat
(But not the comments. There isn't a way to turn that off with ktfmt, so manually run kdocformat afterwards, and remove any damaged comments such as extra ``` due to facebook/ktfmt#235 I couldn't find a way to have the ktfmt plugin applied (so I can run the format task) without it also on its own adding itself into the check task, which means check now fails (because the sources don't match ktfmts attempt to format comments too), so for now I've commented out the tasks from the build file. To format, put these back, then run ./gradlew ktfmtFormat
(But not the comments. There isn't a way to turn that off with ktfmt, so manually run kdocformat afterwards, and remove any damaged comments such as extra ``` due to facebook/ktfmt#235 I couldn't find a way to have the ktfmt plugin applied (so I can run the format task) without it also on its own adding itself into the check task, which means check now fails (because the sources don't match ktfmts attempt to format comments too), so for now I've commented out the tasks from the build file. To format, put these back, then run ./gradlew ktfmtFormat
v0.49 formats
to this:
Which seems to me like the issue has been fixed. |
Original code; triple quote is unpaired accidentally
After formatting; an even # of triple quotes are added, which does nothing to solve the problem. Every time formatter is run, more triple quotes are added.
The text was updated successfully, but these errors were encountered: