I have implemented the latest code mirror in our asp.net application. the editor allows to type javascript which has commented code and un commented code.
I want to know whether all the code written in the editor is commented or not.
Can anyone please advice.
You can fetch the document text, than pass it through a regex, filtering out all the comments:
var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
lineNumbers: true
});
var out = document.getElementById('out');
out.textContent = editor.getValue()
.replace(/(?:\/\*(?:[\s\S]*?)\*\/)|(?:[\s;]+\/\/(?:.*)$)/gm, '');