access-company / kotlin_intro

introduction of Kotlin!
9 stars 5 forks source link

Embedding Kotlin Playgroundに対応する #45

Closed ghost closed 2 years ago

ghost commented 2 years ago

概要

Embedding Kotlin Playground https://blog.jetbrains.com/kotlin/2018/04/embedding-kotlin-playground/#:~:text=Embedded%20Kotlin%20Playground%20works%20on,target%20is%20set%20to%20JVM

に従い、HTMLのヘッダーに以下1行を挿入する

<script src="https://unpkg.com/kotlin-playground@1" data-selector="code"></script>

すると、ページ内で実行環境が出来上がる

これを全ページに適用できれば、access-company/KotlinTrainingが不要になる

調査事項

GitbookでHTMLヘッダーを変えたい場合、どうすればよいか

https://github.com/NoriSte/gitbook-plugin-head-append が使えるかな?

ghost commented 2 years ago

https://github.com/NoriSte/gitbook-plugin-head-append が使えるかな?

https://github.com/access-company/kotlin_intro/commit/973088fe8e15cebe30a507592e22e41fd23220ba で使えることがわかった。

しかし、scriptヘッダーを入れるだけだと文中のcodeブロック全部に適用されてしまうので、例えば

のhelloみたいにビルド対象じゃない箇所にも適用されてしまう。

`〜`なら非適用で```〜```なら適用とか、Kotlinのコードだけに適用、みたいな区別をしたいところ。

ghost commented 2 years ago

```Kotlin〜``` で囲まれるコードにはlang-kotlinクラスが付くので、それをscriptタグに指定 https://github.com/access-company/kotlin_intro/commit/08c8e7252e3588832bf70343fb760f2875cdbd24 すれば期待通りの仕上がりになった

ここはmainクラスがないので再生でけへんけど #49 で全体精査予定