codemirror-rails 2.2.1 → 2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. data/README.md +8 -0
  2. data/codemirror-rails.gemspec +1 -1
  3. data/lib/codemirror/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/codemirror.js +842 -422
  5. data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +2 -2
  6. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +722 -32
  7. data/vendor/assets/javascripts/codemirror/modes/clike.js +31 -9
  8. data/vendor/assets/javascripts/codemirror/modes/clojure.js +14 -14
  9. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +59 -37
  10. data/vendor/assets/javascripts/codemirror/modes/css.js +1 -1
  11. data/vendor/assets/javascripts/codemirror/modes/diff.js +24 -5
  12. data/vendor/assets/javascripts/codemirror/modes/ecl.js +203 -0
  13. data/vendor/assets/javascripts/codemirror/modes/erlang.js +251 -0
  14. data/vendor/assets/javascripts/codemirror/modes/gfm.js +40 -4
  15. data/vendor/assets/javascripts/codemirror/modes/go.js +170 -0
  16. data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +1 -1
  17. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +4 -2
  18. data/vendor/assets/javascripts/codemirror/modes/javascript.js +10 -9
  19. data/vendor/assets/javascripts/codemirror/modes/less.js +232 -0
  20. data/vendor/assets/javascripts/codemirror/modes/markdown.js +52 -49
  21. data/vendor/assets/javascripts/codemirror/modes/mysql.js +188 -0
  22. data/vendor/assets/javascripts/codemirror/modes/pascal.js +2 -46
  23. data/vendor/assets/javascripts/codemirror/modes/perl.js +1 -1
  24. data/vendor/assets/javascripts/codemirror/modes/php.js +55 -25
  25. data/vendor/assets/javascripts/codemirror/modes/pig.js +172 -0
  26. data/vendor/assets/javascripts/codemirror/modes/properties.js +63 -0
  27. data/vendor/assets/javascripts/codemirror/modes/python.js +37 -32
  28. data/vendor/assets/javascripts/codemirror/modes/rpm-spec.js +1 -1
  29. data/vendor/assets/javascripts/codemirror/modes/rst.js +1 -1
  30. data/vendor/assets/javascripts/codemirror/modes/ruby.js +14 -14
  31. data/vendor/assets/javascripts/codemirror/modes/rust.js +36 -15
  32. data/vendor/assets/javascripts/codemirror/modes/scheme.js +74 -46
  33. data/vendor/assets/javascripts/codemirror/modes/shell.js +103 -0
  34. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +16 -16
  35. data/vendor/assets/javascripts/codemirror/modes/smarty.js +148 -0
  36. data/vendor/assets/javascripts/codemirror/modes/stex.js +21 -6
  37. data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +55 -45
  38. data/vendor/assets/javascripts/codemirror/modes/tiki.js +316 -0
  39. data/vendor/assets/javascripts/codemirror/modes/vbscript.js +26 -0
  40. data/vendor/assets/javascripts/codemirror/modes/verilog.js +194 -0
  41. data/vendor/assets/javascripts/codemirror/modes/xml.js +89 -16
  42. data/vendor/assets/javascripts/codemirror/modes/xmlpure.js +5 -0
  43. data/vendor/assets/javascripts/codemirror/modes/xquery.js +448 -0
  44. data/vendor/assets/javascripts/codemirror/utils/closetag.js +146 -0
  45. data/vendor/assets/javascripts/codemirror/utils/dialog.js +63 -0
  46. data/vendor/assets/javascripts/codemirror/utils/foldcode.js +196 -0
  47. data/vendor/assets/javascripts/codemirror/utils/formatting.js +297 -0
  48. data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +134 -0
  49. data/vendor/assets/javascripts/codemirror/utils/loadmode.js +51 -0
  50. data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +44 -0
  51. data/vendor/assets/javascripts/codemirror/utils/multiplex.js +72 -0
  52. data/vendor/assets/javascripts/codemirror/{overlay.js → utils/overlay.js} +3 -2
  53. data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +123 -0
  54. data/vendor/assets/javascripts/codemirror/utils/runmode.js +49 -0
  55. data/vendor/assets/javascripts/codemirror/utils/search.js +118 -0
  56. data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +117 -0
  57. data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +72 -0
  58. data/vendor/assets/stylesheets/codemirror.css +69 -5
  59. data/vendor/assets/stylesheets/codemirror/modes/tiddlywiki.css +14 -21
  60. data/vendor/assets/stylesheets/codemirror/modes/tiki.css +26 -0
  61. data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +81 -0
  62. data/vendor/assets/stylesheets/codemirror/themes/blackboard.css +25 -0
  63. data/vendor/assets/stylesheets/codemirror/themes/cobalt.css +1 -1
  64. data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +1 -1
  65. data/vendor/assets/stylesheets/codemirror/themes/elegant.css +2 -2
  66. data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +21 -0
  67. data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +44 -0
  68. data/vendor/assets/stylesheets/codemirror/themes/monokai.css +1 -1
  69. data/vendor/assets/stylesheets/codemirror/themes/neat.css +3 -3
  70. data/vendor/assets/stylesheets/codemirror/themes/night.css +1 -1
  71. data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +2 -2
  72. data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +27 -0
  73. data/vendor/assets/stylesheets/codemirror/themes/xq-dark.css +46 -0
  74. data/vendor/assets/stylesheets/codemirror/utils/dialog.css +23 -0
  75. data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +16 -0
  76. metadata +41 -10
  77. data/vendor/assets/javascripts/codemirror/runmode.js +0 -27
  78. data/vendor/assets/stylesheets/codemirror/modes/clike.css +0 -7
  79. data/vendor/assets/stylesheets/codemirror/modes/markdown.css +0 -10
  80. data/vendor/assets/stylesheets/codemirror/modes/rst.css +0 -75
  81. data/vendor/assets/stylesheets/codemirror/themes/default.css +0 -19
@@ -0,0 +1,103 @@
1
+ CodeMirror.defineMode('shell', function(config) {
2
+
3
+ var atoms = ['true','false'],
4
+ keywords = ['if','then','do','else','elif','while','until','for','in','esac','fi','fin','fil','done','exit','set','unset','export','function'],
5
+ commands = ['ab','awk','bash','beep','cat','cc','cd','chown','chmod','chroot','clear','cp','curl','cut','diff','echo','find','gawk','gcc','get','git','grep','kill','killall','ls','make','mkdir','openssl','mv','nc','node','npm','ping','ps','restart','rm','rmdir','sed','service','sh','shopt','shred','source','sort','sleep','ssh','start','stop','su','sudo','tee','telnet','top','touch','vi','vim','wall','wc','wget','who','write','yes','zsh'];
6
+
7
+ function tokenBase(stream, state) {
8
+
9
+ var sol = stream.sol();
10
+ var ch = stream.next();
11
+
12
+ if (ch === '\'' || ch === '"' || ch === '`') {
13
+ state.tokens.unshift(tokenString(ch));
14
+ return tokenize(stream, state);
15
+ }
16
+ if (ch === '#') {
17
+ if (sol && stream.eat('!')) {
18
+ stream.skipToEnd();
19
+ return 'meta'; // 'comment'?
20
+ }
21
+ stream.skipToEnd();
22
+ return 'comment';
23
+ }
24
+ if (ch === '$') {
25
+ state.tokens.unshift(tokenDollar);
26
+ return tokenize(stream, state);
27
+ }
28
+ if (ch === '+' || ch === '=') {
29
+ return 'operator';
30
+ }
31
+ if (ch === '-') {
32
+ stream.eat('-');
33
+ stream.eatWhile(/\w/);
34
+ return 'attribute';
35
+ }
36
+ if (/\d/.test(ch)) {
37
+ stream.eatWhile(/\d/);
38
+ if(!/\w/.test(stream.peek())) {
39
+ return 'number';
40
+ }
41
+ }
42
+ stream.eatWhile(/\w/);
43
+ var cur = stream.current();
44
+ if (stream.peek() === '=' && /\w+/.test(cur)) return 'def';
45
+ if (atoms.indexOf(cur) !== -1) return 'atom';
46
+ if (commands.indexOf(cur) !== -1) return 'builtin';
47
+ if (keywords.indexOf(cur) !== -1) return 'keyword';
48
+ return 'word';
49
+ }
50
+
51
+ function tokenString(quote) {
52
+ return function(stream, state) {
53
+ var next, end = false, escaped = false;
54
+ while ((next = stream.next()) != null) {
55
+ if (next === quote && !escaped) {
56
+ end = true;
57
+ break;
58
+ }
59
+ if (next === '$' && !escaped && quote !== '\'') {
60
+ escaped = true;
61
+ stream.backUp(1);
62
+ state.tokens.unshift(tokenDollar);
63
+ break;
64
+ }
65
+ escaped = !escaped && next === '\\';
66
+ }
67
+ if (end || !escaped) {
68
+ state.tokens.shift();
69
+ }
70
+ return (quote === '`' || quote === ')' ? 'quote' : 'string');
71
+ };
72
+ };
73
+
74
+ var tokenDollar = function(stream, state) {
75
+ if (state.tokens.length > 1) stream.eat('$');
76
+ var ch = stream.next(), hungry = /\w/;
77
+ if (ch === '{') hungry = /[^}]/;
78
+ if (ch === '(') {
79
+ state.tokens[0] = tokenString(')');
80
+ return tokenize(stream, state);
81
+ }
82
+ if (!/\d/.test(ch)) {
83
+ stream.eatWhile(hungry);
84
+ stream.eat('}');
85
+ }
86
+ state.tokens.shift();
87
+ return 'def';
88
+ };
89
+
90
+ function tokenize(stream, state) {
91
+ return (state.tokens[0] || tokenBase) (stream, state);
92
+ };
93
+
94
+ return {
95
+ startState: function() {return {tokens:[]}},
96
+ token: function(stream, state) {
97
+ if (stream.eatSpace()) return null;
98
+ return tokenize(stream, state);
99
+ }
100
+ };
101
+ });
102
+
103
+ CodeMirror.defineMIME('text/x-sh', 'shell');
@@ -27,45 +27,45 @@ CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
27
27
 
28
28
  var next = function(stream, context, state) {
29
29
  var token = new Token(null, context, false);
30
- var char = stream.next();
30
+ var aChar = stream.next();
31
31
 
32
- if (char === '"') {
32
+ if (aChar === '"') {
33
33
  token = nextComment(stream, new Context(nextComment, context));
34
34
 
35
- } else if (char === '\'') {
35
+ } else if (aChar === '\'') {
36
36
  token = nextString(stream, new Context(nextString, context));
37
37
 
38
- } else if (char === '#') {
38
+ } else if (aChar === '#') {
39
39
  stream.eatWhile(/[^ .]/);
40
40
  token.name = 'string-2';
41
41
 
42
- } else if (char === '$') {
42
+ } else if (aChar === '$') {
43
43
  stream.eatWhile(/[^ ]/);
44
44
  token.name = 'string-2';
45
45
 
46
- } else if (char === '|' && state.expectVariable) {
46
+ } else if (aChar === '|' && state.expectVariable) {
47
47
  token.context = new Context(nextTemporaries, context);
48
48
 
49
- } else if (/[\[\]{}()]/.test(char)) {
49
+ } else if (/[\[\]{}()]/.test(aChar)) {
50
50
  token.name = 'bracket';
51
- token.eos = /[\[{(]/.test(char);
51
+ token.eos = /[\[{(]/.test(aChar);
52
52
 
53
- if (char === '[') {
53
+ if (aChar === '[') {
54
54
  state.indentation++;
55
- } else if (char === ']') {
55
+ } else if (aChar === ']') {
56
56
  state.indentation = Math.max(0, state.indentation - 1);
57
57
  }
58
58
 
59
- } else if (specialChars.test(char)) {
59
+ } else if (specialChars.test(aChar)) {
60
60
  stream.eatWhile(specialChars);
61
61
  token.name = 'operator';
62
- token.eos = char !== ';'; // ; cascaded message expression
62
+ token.eos = aChar !== ';'; // ; cascaded message expression
63
63
 
64
- } else if (/\d/.test(char)) {
64
+ } else if (/\d/.test(aChar)) {
65
65
  stream.eatWhile(/[\w\d]/);
66
66
  token.name = 'number'
67
67
 
68
- } else if (/[\w_]/.test(char)) {
68
+ } else if (/[\w_]/.test(aChar)) {
69
69
  stream.eatWhile(/[\w\d_]/);
70
70
  token.name = state.expectVariable ? (keywords.test(stream.current()) ? 'keyword' : 'variable') : null;
71
71
 
@@ -88,9 +88,9 @@ CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
88
88
 
89
89
  var nextTemporaries = function(stream, context, state) {
90
90
  var token = new Token(null, context, false);
91
- var char = stream.next();
91
+ var aChar = stream.next();
92
92
 
93
- if (char === '|') {
93
+ if (aChar === '|') {
94
94
  token.context = context.parent;
95
95
  token.eos = true;
96
96
 
@@ -0,0 +1,148 @@
1
+ CodeMirror.defineMode("smarty", function(config, parserConfig) {
2
+ var keyFuncs = ["debug", "extends", "function", "include", "literal"];
3
+ var last;
4
+ var regs = {
5
+ operatorChars: /[+\-*&%=<>!?]/,
6
+ validIdentifier: /[a-zA-Z0-9\_]/,
7
+ stringChar: /[\'\"]/
8
+ }
9
+ var leftDelim = (typeof config.mode.leftDelimiter != 'undefined') ? config.mode.leftDelimiter : "{";
10
+ var rightDelim = (typeof config.mode.rightDelimiter != 'undefined') ? config.mode.rightDelimiter : "}";
11
+ function ret(style, lst) { last = lst; return style; }
12
+
13
+
14
+ function tokenizer(stream, state) {
15
+ function chain(parser) {
16
+ state.tokenize = parser;
17
+ return parser(stream, state);
18
+ }
19
+
20
+ if (stream.match(leftDelim, true)) {
21
+ if (stream.eat("*")) {
22
+ return chain(inBlock("comment", "*" + rightDelim));
23
+ }
24
+ else {
25
+ state.tokenize = inSmarty;
26
+ return "tag";
27
+ }
28
+ }
29
+ else {
30
+ // I'd like to do an eatWhile() here, but I can't get it to eat only up to the rightDelim string/char
31
+ stream.next();
32
+ return null;
33
+ }
34
+ }
35
+
36
+ function inSmarty(stream, state) {
37
+ if (stream.match(rightDelim, true)) {
38
+ state.tokenize = tokenizer;
39
+ return ret("tag", null);
40
+ }
41
+
42
+ var ch = stream.next();
43
+ if (ch == "$") {
44
+ stream.eatWhile(regs.validIdentifier);
45
+ return ret("variable-2", "variable");
46
+ }
47
+ else if (ch == ".") {
48
+ return ret("operator", "property");
49
+ }
50
+ else if (regs.stringChar.test(ch)) {
51
+ state.tokenize = inAttribute(ch);
52
+ return ret("string", "string");
53
+ }
54
+ else if (regs.operatorChars.test(ch)) {
55
+ stream.eatWhile(regs.operatorChars);
56
+ return ret("operator", "operator");
57
+ }
58
+ else if (ch == "[" || ch == "]") {
59
+ return ret("bracket", "bracket");
60
+ }
61
+ else if (/\d/.test(ch)) {
62
+ stream.eatWhile(/\d/);
63
+ return ret("number", "number");
64
+ }
65
+ else {
66
+ if (state.last == "variable") {
67
+ if (ch == "@") {
68
+ stream.eatWhile(regs.validIdentifier);
69
+ return ret("property", "property");
70
+ }
71
+ else if (ch == "|") {
72
+ stream.eatWhile(regs.validIdentifier);
73
+ return ret("qualifier", "modifier");
74
+ }
75
+ }
76
+ else if (state.last == "whitespace") {
77
+ stream.eatWhile(regs.validIdentifier);
78
+ return ret("attribute", "modifier");
79
+ }
80
+ else if (state.last == "property") {
81
+ stream.eatWhile(regs.validIdentifier);
82
+ return ret("property", null);
83
+ }
84
+ else if (/\s/.test(ch)) {
85
+ last = "whitespace";
86
+ return null;
87
+ }
88
+
89
+ var str = "";
90
+ if (ch != "/") {
91
+ str += ch;
92
+ }
93
+ var c = "";
94
+ while ((c = stream.eat(regs.validIdentifier))) {
95
+ str += c;
96
+ }
97
+ var i, j;
98
+ for (i=0, j=keyFuncs.length; i<j; i++) {
99
+ if (keyFuncs[i] == str) {
100
+ return ret("keyword", "keyword");
101
+ }
102
+ }
103
+ if (/\s/.test(ch)) {
104
+ return null;
105
+ }
106
+ return ret("tag", "tag");
107
+ }
108
+ }
109
+
110
+ function inAttribute(quote) {
111
+ return function(stream, state) {
112
+ while (!stream.eol()) {
113
+ if (stream.next() == quote) {
114
+ state.tokenize = inSmarty;
115
+ break;
116
+ }
117
+ }
118
+ return "string";
119
+ };
120
+ }
121
+
122
+ function inBlock(style, terminator) {
123
+ return function(stream, state) {
124
+ while (!stream.eol()) {
125
+ if (stream.match(terminator)) {
126
+ state.tokenize = tokenizer;
127
+ break;
128
+ }
129
+ stream.next();
130
+ }
131
+ return style;
132
+ };
133
+ }
134
+
135
+ return {
136
+ startState: function() {
137
+ return { tokenize: tokenizer, mode: "smarty", last: null };
138
+ },
139
+ token: function(stream, state) {
140
+ var style = state.tokenize(stream, state);
141
+ state.last = last;
142
+ return style;
143
+ },
144
+ electricChars: ""
145
+ }
146
+ });
147
+
148
+ CodeMirror.defineMIME("text/x-smarty", "smarty");
@@ -82,22 +82,37 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
82
82
  }
83
83
 
84
84
  function normal(source, state) {
85
- if (source.match(/^\\[a-z]+/)) {
85
+ if (source.match(/^\\[a-zA-Z@]+/)) {
86
86
  var cmdName = source.current();
87
87
  cmdName = cmdName.substr(1, cmdName.length-1);
88
- var plug = plugins[cmdName];
89
- if (typeof(plug) == 'undefined') {
90
- plug = plugins["DEFAULT"];
91
- }
88
+ var plug;
89
+ if (plugins.hasOwnProperty(cmdName)) {
90
+ plug = plugins[cmdName];
91
+ } else {
92
+ plug = plugins["DEFAULT"];
93
+ }
92
94
  plug = new plug();
93
95
  pushCommand(state, plug);
94
96
  setState(state, beginParams);
95
97
  return plug.style;
96
98
  }
97
99
 
100
+ // escape characters
101
+ if (source.match(/^\\[$&%#{}_]/)) {
102
+ return "tag";
103
+ }
104
+
105
+ // white space control characters
106
+ if (source.match(/^\\[,;!\/]/)) {
107
+ return "tag";
108
+ }
109
+
98
110
  var ch = source.next();
99
111
  if (ch == "%") {
100
- setState(state, inCComment);
112
+ // special case: % at end of its own line; stay in same state
113
+ if (!source.eol()) {
114
+ setState(state, inCComment);
115
+ }
101
116
  return "comment";
102
117
  }
103
118
  else if (ch=='}' || ch==']') {
@@ -1,18 +1,18 @@
1
1
  /***
2
- |''Name''|tiddlywiki.js|
3
- |''Description''|Enables TiddlyWikiy syntax highlighting using CodeMirror2|
4
- |''Author''|PMario|
5
- |''Version''|0.1.6|
6
- |''Status''|''beta''|
7
- |''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]|
8
- |''Documentation''|http://codemirror.tiddlyspace.com/|
9
- |''License''|[[MIT License|http://www.opensource.org/licenses/mit-license.php]]|
10
- |''CoreVersion''|2.5.0|
11
- |''Requires''|codemirror.js|
12
- |''Keywords''|syntax highlighting color code mirror codemirror|
13
- ! Info
14
- CoreVersion parameter is needed for TiddlyWiki only!
15
- ***/
2
+ |''Name''|tiddlywiki.js|
3
+ |''Description''|Enables TiddlyWikiy syntax highlighting using CodeMirror|
4
+ |''Author''|PMario|
5
+ |''Version''|0.1.7|
6
+ |''Status''|''stable''|
7
+ |''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]|
8
+ |''Documentation''|http://codemirror.tiddlyspace.com/|
9
+ |''License''|[[MIT License|http://www.opensource.org/licenses/mit-license.php]]|
10
+ |''CoreVersion''|2.5.0|
11
+ |''Requires''|codemirror.js|
12
+ |''Keywords''|syntax highlighting color code mirror codemirror|
13
+ ! Info
14
+ CoreVersion parameter is needed for TiddlyWiki only!
15
+ ***/
16
16
  //{{{
17
17
  CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
18
18
  var indentUnit = config.indentUnit;
@@ -47,20 +47,20 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
47
47
  }();
48
48
 
49
49
  var isSpaceName = /[\w_\-]/i,
50
- reHR = /^\-\-\-\-+$/,
50
+ reHR = /^\-\-\-\-+$/, // <hr>
51
51
  reWikiCommentStart = /^\/\*\*\*$/, // /***
52
52
  reWikiCommentStop = /^\*\*\*\/$/, // ***/
53
53
  reBlockQuote = /^<<<$/,
54
54
 
55
- reJsCodeStart = /^\/\/\{\{\{$/, // //{{{
56
- reJsCodeStop = /^\/\/\}\}\}$/, // //}}}
57
- reXmlCodeStart = /^<!--\{\{\{-->$/,
58
- reXmlCodeStop = /^<!--\}\}\}-->$/,
55
+ reJsCodeStart = /^\/\/\{\{\{$/, // //{{{ js block start
56
+ reJsCodeStop = /^\/\/\}\}\}$/, // //}}} js stop
57
+ reXmlCodeStart = /^<!--\{\{\{-->$/, // xml block start
58
+ reXmlCodeStop = /^<!--\}\}\}-->$/, // xml stop
59
59
 
60
- reCodeBlockStart = /^\{\{\{$/,
61
- reCodeBlockStop = /^\}\}\}$/,
60
+ reCodeBlockStart = /^\{\{\{$/, // {{{ TW text div block start
61
+ reCodeBlockStop = /^\}\}\}$/, // }}} TW text stop
62
62
 
63
- reCodeStart = /\{\{\{/,
63
+ reCodeStart = /\{\{\{/, // {{{ code span start
64
64
  reUntilCodeStop = /.*?\}\}\}/;
65
65
 
66
66
  function chain(stream, state, f) {
@@ -95,9 +95,9 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
95
95
 
96
96
  state.block = false; // indicates the start of a code block.
97
97
 
98
- ch = stream.peek(); // don't eat, to make match simpler
98
+ ch = stream.peek(); // don't eat, to make matching simpler
99
99
 
100
- // check start of blocks
100
+ // check start of blocks
101
101
  if (sol && /[<\/\*{}\-]/.test(ch)) {
102
102
  if (stream.match(reCodeBlockStart)) {
103
103
  state.block = true;
@@ -107,16 +107,16 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
107
107
  return ret('quote', 'quote');
108
108
  }
109
109
  if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop)) {
110
- return ret('code', 'code');
110
+ return ret('code', 'comment');
111
111
  }
112
112
  if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop)) {
113
- return ret('code', 'code');
113
+ return ret('code', 'comment');
114
114
  }
115
115
  if (stream.match(reHR)) {
116
116
  return ret('hr', 'hr');
117
117
  }
118
118
  } // sol
119
- var ch = stream.next();
119
+ ch = stream.next();
120
120
 
121
121
  if (sol && /[\/\*!#;:>|]/.test(ch)) {
122
122
  if (ch == "!") { // tw header
@@ -125,26 +125,26 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
125
125
  }
126
126
  if (ch == "*") { // tw list
127
127
  stream.eatWhile('*');
128
- return ret("list", "list");
128
+ return ret("list", "comment");
129
129
  }
130
130
  if (ch == "#") { // tw numbered list
131
131
  stream.eatWhile('#');
132
- return ret("list", "list");
132
+ return ret("list", "comment");
133
133
  }
134
- if (ch == ";") { // tw list
134
+ if (ch == ";") { // definition list, term
135
135
  stream.eatWhile(';');
136
- return ret("list", "list");
136
+ return ret("list", "comment");
137
137
  }
138
- if (ch == ":") { // tw list
138
+ if (ch == ":") { // definition list, description
139
139
  stream.eatWhile(':');
140
- return ret("list", "list");
140
+ return ret("list", "comment");
141
141
  }
142
142
  if (ch == ">") { // single line quote
143
143
  stream.eatWhile(">");
144
144
  return ret("quote", "quote");
145
145
  }
146
146
  if (ch == '|') {
147
- return ret('table', 'table');
147
+ return ret('table', 'header');
148
148
  }
149
149
  }
150
150
 
@@ -155,13 +155,16 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
155
155
  // rudimentary html:// file:// link matching. TW knows much more ...
156
156
  if (/[hf]/i.test(ch)) {
157
157
  if (/[ti]/i.test(stream.peek()) && stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i)) {
158
- return ret("link-external", "link-external");
158
+ return ret("link", "link");
159
159
  }
160
160
  }
161
161
  // just a little string indicator, don't want to have the whole string covered
162
162
  if (ch == '"') {
163
163
  return ret('string', 'string');
164
164
  }
165
+ if (ch == '~') { // _no_ CamelCase indicator should be bold
166
+ return ret('text', 'brace');
167
+ }
165
168
  if (/[\[\]]/.test(ch)) { // check for [[..]]
166
169
  if (stream.peek() == ch) {
167
170
  stream.next();
@@ -170,7 +173,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
170
173
  }
171
174
  if (ch == "@") { // check for space link. TODO fix @@...@@ highlighting
172
175
  stream.eatWhile(isSpaceName);
173
- return ret("link-external", "link-external");
176
+ return ret("link", "link");
174
177
  }
175
178
  if (/\d/.test(ch)) { // numbers
176
179
  stream.eatWhile(/\d/);
@@ -189,9 +192,15 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
189
192
  return chain(stream, state, twTokenUnderline);
190
193
  }
191
194
  }
192
- if (ch == "-") { // tw strikethrough TODO looks ugly .. different handling see below;
195
+ // strikethrough and mdash handling
196
+ if (ch == "-") {
193
197
  if (stream.eat("-")) {
194
- return chain(stream, state, twTokenStrike);
198
+ // if strikethrough looks ugly, change CSS.
199
+ if (stream.peek() != ' ')
200
+ return chain(stream, state, twTokenStrike);
201
+ // mdash
202
+ if (stream.peek() == ' ')
203
+ return ret('text', 'brace');
195
204
  }
196
205
  }
197
206
  if (ch == "'") { // tw bold
@@ -208,6 +217,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
208
217
  return ret(ch);
209
218
  }
210
219
 
220
+ // core macro handling
211
221
  stream.eatWhile(/[\w\$_]/);
212
222
  var word = stream.current(),
213
223
  known = textwords.propertyIsEnumerable(word) && textwords[word];
@@ -256,21 +266,21 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
256
266
  var ch, sb = state.block;
257
267
 
258
268
  if (sb && stream.current()) {
259
- return ret("code", "code");
269
+ return ret("code", "comment");
260
270
  }
261
271
 
262
272
  if (!sb && stream.match(reUntilCodeStop)) {
263
273
  state.tokenize = jsTokenBase;
264
- return ret("code", "code-inline");
274
+ return ret("code", "comment");
265
275
  }
266
276
 
267
277
  if (sb && stream.sol() && stream.match(reCodeBlockStop)) {
268
278
  state.tokenize = jsTokenBase;
269
- return ret("code", "code");
279
+ return ret("code", "comment");
270
280
  }
271
281
 
272
282
  ch = stream.next();
273
- return (sb) ? ret("code", "code") : ret("code", "code-inline");
283
+ return (sb) ? ret("code", "comment") : ret("code", "comment");
274
284
  }
275
285
 
276
286
  // tw em / italic
@@ -301,8 +311,8 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
301
311
  return ret("text", "underlined");
302
312
  }
303
313
 
304
- // tw strike through text looks ugly
305
- // TODO just strike through the first and last 2 chars if possible.
314
+ // tw strike through text looks ugly
315
+ // change CSS if needed
306
316
  function twTokenStrike(stream, state) {
307
317
  var maybeEnd = false,
308
318
  ch, nr;
@@ -314,7 +324,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
314
324
  }
315
325
  maybeEnd = (ch == "-");
316
326
  }
317
- return ret("text", "line-through");
327
+ return ret("text", "strikethrough");
318
328
  }
319
329
 
320
330
  // macro