Skip to content

Instantly share code, notes, and snippets.

@lerouxb
Created June 30, 2011 15:02
Show Gist options
  • Select an option

  • Save lerouxb/1056418 to your computer and use it in GitHub Desktop.

Select an option

Save lerouxb/1056418 to your computer and use it in GitHub Desktop.
CodeMirror 2 overlay parser for beard
CodeMirror.defineMode("beard", function(config, parserConfig) {
var beardOverlay = {
token: function(stream, state) {
if (stream.match("{{")) {
while ((ch = stream.next()) != null) {
if (ch == "}" && stream.next() == "}") {
break;
}
}
return "beard";
}
if (stream.match("{#")) {
while ((ch = stream.next()) != null) {
if (ch == "#" && stream.next() == "}") {
break;
}
}
return "comment";
}
while (stream.next() != null && !(
stream.match("{{", false) || stream.match("{#", false))) {
}
return null;
}
};
return CodeMirror.overlayParser(
CodeMirror.getMode(config, parserConfig.backdrop || "text/html"),
beardOverlay);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment