Implemented using Rust + tree-sitter, by @panrz.
The codes provided below will be rendered to HTML and served by the server.
<textarea id="input" style="width: 100%; height: 200px;" spellcheck="false"> {% for i in range(10) %}{{ i }}{% endfor %} </textarea>
Format
<textarea id="output" style="width: 100%; height: 200px;" spellcheck="false"></textarea><script> // Generated by copilot function format() { const input = document.getElementById('input').value; fetch('/format', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ input }), }) .then((res) => res.text()) .then((data) => { document.getElementById('output').value = data; }); } </script>
$ cargo run
And visit localhost:18018