People typically write tutorials with code snippets. What if the code snippets can become live by adding a couple of javascript?
Here is the plan:
<script type="text/javascript" src=".../livecode.js"></script>
<script type="text/javascript">
var LIVECODE_RUNTIME = "python";
var LIVECODE_SELECTOR = "pre";
var LIVECODE_URL = "https://livevode.example.com";
</script>
On load, it will convert all <pre> elements into livecode editors. Users will be able to click run to execute that code.
This could be added to any webpage.
It may be possible to find the LIVECODE_URL automatically from the location of the script tag. Python has __file__ to find the path of current module, we need something like that for JS. John Resig has suggested a hack to get something close. It would be interesting to try.
People typically write tutorials with code snippets. What if the code snippets can become live by adding a couple of javascript?
Here is the plan:
On load, it will convert all
<pre>
elements into livecode editors. Users will be able to click run to execute that code. This could be added to any webpage.It may be possible to find the
LIVECODE_URL
automatically from the location of the script tag. Python has__file__
to find the path of current module, we need something like that for JS. John Resig has suggested a hack to get something close. It would be interesting to try.