JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://dl.dropbox.com/u/14243582/jscalc/js/rangy-core.js"></script>
<script src="http://dl.dropbox.com/u/14243582/jscalc/js/rangy-selectionsaverestore.js"></script>
<div contenteditable="true" id="pad" onkeyup="formatText();"></div>
CSS
#pad {
border: 1px solid black;
height: 400px;
}
JavaScript
function formatText(){
var savedSel = rangy.saveSelection();
el = document.getElementById('pad');
el.innerHTML = el.innerHTML.replace(/(<([^>]+)>)/ig,"");
el.innerHTML = el.innerHTML.replace(/([0-9])/ig,"<font color='red'>$1</font>");
// Restore the original selection
rangy.restoreSelection(savedSel);
}