Ah, now i see what you mean. You don’t want just a
code block
which is created like this:
```language_name_for_highlighting
code block
```
What you want is to have the runable portion. Sorry for the missunderstanding, that’s not standard markdown.
The simplest way would be to share a link to https://play.kotlinlang.org (but i agree that’s not really cool as it takes you to a new website in a new page, bla, bla).
Whoever clicks may run it: Kotlin Playground: Edit, Run, Share Kotlin Code Online.
But what we really want is a runnable piece of code, embeded in the post:
fun main() {
println("HURRRRRR")
}
which is done as follows:
```run-kotlin
fun main() {
println("HURRRRRR")
}
```
Now the question comes to “how did i figure that out”? I looked at the raw markdown of that particular post:
-
Copy the link that you wanna check out:
https://discuss.kotlinlang.org/t/kotlin-needs-try-with-resources/214/54
.
-
Call the
raw
endpoint for that post: https://discuss.kotlinlang.org/raw/214/54?u=thebestpessimist
As for the question of “how did they do it”, i guess it’s a discourse plugin created by jetbrains which handles the code blocks with highlighting run-kotlin
, but idk for sure.