https://kotlinlang.org logo
#getting-started
Title
# getting-started
c

Colton Idle

03/03/2021, 4:01 AM
I feel like I found conflicting info on how to add a code snippet to a kdoc for my function. @yole in an old SO post said to just use triple backticks
Copy code
But kdoc documentation currently links out to <https://daringfireball.net/projects/markdown/syntax#precode> which seems to say that you should just indent?

Which one is correct?

I just want to have something like this

```/**
* Sample usage
* ```kotlin
* blah.boop()
*
*/``` Is that correct? I thought I would maybe get some syntax highlight in the IDE, but nothing. Is having the kotlin keyword following the backticks not needed?
e

ephemient

03/03/2021, 4:31 AM
Markdown originally only supported 4-space indents for code blocks. most variants also added triple backticks for code blocks. the only way of explicitly specifying a language is with triple backticks.
c

Colton Idle

03/03/2021, 4:41 AM
So my sample above makes sense?
e

ephemient

03/03/2021, 5:22 AM
yes, even if it doesn't render great in IntelliJ it is valid markdown that dokka would be happy to render
although at this time dokka doesn't seem to do syntax highlighting either, but it does at least tag the code blocks in its html output with a css class that you could apply your own highlighter to