aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/markdown
diff options
context:
space:
mode:
authorAnanya Sen2012-02-27 14:41:21 -0800
committerAnanya Sen2012-02-27 14:41:21 -0800
commit51ed781953bc44bba3c70938aa57b856394cbc88 (patch)
tree483bcacdcdcc6802d2d048b576406b111656fa05 /imports/codemirror/mode/markdown
parent15d00c49b522aa471d1ccfbbd33f5c0e721eb89e (diff)
downloadninja-51ed781953bc44bba3c70938aa57b856394cbc88.tar.gz
updating to codemirror 2.22
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'imports/codemirror/mode/markdown')
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/markdown/index.html0
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/markdown/markdown.js82
2 files changed, 58 insertions, 24 deletions
diff --git a/imports/codemirror/mode/markdown/index.html b/imports/codemirror/mode/markdown/index.html
index 3a60c03f..3a60c03f 100755..100644
--- a/imports/codemirror/mode/markdown/index.html
+++ b/imports/codemirror/mode/markdown/index.html
diff --git a/imports/codemirror/mode/markdown/markdown.js b/imports/codemirror/mode/markdown/markdown.js
index 455bb43c..800ff0b4 100755..100644
--- a/imports/codemirror/mode/markdown/markdown.js
+++ b/imports/codemirror/mode/markdown/markdown.js
@@ -15,7 +15,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
15 15
16 var hrRE = /^[*-=_]/ 16 var hrRE = /^[*-=_]/
17 , ulRE = /^[*-+]\s+/ 17 , ulRE = /^[*-+]\s+/
18 , olRE = /^[0-9]\.\s+/ 18 , olRE = /^[0-9]+\.\s+/
19 , headerRE = /^(?:\={3,}|-{3,})$/ 19 , headerRE = /^(?:\={3,}|-{3,})$/
20 , codeRE = /^(k:\t|\s{4,})/ 20 , codeRE = /^(k:\t|\s{4,})/
21 , textRE = /^[^\[*_\\<>`]+/; 21 , textRE = /^[^\[*_\\<>`]+/;
@@ -34,35 +34,25 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
34 // Blocks 34 // Blocks
35 35
36 function blockNormal(stream, state) { 36 function blockNormal(stream, state) {
37 var match;
37 if (stream.match(codeRE)) { 38 if (stream.match(codeRE)) {
38 stream.skipToEnd(); 39 stream.skipToEnd();
39 return code; 40 return code;
40 } 41 } else if (stream.eatSpace()) {
41
42 if (stream.eatSpace()) {
43 return null; 42 return null;
44 } 43 } else if (stream.peek() === '#' || stream.match(headerRE)) {
45 44 state.header = true;
46 if (stream.peek() === '#' || stream.match(headerRE)) { 45 } else if (stream.eat('>')) {
47 stream.skipToEnd();
48 return header;
49 }
50 if (stream.eat('>')) {
51 state.indentation++; 46 state.indentation++;
52 return quote; 47 state.quote = true;
53 } 48 } else if (stream.peek() === '[') {
54 if (stream.peek() === '[') {
55 return switchInline(stream, state, footnoteLink); 49 return switchInline(stream, state, footnoteLink);
56 } 50 } else if (hrRE.test(stream.peek())) {
57 if (hrRE.test(stream.peek())) {
58 var re = new RegExp('(?:\s*['+stream.peek()+']){3,}$'); 51 var re = new RegExp('(?:\s*['+stream.peek()+']){3,}$');
59 if (stream.match(re, true)) { 52 if (stream.match(re, true)) {
60 return hr; 53 return hr;
61 } 54 }
62 } 55 } else if (match = stream.match(ulRE, true) || stream.match(olRE, true)) {
63
64 var match;
65 if (match = stream.match(ulRE, true) || stream.match(olRE, true)) {
66 state.indentation += match[0].length; 56 state.indentation += match[0].length;
67 return list; 57 return list;
68 } 58 }
@@ -82,8 +72,39 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
82 72
83 // Inline 73 // Inline
84 function getType(state) { 74 function getType(state) {
85 return state.strong ? (state.em ? emstrong : strong) 75
86 : (state.em ? em : null); 76 // Set defaults
77 returnValue = '';
78
79 // Strong / Emphasis
80 if(state.strong){
81 if(state.em){
82 returnValue += (returnValue ? ' ' : '') + emstrong;
83 } else {
84 returnValue += (returnValue ? ' ' : '') + strong;
85 }
86 } else {
87 if(state.em){
88 returnValue += (returnValue ? ' ' : '') + em;
89 }
90 }
91
92 // Header
93 if(state.header){
94 returnValue += (returnValue ? ' ' : '') + header;
95 }
96
97 // Quotes
98 if(state.quote){
99 returnValue += (returnValue ? ' ' : '') + quote;
100 }
101
102 // Check valud and return
103 if(!returnValue){
104 returnValue = null;
105 }
106 return returnValue;
107
87 } 108 }
88 109
89 function handleText(stream, state) { 110 function handleText(stream, state) {
@@ -192,7 +213,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
192 inline: inlineNormal, 213 inline: inlineNormal,
193 text: handleText, 214 text: handleText,
194 em: false, 215 em: false,
195 strong: false 216 strong: false,
217 header: false,
218 quote: false
196 }; 219 };
197 }, 220 },
198 221
@@ -207,12 +230,23 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
207 inline: s.inline, 230 inline: s.inline,
208 text: s.text, 231 text: s.text,
209 em: s.em, 232 em: s.em,
210 strong: s.strong 233 strong: s.strong,
234 header: s.header,
235 quote: s.quote
211 }; 236 };
212 }, 237 },
213 238
214 token: function(stream, state) { 239 token: function(stream, state) {
215 if (stream.sol()) { 240 if (stream.sol()) {
241 // Reset EM state
242 state.em = false;
243 // Reset STRONG state
244 state.strong = false;
245 // Reset state.header
246 state.header = false;
247 // Reset state.quote
248 state.quote = false;
249
216 state.f = state.block; 250 state.f = state.block;
217 var previousIndentation = state.indentation 251 var previousIndentation = state.indentation
218 , currentIndentation = 0; 252 , currentIndentation = 0;