How I can color the word in comment in specific color in codemirror?


#1

I use my own mode to color some word in codemirror , I want to color the words inside the comment ("/* ggggg */") in green color , I did not how I can do it with codemirror , my try but not work :

CodeMirror.defineMode(“mymode”, function() {

return {
    token: function(stream,state) {

        if (stream.match("aaa") ) {
            return "style1";
        } else if (stream.match("bbb") ) {
            return "style2";
        } if ( stream.match("/*") ||stream.match("*/") ) {
            //prevToken = null;
            //stream.eatSpace();
            return null;
        }
        else {
            stream.next();
            return null;
        }
    }
};

});

this my try online : my try but not work

What I want : I want when type any word between ("/* */") to color the words in green like the comment in (Visual studio , Netbeans …)

any help ?


#2

thanks solved