<p>I've been playing with an exciting feature of HTML5 that I hadn't heard of: the <codeclass="language-html">contentEditable</code> attribute. It's magical! It just makes anything suddenly be editable in-browser! It also finally provides me with the thing I've been wanting ever since growing dissatisfied with text editors: A way to build a <em>new</em> text editor, <em>without</em> having to actually code up the guts of text movement, manipulation, and entry. Oh, happy day!</p>
number = contents:[0-9]+ { return parseInt(contents.join(""), 10); }
</code></pre>
<p>Perhaps the answer is to break up the editor's coding space by lines, as webkit is wont to do. Specifically, this would be good because it'd make it easier to track the cursor position, because it would never change relative to the line element it's contained in!</p>
<styletype="text/css">
#editor div {
margin-left: 1em;
}
.block>code.line {
display: block;
margin-left: 1em;
}
.if>.branch {
display: inline-block;
}
</style>
<divid="editor">
<divclass="block">
<codeclass="line">// a comment!</code>
<codeclass="line">var a = 5;</code>
<codeclass="line">var b = foo(a); </code>
<divclass="if block">
<divclass="if branch">
<divclass="condition">
if (<codeclass="line">b > 100 && b / 7 == 3</code>)
</div>
<divclass="block">
{
<codeclass="line">// Some results should take place</code>