aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/gfm/gfm.js
diff options
context:
space:
mode:
authorJonathan Duran2012-07-17 11:42:09 -0700
committerJonathan Duran2012-07-17 11:42:09 -0700
commitb4b3e45d6684e77d361b4f8ca5be4889428320c5 (patch)
tree2156d9920ea1b7db49ed6460545fea7cda121bae /imports/codemirror/mode/gfm/gfm.js
parent4a87ff575693509ac578d46af26fa137c0dc3f58 (diff)
parent4f737b24c19ddc02d20f9783b8b080fc6ef11142 (diff)
downloadninja-b4b3e45d6684e77d361b4f8ca5be4889428320c5.tar.gz
Merge branch 'refs/heads/NINJA-master' into TimelineUber
Diffstat (limited to 'imports/codemirror/mode/gfm/gfm.js')
-rw-r--r--imports/codemirror/mode/gfm/gfm.js42
1 files changed, 39 insertions, 3 deletions
diff --git a/imports/codemirror/mode/gfm/gfm.js b/imports/codemirror/mode/gfm/gfm.js
index 01afed7b..8f457c53 100644
--- a/imports/codemirror/mode/gfm/gfm.js
+++ b/imports/codemirror/mode/gfm/gfm.js
@@ -69,7 +69,7 @@ CodeMirror.defineMode("gfm", function(config, parserConfig) {
69 function handleText(stream, mdState) { 69 function handleText(stream, mdState) {
70 var match; 70 var match;
71 if (stream.match(/^\w+:\/\/\S+/)) { 71 if (stream.match(/^\w+:\/\/\S+/)) {
72 return 'linkhref'; 72 return 'link';
73 } 73 }
74 if (stream.match(/^[^\[*\\<>` _][^\[*\\<>` ]*[^\[*\\<>` _]/)) { 74 if (stream.match(/^[^\[*\\<>` _][^\[*\\<>` ]*[^\[*\\<>` _]/)) {
75 return mdMode.getType(mdState); 75 return mdMode.getType(mdState);
@@ -102,7 +102,43 @@ CodeMirror.defineMode("gfm", function(config, parserConfig) {
102 }, 102 },
103 103
104 token: function(stream, state) { 104 token: function(stream, state) {
105 return state.token(stream, state); 105 /* Parse GFM double bracket links */
106 if ((ch = stream.peek()) != undefined && ch == '[') {
107 stream.next(); // Advance the stream
108
109 /* Only handle double bracket links */
110 if ((ch = stream.peek()) == undefined || ch != '[') {
111 stream.backUp(1);
112 return state.token(stream, state);
113 }
114
115 while ((ch = stream.next()) != undefined && ch != ']') {}
116
117 if (ch == ']' && (ch = stream.next()) != undefined && ch == ']')
118 return 'link';
119
120 /* If we did not find the second ']' */
121 stream.backUp(1);
122 }
123
124 /* Match GFM latex formulas, as well as latex formulas within '$' */
125 if (stream.match(/^\$[^\$]+\$/)) {
126 return "string";
127 }
128
129 if (stream.match(/^\\\((.*?)\\\)/)) {
130 return "string";
131 }
132
133 if (stream.match(/^\$\$[^\$]+\$\$/)) {
134 return "string";
135 }
136
137 if (stream.match(/^\\\[(.*?)\\\]/)) {
138 return "string";
139 }
140
141 return state.token(stream, state);
106 } 142 }
107 } 143 }
108}); 144}, "markdown");