Created
June 30, 2011 15:02
-
-
Save lerouxb/1056418 to your computer and use it in GitHub Desktop.
CodeMirror 2 overlay parser for beard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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