swagr 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/Rakefile +20 -0
  2. data/bin/swagr +37 -9
  3. data/examples/examples01/app.rb +5 -1
  4. data/examples/examples01/views/edit.slim +31 -0
  5. data/examples/examples01/views/footer.slim +1 -1
  6. data/examples/examples01/views/layout.slim +23 -5
  7. data/examples/examples01/views/navbar.slim +17 -16
  8. data/lib/swagr/version.rb +3 -1
  9. data/templates/app.rb +5 -1
  10. data/templates/static/js/codemirror/keymap/vim.js +279 -66
  11. data/templates/static/js/codemirror/lib/codemirror.css +10 -9
  12. data/templates/static/js/codemirror/lib/codemirror.js +385 -152
  13. data/templates/static/js/codemirror/mode/apl/apl.js +160 -0
  14. data/templates/static/js/codemirror/mode/apl/index.html +61 -0
  15. data/templates/static/js/codemirror/mode/asterisk/asterisk.js +183 -0
  16. data/templates/static/js/codemirror/mode/asterisk/index.html +142 -0
  17. data/templates/static/js/codemirror/mode/clike/clike.js +2 -0
  18. data/templates/static/js/codemirror/mode/clike/index.html +1 -1
  19. data/templates/static/js/codemirror/mode/clike/scala.html +1 -1
  20. data/templates/static/js/codemirror/mode/clojure/clojure.js +3 -3
  21. data/templates/static/js/codemirror/mode/css/css.js +2 -2
  22. data/templates/static/js/codemirror/mode/css/test.js +76 -471
  23. data/templates/static/js/codemirror/mode/d/d.js +205 -0
  24. data/templates/static/js/codemirror/mode/d/index.html +262 -0
  25. data/templates/static/js/codemirror/mode/erlang/index.html +1 -1
  26. data/templates/static/js/codemirror/mode/gfm/gfm.js +2 -1
  27. data/templates/static/js/codemirror/mode/gfm/index.html +1 -2
  28. data/templates/static/js/codemirror/mode/gfm/test.js +84 -225
  29. data/templates/static/js/codemirror/mode/go/index.html +1 -1
  30. data/templates/static/js/codemirror/mode/groovy/index.html +1 -1
  31. data/templates/static/js/codemirror/mode/haskell/index.html +1 -1
  32. data/templates/static/js/codemirror/mode/javascript/index.html +2 -2
  33. data/templates/static/js/codemirror/mode/javascript/javascript.js +13 -2
  34. data/templates/static/js/codemirror/mode/less/index.html +1 -1
  35. data/templates/static/js/codemirror/mode/lua/index.html +1 -1
  36. data/templates/static/js/codemirror/mode/markdown/index.html +1 -1
  37. data/templates/static/js/codemirror/mode/markdown/markdown.js +8 -7
  38. data/templates/static/js/codemirror/mode/markdown/test.js +579 -1266
  39. data/templates/static/js/codemirror/mode/meta.js +71 -0
  40. data/templates/static/js/codemirror/mode/mysql/index.html +2 -0
  41. data/templates/static/js/codemirror/mode/ocaml/index.html +1 -1
  42. data/templates/static/js/codemirror/mode/php/index.html +1 -1
  43. data/templates/static/js/codemirror/mode/plsql/index.html +2 -0
  44. data/templates/static/js/codemirror/mode/python/index.html +1 -1
  45. data/templates/static/js/codemirror/mode/ruby/index.html +1 -1
  46. data/templates/static/js/codemirror/mode/sass/index.html +54 -0
  47. data/templates/static/js/codemirror/mode/sass/sass.js +349 -0
  48. data/templates/static/js/codemirror/mode/shell/index.html +1 -1
  49. data/templates/static/js/codemirror/mode/sieve/LICENSE +0 -4
  50. data/templates/static/js/codemirror/mode/sieve/sieve.js +37 -10
  51. data/templates/static/js/codemirror/mode/smalltalk/index.html +1 -1
  52. data/templates/static/js/codemirror/mode/sparql/index.html +1 -1
  53. data/templates/static/js/codemirror/mode/sql/index.html +68 -0
  54. data/templates/static/js/codemirror/mode/sql/sql.js +268 -0
  55. data/templates/static/js/codemirror/mode/stex/test.js +104 -343
  56. data/templates/static/js/codemirror/mode/tiddlywiki/index.html +1 -1
  57. data/templates/static/js/codemirror/mode/vb/index.html +1 -1
  58. data/templates/static/js/codemirror/mode/xquery/test.js +54 -67
  59. data/templates/static/js/codemirror/mode/xquery/xquery.js +8 -8
  60. data/templates/static/js/crossfilter.min.js +1 -0
  61. data/templates/views/edit.slim +31 -0
  62. data/templates/views/footer.slim +1 -1
  63. data/templates/views/layout.slim +23 -5
  64. data/templates/views/navbar.slim +17 -16
  65. metadata +16 -30
  66. data/examples/examples01/static/css/codemirror.css +0 -1247
  67. data/examples/examples01/static/js/codemirror-compressed-3-0.js +0 -5
  68. data/examples/examples01/views/about.slim +0 -15
  69. data/examples/examples01/views/application.slim +0 -0
  70. data/examples/examples01/views/layout_cm.slim +0 -17
  71. data/templates/static/js/codemirror/lib/util/closetag.js +0 -85
  72. data/templates/static/js/codemirror/lib/util/colorize.js +0 -29
  73. data/templates/static/js/codemirror/lib/util/continuecomment.js +0 -36
  74. data/templates/static/js/codemirror/lib/util/continuelist.js +0 -28
  75. data/templates/static/js/codemirror/lib/util/dialog.css +0 -32
  76. data/templates/static/js/codemirror/lib/util/dialog.js +0 -75
  77. data/templates/static/js/codemirror/lib/util/foldcode.js +0 -182
  78. data/templates/static/js/codemirror/lib/util/formatting.js +0 -108
  79. data/templates/static/js/codemirror/lib/util/javascript-hint.js +0 -137
  80. data/templates/static/js/codemirror/lib/util/loadmode.js +0 -51
  81. data/templates/static/js/codemirror/lib/util/match-highlighter.js +0 -46
  82. data/templates/static/js/codemirror/lib/util/matchbrackets.js +0 -63
  83. data/templates/static/js/codemirror/lib/util/multiplex.js +0 -95
  84. data/templates/static/js/codemirror/lib/util/overlay.js +0 -59
  85. data/templates/static/js/codemirror/lib/util/pig-hint.js +0 -117
  86. data/templates/static/js/codemirror/lib/util/runmode-standalone.js +0 -90
  87. data/templates/static/js/codemirror/lib/util/runmode.js +0 -52
  88. data/templates/static/js/codemirror/lib/util/search.js +0 -119
  89. data/templates/static/js/codemirror/lib/util/searchcursor.js +0 -119
  90. data/templates/static/js/codemirror/lib/util/simple-hint.css +0 -16
  91. data/templates/static/js/codemirror/lib/util/simple-hint.js +0 -102
  92. data/templates/static/js/codemirror/lib/util/xml-hint.js +0 -131
  93. data/templates/views/about.slim +0 -15
@@ -0,0 +1,71 @@
1
+ CodeMirror.modeInfo = [
2
+ {name: 'APL', mime: 'text/apl', mode: 'apl'},
3
+ {name: 'Asterisk', mime: 'text/x-asterisk', mode: 'asterisk'},
4
+ {name: 'C', mime: 'text/x-csrc', mode: 'clike'},
5
+ {name: 'C++', mime: 'text/x-c++src', mode: 'clike'},
6
+ {name: 'Java', mime: 'text/x-java', mode: 'clike'},
7
+ {name: 'C#', mime: 'text/x-csharp', mode: 'clike'},
8
+ {name: 'Scala', mime: 'text/x-scala', mode: 'clike'},
9
+ {name: 'Clojure', mime: 'text/x-clojure', mode: 'clojure'},
10
+ {name: 'CoffeeScript', mime: 'text/x-coffeescript', mode: 'coffeescript'},
11
+ {name: 'Common Lisp', mime: 'text/x-common-lisp', mode: 'commonlisp'},
12
+ {name: 'CSS', mime: 'text/css', mode: 'css'},
13
+ {name: 'D', mime: 'text/x-d', mode: 'd'},
14
+ {name: 'diff', mime: 'text/x-diff', mode: 'diff'},
15
+ {name: 'ECL', mime: 'text/x-ecl', mode: 'ecl'},
16
+ {name: 'Erlang', mime: 'text/x-erlang', mode: 'erlang'},
17
+ {name: 'GitHub Flavored Markdown', mode: 'gfm'},
18
+ {name: 'GO', mime: 'text/x-go', mode: 'go'},
19
+ {name: 'Groovy', mime: 'text/x-groovy', mode: 'groovy'},
20
+ {name: 'Haskell', mime: 'text/x-haskell', mode: 'haskell'},
21
+ {name: 'Haxe', mime: 'text/x-haxe', mode: 'haxe'},
22
+ {name: 'ASP.NET', mime: 'application/x-aspx', mode: 'htmlembedded'},
23
+ {name: 'Embedded Javascript', mime: 'application/x-ejs', mode: 'htmlembedded'},
24
+ {name: 'JavaServer Pages', mime: 'application/x-jsp', mode: 'htmlembedded'},
25
+ {name: 'HTML', mime: 'text/html', mode: 'htmlmixed'},
26
+ {name: 'HTTP', mime: 'message/http', mode: 'http'},
27
+ {name: 'JavaScript', mime: 'text/javascript', mode: 'javascript'},
28
+ {name: 'JSON', mime: 'application/json', mode: 'javascript'},
29
+ {name: 'TypeScript', mime: 'application/typescript', mode: 'javascript'},
30
+ {name: 'Jinja2', mime: 'jinja2', mode: 'jinja2'},
31
+ {name: 'LESS', mime: 'text/x-less', mode: 'less'},
32
+ {name: 'Lua', mime: 'text/x-lua', mode: 'lua'},
33
+ {name: 'Markdown (GitHub-flavour)', mime: 'text/x-markdown', mode: 'markdown'},
34
+ {name: 'NTriples', mime: 'text/n-triples', mode: 'ntriples'},
35
+ {name: 'OCaml', mime: 'text/x-ocaml', mode: 'ocaml'},
36
+ {name: 'Pascal', mime: 'text/x-pascal', mode: 'pascal'},
37
+ {name: 'Perl', mime: 'text/x-perl', mode: 'perl'},
38
+ {name: 'PHP', mime: 'text/x-php', mode: 'php'},
39
+ {name: 'PHP(HTML)', mime: 'application/x-httpd-php', mode: 'php'},
40
+ {name: 'Pig', mime: 'text/x-pig', mode: 'pig'},
41
+ {name: 'Properties files', mime: 'text/x-properties', mode: 'clike'},
42
+ {name: 'Python', mime: 'text/x-python', mode: 'python'},
43
+ {name: 'R', mime: 'text/x-rsrc', mode: 'r'},
44
+ {name: 'reStructuredText', mime: 'text/x-rst', mode: 'rst'},
45
+ {name: 'Ruby', mime: 'text/x-ruby', mode: 'ruby'},
46
+ {name: 'Rust', mime: 'text/x-rustsrc', mode: 'rust'},
47
+ {name: 'Sass', mime: 'text/x-sass', mode: 'sass'},
48
+ {name: 'Scheme', mime: 'text/x-scheme', mode: 'scheme'},
49
+ {name: 'Shell', mime: 'text/x-sh', mode: 'shell'},
50
+ {name: 'Sieve', mime: 'application/sieve', mode: 'sieve'},
51
+ {name: 'Smalltalk', mime: 'text/x-stsrc', mode: 'smalltalk'},
52
+ {name: 'Smarty', mime: 'text/x-smarty', mode: 'smarty'},
53
+ {name: 'SPARQL', mime: 'application/x-sparql-query', mode: 'sparql'},
54
+ {name: 'SQL', mime: 'text/x-sql', mode: 'sql'},
55
+ {name: 'MySQL', mime: 'text/x-mysql', mode: 'sql'},
56
+ {name: 'MariaDB', mime: 'text/x-mariadb', mode: 'sql'},
57
+ {name: 'PL/SQL', mime: 'text/x-plsql', mode: 'sql'},
58
+ {name: 'sTeX', mime: 'text/x-stex', mode: 'stex'},
59
+ {name: 'LaTeX', mime: 'text/x-latex', mode: 'stex'},
60
+ {name: 'TiddlyWiki ', mime: 'text/x-tiddlywiki', mode: 'tiddlwiki'},
61
+ {name: 'Tiki wiki', mime: 'text/tiki', mode: 'tiki'},
62
+ {name: 'VB.NET', mime: 'text/x-vb', mode: 'vb'},
63
+ {name: 'VBScript', mime: 'text/vbscript', mode: 'vbscript'},
64
+ {name: 'Velocity', mime: 'text/velocity', mode: 'velocity'},
65
+ {name: 'Verilog', mime: 'text/x-verilog', mode: 'verilog'},
66
+ {name: 'XML', mime: 'application/xml', mode: 'xml'},
67
+ {name: 'HTML', mime: 'text/html', mode: 'xml'},
68
+ {name: 'XQuery', mime: 'application/xquery', mode: 'xquery'},
69
+ {name: 'YAML', mime: 'text/x-yaml', mode: 'yaml'},
70
+ {name: 'Z80', mime: 'text/x-z80', mode: 'z80'}
71
+ ];
@@ -35,6 +35,8 @@ LIMIT 0,30;
35
35
  });
36
36
  </script>
37
37
 
38
+ <p><strong><span style="color: red">!!</span> This mode is deprecated in favor of the <a href="../sql/index.html">generic SQL mode</a> (which can be configured to handle MySQL).</strong></p>
39
+
38
40
  <p><strong>MIME types defined:</strong> <code>text/x-mysql</code>.</p>
39
41
 
40
42
  </body>
@@ -10,7 +10,7 @@
10
10
  </style>
11
11
 
12
12
  <script src=../../lib/codemirror.js></script>
13
- <script src=../../lib/util/matchbrackets.js></script>
13
+ <script src=../../addon/edit/matchbrackets.js></script>
14
14
  <script src=ocaml.js></script>
15
15
 
16
16
  <h1>CodeMirror: OCaml mode</h1>
@@ -5,7 +5,7 @@
5
5
  <title>CodeMirror: PHP mode</title>
6
6
  <link rel="stylesheet" href="../../lib/codemirror.css">
7
7
  <script src="../../lib/codemirror.js"></script>
8
- <script src="../../lib/util/matchbrackets.js"></script>
8
+ <script src="../../addon/edit/matchbrackets.js"></script>
9
9
  <script src="../htmlmixed/htmlmixed.js"></script>
10
10
  <script src="../xml/xml.js"></script>
11
11
  <script src="../javascript/javascript.js"></script>
@@ -53,6 +53,8 @@ END;
53
53
  });
54
54
  </script>
55
55
 
56
+ <p><strong><span style="color: red">!!</span> This mode is deprecated in favor of the <a href="../sql/index.html">generic SQL mode</a> (which can be configured to handle PL/SQL).</strong></p>
57
+
56
58
  <p>
57
59
  Simple mode that handles Oracle PL/SQL language (and Oracle SQL, of course).
58
60
  </p>
@@ -5,7 +5,7 @@
5
5
  <title>CodeMirror: Python mode</title>
6
6
  <link rel="stylesheet" href="../../lib/codemirror.css">
7
7
  <script src="../../lib/codemirror.js"></script>
8
- <script src="../../lib/util/matchbrackets.js"></script>
8
+ <script src="../../addon/edit/matchbrackets.js"></script>
9
9
  <script src="python.js"></script>
10
10
  <link rel="stylesheet" href="../../doc/docs.css">
11
11
  <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
@@ -5,7 +5,7 @@
5
5
  <title>CodeMirror: Ruby mode</title>
6
6
  <link rel="stylesheet" href="../../lib/codemirror.css">
7
7
  <script src="../../lib/codemirror.js"></script>
8
- <script src="../../lib/util/matchbrackets.js"></script>
8
+ <script src="../../addon/edit/matchbrackets.js"></script>
9
9
  <script src="ruby.js"></script>
10
10
  <style>
11
11
  .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
@@ -0,0 +1,54 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>CodeMirror: Sass mode</title>
6
+ <link rel="stylesheet" href="../../lib/codemirror.css">
7
+ <script src="../../lib/codemirror.js"></script>
8
+ <script src="../../addon/edit/matchbrackets.js"></script>
9
+ <script src="sass.js"></script>
10
+ <style>.CodeMirror {border: 1px solid #ddd; font-size:12px; height: 400px}</style>
11
+ <link rel="stylesheet" href="../../doc/docs.css">
12
+ </head>
13
+ <body>
14
+ <h1>CodeMirror: Sass mode</h1>
15
+ <form><textarea id="code" name="code">// Variable Definitions
16
+
17
+ $page-width: 800px
18
+ $sidebar-width: 200px
19
+ $primary-color: #eeeeee
20
+
21
+ // Global Attributes
22
+
23
+ body
24
+ font:
25
+ family: sans-serif
26
+ size: 30em
27
+ weight: bold
28
+
29
+ // Scoped Styles
30
+
31
+ #contents
32
+ width: $page-width
33
+ #sidebar
34
+ float: right
35
+ width: $sidebar-width
36
+ #main
37
+ width: $page-width - $sidebar-width
38
+ background: $primary-color
39
+ h2
40
+ color: blue
41
+
42
+ #footer
43
+ height: 200px
44
+ </textarea></form>
45
+ <script>
46
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
47
+ lineNumbers : true,
48
+ matchBrackets : true
49
+ });
50
+ </script>
51
+
52
+ <p><strong>MIME types defined:</strong> <code>text/x-sass</code>.</p>
53
+ </body>
54
+ </html>
@@ -0,0 +1,349 @@
1
+ CodeMirror.defineMode("sass", function(config) {
2
+ var tokenRegexp = function(words){
3
+ return new RegExp("^" + words.join("|"));
4
+ };
5
+
6
+ var tags = ["&", "a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","command","datalist","dd","del","details","dfn","dir","div","dl","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","keygen","kbd","label","legend","li","link","map","mark","menu","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strike","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr"];
7
+ var keywords = ["true", "false", "null", "auto"];
8
+ var keywordsRegexp = new RegExp("^" + keywords.join("|"));
9
+
10
+ var operators = ["\\(", "\\)", "=", ">", "<", "==", ">=", "<=", "\\+", "-", "\\!=", "/", "\\*", "%", "and", "or", "not"];
11
+ var opRegexp = tokenRegexp(operators);
12
+
13
+ function htmlTag(val){
14
+ for(var i=0; i<tags.length; i++){
15
+ if(val === tags[i]){
16
+ return true;
17
+ }
18
+ }
19
+ }
20
+
21
+
22
+ var pseudoElements = [':first-line', ':hover', ':first-letter', ':active', ':visited', ':before', ':after', ':link', ':focus', ':first-child', ':lang'];
23
+ var pseudoElementsRegexp = new RegExp("^(" + pseudoElements.join("\\b|") + ")");
24
+
25
+ var urlTokens = function(stream, state){
26
+ var ch = stream.peek();
27
+
28
+ if (ch === ")"){
29
+ stream.next();
30
+ state.tokenizer = tokenBase;
31
+ return "operator";
32
+ }else if (ch === "("){
33
+ stream.next();
34
+ stream.eatSpace();
35
+
36
+ return "operator";
37
+ }else if (ch === "'" || ch === '"'){
38
+ state.tokenizer = buildStringTokenizer(stream.next());
39
+ return "string";
40
+ }else{
41
+ state.tokenizer = buildStringTokenizer(")", false);
42
+ return "string";
43
+ }
44
+ };
45
+ var multilineComment = function(stream, state) {
46
+ if (stream.skipTo("*/")){
47
+ stream.next();
48
+ stream.next();
49
+ state.tokenizer = tokenBase;
50
+ }else {
51
+ stream.next();
52
+ }
53
+
54
+ return "comment";
55
+ };
56
+
57
+ var buildStringTokenizer = function(quote, greedy){
58
+ if(greedy == null){ greedy = true; }
59
+
60
+ function stringTokenizer(stream, state){
61
+ var nextChar = stream.next();
62
+ var peekChar = stream.peek();
63
+ var previousChar = stream.string.charAt(stream.pos-2);
64
+
65
+ var endingString = ((nextChar !== "\\" && peekChar === quote) || (nextChar === quote && previousChar !== "\\"));
66
+
67
+ /*
68
+ console.log("previousChar: " + previousChar);
69
+ console.log("nextChar: " + nextChar);
70
+ console.log("peekChar: " + peekChar);
71
+ console.log("ending: " + endingString);
72
+ */
73
+
74
+ if (endingString){
75
+ if (nextChar !== quote && greedy) { stream.next(); }
76
+ state.tokenizer = tokenBase;
77
+ return "string";
78
+ }else if (nextChar === "#" && peekChar === "{"){
79
+ state.tokenizer = buildInterpolationTokenizer(stringTokenizer);
80
+ stream.next();
81
+ return "operator";
82
+ }else {
83
+ return "string";
84
+ }
85
+ }
86
+
87
+ return stringTokenizer;
88
+ };
89
+
90
+ var buildInterpolationTokenizer = function(currentTokenizer){
91
+ return function(stream, state){
92
+ if (stream.peek() === "}"){
93
+ stream.next();
94
+ state.tokenizer = currentTokenizer;
95
+ return "operator";
96
+ }else{
97
+ return tokenBase(stream, state);
98
+ }
99
+ };
100
+ };
101
+
102
+ var indent = function(state){
103
+ if (state.indentCount == 0){
104
+ state.indentCount++;
105
+ var lastScopeOffset = state.scopes[0].offset;
106
+ var currentOffset = lastScopeOffset + config.indentUnit;
107
+ state.scopes.unshift({ offset:currentOffset });
108
+ }
109
+ };
110
+
111
+ var dedent = function(state){
112
+ if (state.scopes.length == 1) { return; }
113
+
114
+ state.scopes.shift();
115
+ };
116
+
117
+ var tokenBase = function(stream, state) {
118
+ var ch = stream.peek();
119
+
120
+ // Single line Comment
121
+ if (stream.match('//')) {
122
+ stream.skipToEnd();
123
+ return "comment";
124
+ }
125
+
126
+ // Multiline Comment
127
+ if (stream.match('/*')){
128
+ state.tokenizer = multilineComment;
129
+ return state.tokenizer(stream, state);
130
+ }
131
+
132
+ // Interpolation
133
+ if (stream.match('#{')){
134
+ state.tokenizer = buildInterpolationTokenizer(tokenBase);
135
+ return "operator";
136
+ }
137
+
138
+ if (ch === "."){
139
+ stream.next();
140
+
141
+ // Match class selectors
142
+ if (stream.match(/^[\w-]+/)){
143
+ indent(state);
144
+ return "atom";
145
+ }else if (stream.peek() === "#"){
146
+ indent(state);
147
+ return "atom";
148
+ }else{
149
+ return "operator";
150
+ }
151
+ }
152
+
153
+ if (ch === "#"){
154
+ stream.next();
155
+
156
+ // Hex numbers
157
+ if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){
158
+ return "number";
159
+ }
160
+
161
+ // ID selectors
162
+ if (stream.match(/^[\w-]+/)){
163
+ indent(state);
164
+ return "atom";
165
+ }
166
+
167
+ if (stream.peek() === "#"){
168
+ indent(state);
169
+ return "atom";
170
+ }
171
+ }
172
+
173
+ // Numbers
174
+ if (stream.match(/^-?[0-9\.]+/)){
175
+ return "number";
176
+ }
177
+
178
+ // Units
179
+ if (stream.match(/^(px|em|in)\b/)){
180
+ return "unit";
181
+ }
182
+
183
+ if (stream.match(keywordsRegexp)){
184
+ return "keyword";
185
+ }
186
+
187
+ if (stream.match(/^url/) && stream.peek() === "("){
188
+ state.tokenizer = urlTokens;
189
+ return "atom";
190
+ }
191
+
192
+ // Variables
193
+ if (ch === "$"){
194
+ stream.next();
195
+ stream.eatWhile(/[\w-]/);
196
+
197
+ if (stream.peek() === ":"){
198
+ stream.next();
199
+ return "variable-2";
200
+ }else{
201
+ return "variable-3";
202
+ }
203
+ }
204
+
205
+ if (ch === "!"){
206
+ stream.next();
207
+
208
+ if (stream.match(/^[\w]+/)){
209
+ return "keyword";
210
+ }
211
+
212
+ return "operator";
213
+ }
214
+
215
+ if (ch === "="){
216
+ stream.next();
217
+
218
+ // Match shortcut mixin definition
219
+ if (stream.match(/^[\w-]+/)){
220
+ indent(state);
221
+ return "meta";
222
+ }else {
223
+ return "operator";
224
+ }
225
+ }
226
+
227
+ if (ch === "+"){
228
+ stream.next();
229
+
230
+ // Match shortcut mixin definition
231
+ if (stream.match(/^[\w-]+/)){
232
+ return "variable-3";
233
+ }else {
234
+ return "operator";
235
+ }
236
+ }
237
+
238
+ // Indent Directives
239
+ if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)){
240
+ indent(state);
241
+ return "meta";
242
+ }
243
+
244
+ // Other Directives
245
+ if (ch === "@"){
246
+ stream.next();
247
+ stream.eatWhile(/[\w-]/);
248
+ return "meta";
249
+ }
250
+
251
+ // Strings
252
+ if (ch === '"' || ch === "'"){
253
+ stream.next();
254
+ state.tokenizer = buildStringTokenizer(ch);
255
+ return "string";
256
+ }
257
+
258
+ // Pseudo element selectors
259
+ if (stream.match(pseudoElementsRegexp)){
260
+ return "keyword";
261
+ }
262
+
263
+ // atoms
264
+ if (stream.eatWhile(/[\w-&]/)){
265
+
266
+ var current = stream.current();
267
+ // matches a property definition
268
+ if (stream.peek() === ":"){
269
+ // if this is an html tag and it has a pseudo selector, then it's an atom
270
+ if (htmlTag(current) && stream.match(pseudoElementsRegexp, false)){
271
+ return "atom";
272
+ }else{
273
+ stream.next();
274
+ return "property";
275
+ }
276
+ }
277
+ return "atom";
278
+ }
279
+
280
+ if (stream.match(opRegexp)){
281
+ return "operator";
282
+ }
283
+
284
+ // If we haven't returned by now, we move 1 character
285
+ // and return an error
286
+ stream.next();
287
+ return 'error';
288
+ };
289
+
290
+ var tokenLexer = function(stream, state) {
291
+ if (stream.sol()){
292
+ state.indentCount = 0;
293
+ }
294
+ var style = state.tokenizer(stream, state);
295
+ var current = stream.current();
296
+
297
+ if (current === "@return"){
298
+ dedent(state);
299
+ }
300
+
301
+ if (style === "atom" && htmlTag(current)){
302
+ indent(state);
303
+ }
304
+
305
+ if (style !== "error"){
306
+ var startOfToken = stream.pos - current.length;
307
+ var withCurrentIndent = startOfToken + (config.indentUnit * state.indentCount);
308
+
309
+ var newScopes = [];
310
+
311
+ for (var i = 0; i < state.scopes.length; i++){
312
+ var scope = state.scopes[i];
313
+
314
+ if (scope.offset <= withCurrentIndent){
315
+ newScopes.push(scope);
316
+ }
317
+ }
318
+
319
+ state.scopes = newScopes;
320
+ }
321
+
322
+
323
+ return style;
324
+ };
325
+
326
+ return {
327
+ startState: function() {
328
+ return {
329
+ tokenizer: tokenBase,
330
+ scopes: [{offset: 0, type: 'sass'}],
331
+ definedVars: [],
332
+ definedMixins: [],
333
+ };
334
+ },
335
+ token: function(stream, state) {
336
+ var style = tokenLexer(stream, state);
337
+
338
+ state.lastToken = { style: style, content: stream.current() };
339
+
340
+ return style;
341
+ },
342
+
343
+ indent: function(state) {
344
+ return state.scopes[0].offset;
345
+ }
346
+ };
347
+ });
348
+
349
+ CodeMirror.defineMIME("text/x-sass", "sass");