Improved editor stability

It is possible to use ctrl-A to select the contents of the editor, and
if that is deleted or pasted you can end up with zero or more than one
editor element, leading to awkward scrollbars in the editor pane. Added
validation to the prism highlight function which ensures that there is
always exactly one editor.