I’ve tried to define custom mode for highlight custom markdown syntax with easyMDE like this:
CodeMirror.defineMode("mymode", function () {
return {
token: function (stream, state) {
if (stream.match("aaa")) {
return "style1";
} else if (stream.match("bbb")) {
return "style2";
} else {
stream.next();
return null;
}
},
};
});
window.easyMDE = new EasyMDE({
element: $('#textarea')[0],
parsingConfig: {
allowAtxHeaderWithoutSpace: true,
},
overlayMode: {
mode: CodeMirror.modes.mymode(),
combine: true,
},
});
Actually, CodeMirror don’t return mymode by CodeMirror.getMode('mymode')
so may be there mistake in declaration by CodeMirror.defineMode
in my code.