CodeMirror.defineMode("lilypond", function() { return { token: function(stream) { // Highlight Comments if (stream.match(/%.*$/)) { return "comment"; } // Highlight LilyPond commands (e.g., \relative, \time, \key) if (stream.match(/\\[a-zA-Z]+/)) { return "keyword"; } // Move to the next character stream.next(); return null; } }; });