aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/gfm/gfm.js
diff options
context:
space:
mode:
authorJon Reid2012-07-17 16:03:14 -0700
committerJon Reid2012-07-17 16:03:14 -0700
commit42a51e0c27f2e2cd825d07b3af5ec05b0e5208b3 (patch)
tree67deeb8c5b34aacc91f737cc64a3bc9ef1f4f05f /imports/codemirror/mode/gfm/gfm.js
parenta12cabc16273ffe04af4bce1f7438dc9326efa89 (diff)
parentb4b3e45d6684e77d361b4f8ca5be4889428320c5 (diff)
downloadninja-42a51e0c27f2e2cd825d07b3af5ec05b0e5208b3.tar.gz
Merge remote-tracking branch 'ninja-jduran/TimelineUber' into timeline-local
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");