mirror of
https://github.com/zekexiao/pocketlang.git
synced 2025-02-06 20:50:55 +08:00
33 lines
848 B
HTML
33 lines
848 B
HTML
<main id="code-editor">
|
|
|
|
<div id="try-title">
|
|
<p>code editor</p> <a id="run-button">run</a>
|
|
</div>
|
|
|
|
<div class="editor language-ruby" id="code-area"></div>
|
|
|
|
<p>output</p>
|
|
<pre><div id="output">...</div></pre>
|
|
</main>
|
|
|
|
<script type="module">
|
|
const editor = document.querySelector('.editor')
|
|
|
|
//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');
|
|
//}
|
|
|
|
const jar = CodeJar(editor, withLineNumbers(highlight_fn), {
|
|
indentOn: /[(\[{]$/
|
|
})
|
|
|
|
jar.updateCode(localStorage.getItem('code'))
|
|
jar.onUpdate(code => {
|
|
localStorage.setItem('code', code)
|
|
})
|
|
</script>
|
|
|
|
<script async type="text/javascript" src="{{ STATIC_DIR }}pocketlang.js"></script> |