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 :
I’m not sure how they did it, but here is how I did it…
You can do something like this :
var comment = $(this).find('.cm-comment');
for (var i = 0; i < comment.length; i++) {
if (comment.eq(i).text().startsWith('//')) {
comment.eq(i).addClass('inline-comment');
}
}
Find all comments inside the ‘.CodeMirror’ object.
Loop through each and if it starts with two forward slashes (an inline comment) add the class 'inline-comment' to that span.
Now you need to have a style for comments, followed by inline-comment like so: