pocketlang/docs/pages/Getting Started/try it now.html

33 lines
848 B
HTML
Raw Normal View History

2021-05-13 03:28:44 +08:00
<main id="code-editor">
<div id="try-title">
<p>code editor</p> <a id="run-button">run</a>
</div>
2021-05-13 18:31:55 +08:00
<div class="editor language-ruby" id="code-area"></div>
2021-05-13 03:28:44 +08:00
<p>output</p>
<pre><div id="output">...</div></pre>
</main>
<script type="module">
const editor = document.querySelector('.editor')
2021-05-13 18:31:55 +08:00
//const highlight = editor => {
// // highlight.js does not trim old tags,
// // let's do it by this hack.
// editor.textContent = editor.textContent;
// editor.innerHTML = Prism.highlight(editor.textContent, Prism.languages.ruby, 'ruby');
//}
2021-05-13 03:28:44 +08:00
2021-05-13 18:31:55 +08:00
const jar = CodeJar(editor, withLineNumbers(highlight_fn), {
2021-05-13 03:28:44 +08:00
indentOn: /[(\[{]$/
})
jar.updateCode(localStorage.getItem('code'))
jar.onUpdate(code => {
localStorage.setItem('code', code)
})
</script>
2021-05-13 18:31:55 +08:00
<script async type="text/javascript" src="{{ STATIC_DIR }}pocketlang.js"></script>