tnorbye / kdoc-formatter

Reformats Kotlin KDoc comments, reflowing text and other cleanup, both via IDE plugin and command line utility
Apache License 2.0
73 stars 2 forks source link

Pre tag flow bug #58

Closed davidtorosyan closed 2 years ago

davidtorosyan commented 2 years ago

The <pre> tag causes some weirdness with flowing.

Before:

/**
 * This tag messes things up.
 * <pre>
 *
 * @return some correct
 * value
 */
fun foo() = Unit

/**
 * Even if it's closed.
 * <pre></pre>
 *
 * @return some correct
 * value
 */
fun foo() = Unit

/**
 * This is fine though.
 *
 * @return some correct
 * value
 */
fun foo() = Unit

After:

/**
 * This tag messes things up.
 * <pre>
 *
 * value
 * @return some correct
 */
fun foo() = Unit

/**
 * Even if it's closed.
 * <pre></pre>
 *
 * value
 * @return some correct
 */
fun foo() = Unit

/**
 * This is fine though.
 *
 * @return some correct value
 */
fun foo() = Unit

When using default options on v1.5.1.

davidtorosyan commented 2 years ago

Would it make sense to fix this by replacing <pre> and </pre> with triple-backticks?

tnorbye commented 2 years ago

This is fixed in 1.5.4 (released just now).

Replacing

 with is a good suggestion, because it turns out <pre> and behave slightly differently (and is handled better by Dokka when it isn't terminated for example). We should track that in a separate issue; the fix above fixes the kdoc formatter to gracefully handle unterminated pre blocks (and blocks), as well as fixes an unrelated issue which didn't handle 
 and 
on the same line.