Hi,
some time ago @Roman_Belov demonstrated (see here ) that runnable Kotlin code can be added to posts on this forum if you specify run-kotlin as a language name in ``` markdown syntax.
I noticed today that this functionality no longer works - is this a bug or was it disabled deliberately?
for(i in 0..5){
println(i)
}
is it?
What am I doing wrong? I use
_```run-kotlin
Eliote
April 26, 2018, 2:59pm
4
fun main(args: Array<String>) {
//sampleStart
println("It needs a main!")
//sampleEnd
}
edit: oh, it works after i refresh the page
edit2: you can also put a //sampleStart and //sampleEnd to hide outside code
Mmmm. It’s still not 100% working. Every time I open up this topic it is displayed wrong and when I refresh it works again.
The same behavior. Windows / Chrome latest
I run Chrome as well, but on a mac and the link @forinil2 shared works for me. So something must be different about that old post
No, the old post is also viewed as runnable only after refresh.
I was bored, so looking at the html of this site it seems like there is a div missing with class “executable-fragment-wrapper”, which only appears after reloading.
html
Before reloading:
<pre><code class="lang-run-kotlin">fun main(args: Array<String>) {
//sampleStart
println("It needs a main!")
//sampleEnd
}
</code></pre>
After reload:
<pre><code class="lang-run-kotlin" data-kotlin-playground-initialized="true" style="display: none;">fun main(args: Array<String>) {
//sampleStart
println("It needs a main!")
//sampleEnd
}
</code>
<div><div class="executable-fragment-wrapper"><div class="executable-fragment"><div class="code-area _folded"><div class="fold-button "></div><div class="zigzag _top "></div><div class="zigzag _bottom "></div><!--if--><div class="run-button "></div><!--if--><textarea style="display: none;"></textarea><div class="CodeMirror cm-s-default"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 12px; left: 21px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea></div><div class="CodeMirror-vscrollbar" cm-not-content="true" style="width: 18px; pointer-events: none;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-hscrollbar" cm-not-content="true" style="height: 18px; pointer-events: none;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 17px; margin-bottom: 0px; border-right-width: 30px; min-height: 16px; min-width: 202.031px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"><div class="CodeMirror-cursor" style="left: 4px; top: 0px; height: 16px;"> </div></div><div class="CodeMirror-code" role="presentation"><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">println</span>(<span class="cm-string">"It needs a main!"</span>)</span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; border-bottom: 0px solid transparent; top: 16px;"></div><div class="CodeMirror-gutters" style="height: 46px; left: 0px;"><div class="CodeMirror-gutter errors-and-warnings-gutter"></div><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div></div><div class="js-code-output-canvas-placeholder"></div></div><div class="compiler-info"><span>Target platform: JVM</span><span>Running on kotlin v. 1.2.40</span></div><!--if--></div>
</div></pre>
Nope, the executable-fragment-wrapper
attribute appends only for the runnable code. Runnable examples always load after DOMContentLoaded
event but some content on this page renders with JavaScript. Right now we are trying to fix this problem.
fun main(args: Array<String>) {
//sampleStart
println("Don't worry! Runnable examples just need a vacation!");
//sampleEnd
}
For future finders of this post, here is an article explaining the features and how you can use it on your own sites as well:
3 Likes