Just bail when encountering some unexpected character. This makes it much more tolerable to type a stylesheet into TextEditor with live HTML preview enabled.