Skip to content

Instantly share code, notes, and snippets.

@kpavlov
Last active July 9, 2020 20:32
Show Gist options
  • Save kpavlov/1ee041798785905e6e51aea62f2c592b to your computer and use it in GitHub Desktop.
Save kpavlov/1ee041798785905e6e51aea62f2c592b to your computer and use it in GitHub Desktop.
Hugo shortcode for Kotlin Playground
<script src="https://unpkg.com/kotlin-playground@1" data-selector=".kotlin-code"></script>
<!-- kotlin -->
<code class="language-kotlin kotlin-code"
{{- if .Get "compilerVersion" }}data-version="{{ .Get "compilerVersion" }}"{{ end -}}
{{- if .Get "foldedButton" }}folded-button="{{ .Get "foldedButton" }}"{{ end -}}
{{- if .Get "height" }}data-output-height="{{ .Get "height" }}"{{ end -}}
{{- if .Get "highlightOnly" }}data-highlight-only{{ end -}}
{{- if .Get "jsLibs" }}data-js-libs="{{ .Get "jsLibs" }}"{{ end -}}
{{- if .Get "targetPlatform" }}data-target-platform="{{ .Get "targetPlatform" }}"{{ end -}}
{{- if .Get "theme" }}theme="{{ .Get "theme" }}"{{ end -}}
>{{htmlUnescape .Inner}}</code>
<!-- /kotlin -->
@hakimrie
Copy link

hakimrie commented Jun 19, 2020

thank you for the gist.
I want to ask, how to make hugo to not strip out tag/edge bracket?

for example this code

{{ <kotlin> }}
fun main(args: Array<String>) {
    println("Hello, World!")
}
{{ </kotlin> }}

will result:

fun main(args: Array) {
    println("Hello, World!")
}

because <String> it removed (by hugo)

update: never mind {{htmlUnescape .Inner}} solve the bug

@kpavlov
Copy link
Author

kpavlov commented Jul 9, 2020

Thanks @hakimrie, gist updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment