diff options
author | Kruti Shah | 2012-07-17 12:40:00 -0700 |
---|---|---|
committer | Kruti Shah | 2012-07-17 12:40:00 -0700 |
commit | bf2d7bdb22c28089dc1067bc9094ebc590daac87 (patch) | |
tree | 2156d9920ea1b7db49ed6460545fea7cda121bae /imports/codemirror/mode/gfm | |
parent | 7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff) | |
parent | b4b3e45d6684e77d361b4f8ca5be4889428320c5 (diff) | |
download | ninja-bf2d7bdb22c28089dc1067bc9094ebc590daac87.tar.gz |
Merge branch 'refs/heads/TimelineUberJD' into Timeline-local-kruti
Diffstat (limited to 'imports/codemirror/mode/gfm')
-rw-r--r-- | imports/codemirror/mode/gfm/gfm.js | 42 |
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"); |