kotlin-playground-wp-plugin
kotlin-playground-wp-plugin copied to clipboard
Indentation lost
Switching between "visual" and "text" tabs in WordPress editor loses all indentation in the [kotlin] block. It used to be that this WP plugin did the right indentation at render time (along with code highlighting), but that seems to be gone in the last week or so.
Is that intentional? Can this plugin do the right indentation? See code snippets at https://www.pushing-pixels.org/2018/08/07/replacing-swingworker-with-kotlin-coroutines.html for how it looks like without indentation.
Try to set auto-indent
attribute to true
value. It might helps.
Doesn't seem to be working.
It works on Kotlin Blog
.
Hm. Try to write only in text
mode :)
Well, I can add the indentation back if I only stay in text mode, but that's far from optimal as the first switch to visual will lose the indentation inside all the [kotlin] blocks.
I'm not seeing auto-indent="false"
on the <pre>
blocks generated from [kotlin]
. Is that something that is only inserted for false value of that flag, and skipped for true?
Yes. That's why I recommend to use only text
mode.
auto-indent
it's kotlin playground attribute.
for example:
[kotlin runnable=false auto-indent=true]
suspend fun <T> CompletableFuture<T>.await(): T = suspendCoroutine { cont ->
whenComplete { value, exception ->
when {
exception != null -> cont.resumeWithException(exception)
else -> cont.resume(value)
}
}
}
[/kotlin]
Can't say I agree with this being closed as WAI. What's the point of having this attribute if the plugin expects the code to already be pre-indented?
Codemirror editor has the context-sensitive indentation. This attribute needs to format each of code line after playground's inited.
I've tried this plugin too for https://www.kotlintips.com, but unfortunately, the formatting is lost, no matter if I try auto-indent=true
or not.