AmberRack 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +74 -0
- data/.rvmrc +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +62 -0
- data/README.md +17 -0
- data/Rakefile +24 -0
- data/amber-rack.gemspec +33 -0
- data/app/amber_app.rb +35 -0
- data/app/javascripts/Benchfib.deploy.js +159 -0
- data/app/javascripts/Benchfib.js +159 -0
- data/app/javascripts/Canvas.deploy.js +1464 -0
- data/app/javascripts/Canvas.js +1464 -0
- data/app/javascripts/Compiler.deploy.js +1587 -0
- data/app/javascripts/Compiler.js +1587 -0
- data/app/javascripts/Examples.deploy.js +800 -0
- data/app/javascripts/Examples.js +800 -0
- data/app/javascripts/IDE.deploy.js +3457 -0
- data/app/javascripts/IDE.js +3457 -0
- data/app/javascripts/IDE.js.bak +3420 -0
- data/app/javascripts/JQuery.deploy.js +898 -0
- data/app/javascripts/JQuery.js +898 -0
- data/app/javascripts/Kernel.deploy.js +6761 -0
- data/app/javascripts/Kernel.js +6761 -0
- data/app/javascripts/Parser.deploy.js +1655 -0
- data/app/javascripts/Parser.js +1655 -0
- data/app/javascripts/Raphael-Core.js +0 -0
- data/app/javascripts/Raphael-Graph.js +0 -0
- data/app/javascripts/SUnit.deploy.js +1059 -0
- data/app/javascripts/SUnit.js +1059 -0
- data/app/javascripts/application.js +2 -0
- data/app/javascripts/boot.js +466 -0
- data/app/javascripts/init.js +2 -0
- data/app/javascripts/jquery-1.4.4.min.js +167 -0
- data/app/javascripts/jquery-ui-1.8.9.custom.min.js +781 -0
- data/app/javascripts/jquery.textarea.js +267 -0
- data/app/javascripts/jtalk.js +78 -0
- data/app/javascripts/lib/CodeMirror/LICENSE +19 -0
- data/app/javascripts/lib/CodeMirror/README.md +6 -0
- data/app/javascripts/lib/CodeMirror/compress.html +92 -0
- data/app/javascripts/lib/CodeMirror/css/baboon.png +0 -0
- data/app/javascripts/lib/CodeMirror/css/baboon_vector.svg +153 -0
- data/app/javascripts/lib/CodeMirror/css/docs.css +154 -0
- data/app/javascripts/lib/CodeMirror/demo/activeline.html +72 -0
- data/app/javascripts/lib/CodeMirror/demo/changemode.html +51 -0
- data/app/javascripts/lib/CodeMirror/demo/complete.html +79 -0
- data/app/javascripts/lib/CodeMirror/demo/complete.js +151 -0
- data/app/javascripts/lib/CodeMirror/demo/fullscreen.html +158 -0
- data/app/javascripts/lib/CodeMirror/demo/marker.html +53 -0
- data/app/javascripts/lib/CodeMirror/demo/mustache.html +57 -0
- data/app/javascripts/lib/CodeMirror/demo/preview.html +75 -0
- data/app/javascripts/lib/CodeMirror/demo/resize.html +44 -0
- data/app/javascripts/lib/CodeMirror/demo/runmode.html +50 -0
- data/app/javascripts/lib/CodeMirror/demo/search.html +106 -0
- data/app/javascripts/lib/CodeMirror/demo/theme.html +53 -0
- data/app/javascripts/lib/CodeMirror/index.html +239 -0
- data/app/javascripts/lib/CodeMirror/internals.html +389 -0
- data/app/javascripts/lib/CodeMirror/lib/codemirror.css +67 -0
- data/app/javascripts/lib/CodeMirror/lib/codemirror.js +2144 -0
- data/app/javascripts/lib/CodeMirror/lib/overlay.js +51 -0
- data/app/javascripts/lib/CodeMirror/lib/runmode.js +27 -0
- data/app/javascripts/lib/CodeMirror/manual.html +854 -0
- data/app/javascripts/lib/CodeMirror/mode/clike/clike.js +247 -0
- data/app/javascripts/lib/CodeMirror/mode/clike/index.html +102 -0
- data/app/javascripts/lib/CodeMirror/mode/css/css.js +124 -0
- data/app/javascripts/lib/CodeMirror/mode/css/index.html +56 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/diff.css +3 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/diff.js +13 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/index.html +99 -0
- data/app/javascripts/lib/CodeMirror/mode/haskell/haskell.js +242 -0
- data/app/javascripts/lib/CodeMirror/mode/haskell/index.html +60 -0
- data/app/javascripts/lib/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/app/javascripts/lib/CodeMirror/mode/htmlmixed/index.html +52 -0
- data/app/javascripts/lib/CodeMirror/mode/javascript/index.html +78 -0
- data/app/javascripts/lib/CodeMirror/mode/javascript/javascript.js +348 -0
- data/app/javascripts/lib/CodeMirror/mode/lua/index.html +72 -0
- data/app/javascripts/lib/CodeMirror/mode/lua/lua.js +138 -0
- data/app/javascripts/lib/CodeMirror/mode/php/index.html +49 -0
- data/app/javascripts/lib/CodeMirror/mode/php/php.js +110 -0
- data/app/javascripts/lib/CodeMirror/mode/plsql/index.html +63 -0
- data/app/javascripts/lib/CodeMirror/mode/plsql/plsql.js +217 -0
- data/app/javascripts/lib/CodeMirror/mode/python/LICENSE.txt +21 -0
- data/app/javascripts/lib/CodeMirror/mode/python/index.html +123 -0
- data/app/javascripts/lib/CodeMirror/mode/python/python.js +321 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/index.html +526 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/rst.css +75 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/rst.js +333 -0
- data/app/javascripts/lib/CodeMirror/mode/scheme/index.html +65 -0
- data/app/javascripts/lib/CodeMirror/mode/scheme/scheme.js +181 -0
- data/app/javascripts/lib/CodeMirror/mode/smalltalk/index.html +56 -0
- data/app/javascripts/lib/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
- data/app/javascripts/lib/CodeMirror/mode/sparql/index.html +41 -0
- data/app/javascripts/lib/CodeMirror/mode/sparql/sparql.js +143 -0
- data/app/javascripts/lib/CodeMirror/mode/stex/index.html +96 -0
- data/app/javascripts/lib/CodeMirror/mode/stex/stex.js +167 -0
- data/app/javascripts/lib/CodeMirror/mode/xml/index.html +42 -0
- data/app/javascripts/lib/CodeMirror/mode/xml/xml.js +231 -0
- data/app/javascripts/lib/CodeMirror/mode/yaml/index.html +68 -0
- data/app/javascripts/lib/CodeMirror/mode/yaml/yaml.js +95 -0
- data/app/javascripts/lib/CodeMirror/oldrelease.html +178 -0
- data/app/javascripts/lib/CodeMirror/test/index.html +29 -0
- data/app/javascripts/lib/CodeMirror/test/test.js +249 -0
- data/app/javascripts/lib/CodeMirror/theme/default.css +18 -0
- data/app/javascripts/lib/CodeMirror/theme/elegant.css +9 -0
- data/app/javascripts/lib/CodeMirror/theme/jtalk.css +21 -0
- data/app/javascripts/lib/CodeMirror/theme/neat.css +8 -0
- data/app/javascripts/lib/CodeMirror/theme/night.css +20 -0
- data/app/javascripts/lib/jQuery/jquery-1.4.4.min.js +167 -0
- data/app/javascripts/lib/jQuery/jquery-ui-1.8.9.custom.min.js +781 -0
- data/app/javascripts/lib/jQuery/jquery.textarea.js +267 -0
- data/app/smalltalk/Canvas.st +481 -0
- data/app/smalltalk/IDE.st +1752 -0
- data/config.ru +2 -0
- data/lib/amber-rack.rb +4 -0
- data/lib/amber-rack/version.rb +3 -0
- data/public/CodeMirror/LICENSE +19 -0
- data/public/CodeMirror/README.md +6 -0
- data/public/CodeMirror/compress.html +92 -0
- data/public/CodeMirror/css/baboon.png +0 -0
- data/public/CodeMirror/css/baboon_vector.svg +153 -0
- data/public/CodeMirror/css/docs.css +154 -0
- data/public/CodeMirror/demo/activeline.html +72 -0
- data/public/CodeMirror/demo/changemode.html +51 -0
- data/public/CodeMirror/demo/complete.html +79 -0
- data/public/CodeMirror/demo/complete.js +151 -0
- data/public/CodeMirror/demo/fullscreen.html +158 -0
- data/public/CodeMirror/demo/marker.html +53 -0
- data/public/CodeMirror/demo/mustache.html +57 -0
- data/public/CodeMirror/demo/preview.html +75 -0
- data/public/CodeMirror/demo/resize.html +44 -0
- data/public/CodeMirror/demo/runmode.html +50 -0
- data/public/CodeMirror/demo/search.html +106 -0
- data/public/CodeMirror/demo/theme.html +53 -0
- data/public/CodeMirror/index.html +239 -0
- data/public/CodeMirror/internals.html +389 -0
- data/public/CodeMirror/lib/codemirror.css +67 -0
- data/public/CodeMirror/lib/codemirror.js +2144 -0
- data/public/CodeMirror/lib/overlay.js +51 -0
- data/public/CodeMirror/lib/runmode.js +27 -0
- data/public/CodeMirror/manual.html +854 -0
- data/public/CodeMirror/mode/clike/clike.js +247 -0
- data/public/CodeMirror/mode/clike/index.html +102 -0
- data/public/CodeMirror/mode/css/css.js +124 -0
- data/public/CodeMirror/mode/css/index.html +56 -0
- data/public/CodeMirror/mode/diff/diff.css +3 -0
- data/public/CodeMirror/mode/diff/diff.js +13 -0
- data/public/CodeMirror/mode/diff/index.html +99 -0
- data/public/CodeMirror/mode/haskell/haskell.js +242 -0
- data/public/CodeMirror/mode/haskell/index.html +60 -0
- data/public/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/public/CodeMirror/mode/htmlmixed/index.html +52 -0
- data/public/CodeMirror/mode/javascript/index.html +78 -0
- data/public/CodeMirror/mode/javascript/javascript.js +348 -0
- data/public/CodeMirror/mode/lua/index.html +72 -0
- data/public/CodeMirror/mode/lua/lua.js +138 -0
- data/public/CodeMirror/mode/php/index.html +49 -0
- data/public/CodeMirror/mode/php/php.js +110 -0
- data/public/CodeMirror/mode/plsql/index.html +63 -0
- data/public/CodeMirror/mode/plsql/plsql.js +217 -0
- data/public/CodeMirror/mode/python/LICENSE.txt +21 -0
- data/public/CodeMirror/mode/python/index.html +123 -0
- data/public/CodeMirror/mode/python/python.js +321 -0
- data/public/CodeMirror/mode/rst/index.html +526 -0
- data/public/CodeMirror/mode/rst/rst.css +75 -0
- data/public/CodeMirror/mode/rst/rst.js +333 -0
- data/public/CodeMirror/mode/scheme/index.html +65 -0
- data/public/CodeMirror/mode/scheme/scheme.js +181 -0
- data/public/CodeMirror/mode/smalltalk/index.html +56 -0
- data/public/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
- data/public/CodeMirror/mode/sparql/index.html +41 -0
- data/public/CodeMirror/mode/sparql/sparql.js +143 -0
- data/public/CodeMirror/mode/stex/index.html +96 -0
- data/public/CodeMirror/mode/stex/stex.js +167 -0
- data/public/CodeMirror/mode/xml/index.html +42 -0
- data/public/CodeMirror/mode/xml/xml.js +231 -0
- data/public/CodeMirror/mode/yaml/index.html +68 -0
- data/public/CodeMirror/mode/yaml/yaml.js +95 -0
- data/public/CodeMirror/oldrelease.html +178 -0
- data/public/CodeMirror/test/index.html +29 -0
- data/public/CodeMirror/test/test.js +249 -0
- data/public/CodeMirror/theme/default.css +18 -0
- data/public/CodeMirror/theme/elegant.css +9 -0
- data/public/CodeMirror/theme/jtalk.css +21 -0
- data/public/CodeMirror/theme/neat.css +8 -0
- data/public/CodeMirror/theme/night.css +20 -0
- data/public/css/jtalk.css +362 -0
- data/public/css/style.css +456 -0
- data/public/css/sunit.css +66 -0
- data/public/ide/fork_me.png +0 -0
- data/public/ide/screen2.png +0 -0
- data/public/ide/style.css +456 -0
- data/public/ide/syntax.css +61 -0
- data/public/ide/text_header.png +0 -0
- data/public/ide/title_container1.png +0 -0
- data/public/images/background_box.png +0 -0
- data/public/images/background_header.png +0 -0
- data/public/images/balloon_header.png +0 -0
- data/views/index.haml +66 -0
- metadata +341 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
.cm-s-default span.cm-emphasis {
|
2
|
+
font-style: italic;
|
3
|
+
}
|
4
|
+
|
5
|
+
.cm-s-default span.cm-strong {
|
6
|
+
font-weight: bold;
|
7
|
+
}
|
8
|
+
|
9
|
+
.cm-s-default span.cm-interpreted {
|
10
|
+
color: #33cc66;
|
11
|
+
}
|
12
|
+
|
13
|
+
.cm-s-default span.cm-inline {
|
14
|
+
color: #3399cc;
|
15
|
+
}
|
16
|
+
|
17
|
+
.cm-s-default span.cm-role {
|
18
|
+
color: #666699;
|
19
|
+
}
|
20
|
+
|
21
|
+
.cm-s-default span.cm-list {
|
22
|
+
color: #cc0099;
|
23
|
+
font-weight: bold;
|
24
|
+
}
|
25
|
+
|
26
|
+
.cm-s-default span.cm-body {
|
27
|
+
color: #6699cc;
|
28
|
+
}
|
29
|
+
|
30
|
+
.cm-s-default span.cm-verbatim {
|
31
|
+
color: #3366ff;
|
32
|
+
}
|
33
|
+
|
34
|
+
.cm-s-default span.cm-comment {
|
35
|
+
color: #aa7700;
|
36
|
+
}
|
37
|
+
|
38
|
+
.cm-s-default span.cm-directive {
|
39
|
+
font-weight: bold;
|
40
|
+
color: #3399ff;
|
41
|
+
}
|
42
|
+
|
43
|
+
.cm-s-default span.cm-hyperlink {
|
44
|
+
font-weight: bold;
|
45
|
+
color: #3366ff;
|
46
|
+
}
|
47
|
+
|
48
|
+
.cm-s-default span.cm-footnote {
|
49
|
+
font-weight: bold;
|
50
|
+
color: #3333ff;
|
51
|
+
}
|
52
|
+
|
53
|
+
.cm-s-default span.cm-citation {
|
54
|
+
font-weight: bold;
|
55
|
+
color: #3300ff;
|
56
|
+
}
|
57
|
+
|
58
|
+
.cm-s-default span.cm-replacement {
|
59
|
+
color: #9933cc;
|
60
|
+
}
|
61
|
+
|
62
|
+
.cm-s-default span.cm-section {
|
63
|
+
font-weight: bold;
|
64
|
+
color: #cc0099;
|
65
|
+
}
|
66
|
+
|
67
|
+
.cm-s-default span.cm-directive-marker {
|
68
|
+
font-weight: bold;
|
69
|
+
color: #3399ff;
|
70
|
+
}
|
71
|
+
|
72
|
+
.cm-s-default span.cm-verbatim-marker {
|
73
|
+
font-weight: bold;
|
74
|
+
color: #9900ff;
|
75
|
+
}
|
@@ -0,0 +1,333 @@
|
|
1
|
+
CodeMirror.defineMode('rst', function(config, options) {
|
2
|
+
function setState(state, fn, ctx) {
|
3
|
+
state.fn = fn;
|
4
|
+
setCtx(state, ctx);
|
5
|
+
}
|
6
|
+
|
7
|
+
function setCtx(state, ctx) {
|
8
|
+
state.ctx = ctx || {};
|
9
|
+
}
|
10
|
+
|
11
|
+
function setNormal(state, ch) {
|
12
|
+
if (ch && (typeof ch !== 'string')) {
|
13
|
+
var str = ch.current();
|
14
|
+
ch = str[str.length-1];
|
15
|
+
}
|
16
|
+
|
17
|
+
setState(state, normal, {back: ch});
|
18
|
+
}
|
19
|
+
|
20
|
+
function hasMode(mode) {
|
21
|
+
if (mode) {
|
22
|
+
var modes = CodeMirror.listModes();
|
23
|
+
|
24
|
+
for (var i in modes) {
|
25
|
+
if (modes[i] == mode) {
|
26
|
+
return true;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
return false;
|
32
|
+
}
|
33
|
+
|
34
|
+
function getMode(mode) {
|
35
|
+
if (hasMode(mode)) {
|
36
|
+
return CodeMirror.getMode(config, mode);
|
37
|
+
} else {
|
38
|
+
return null;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
var verbatimMode = getMode(options.verbatim);
|
43
|
+
var pythonMode = getMode('python');
|
44
|
+
|
45
|
+
var reSection = /^[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/;
|
46
|
+
var reDirective = /^\s*\w([-:.\w]*\w)?::(\s|$)/;
|
47
|
+
var reHyperlink = /^\s*_[\w-]+:(\s|$)/;
|
48
|
+
var reFootnote = /^\s*\[(\d+|#)\](\s|$)/;
|
49
|
+
var reCitation = /^\s*\[[A-Za-z][\w-]*\](\s|$)/;
|
50
|
+
var reFootnoteRef = /^\[(\d+|#)\]_/;
|
51
|
+
var reCitationRef = /^\[[A-Za-z][\w-]*\]_/;
|
52
|
+
var reDirectiveMarker = /^\.\.(\s|$)/;
|
53
|
+
var reVerbatimMarker = /^::\s*$/;
|
54
|
+
var rePreInline = /^[-\s"([{</:]/;
|
55
|
+
var rePostInline = /^[-\s`'")\]}>/:.,;!?\\_]/;
|
56
|
+
var reEnumeratedList = /^\s*((\d+|[A-Za-z#])[.)]|\((\d+|[A-Z-a-z#])\))\s/;
|
57
|
+
var reBulletedList = /^\s*[-\+\*]\s/;
|
58
|
+
var reExamples = /^\s+(>>>|In \[\d+\]:)\s/;
|
59
|
+
|
60
|
+
function normal(stream, state) {
|
61
|
+
var ch, sol, i;
|
62
|
+
|
63
|
+
if (stream.eat(/\\/)) {
|
64
|
+
ch = stream.next();
|
65
|
+
setNormal(state, ch);
|
66
|
+
return null;
|
67
|
+
}
|
68
|
+
|
69
|
+
sol = stream.sol();
|
70
|
+
|
71
|
+
if (sol && (ch = stream.eat(reSection))) {
|
72
|
+
for (i = 0; stream.eat(ch); i++);
|
73
|
+
|
74
|
+
if (i >= 3 && stream.match(/^\s*$/)) {
|
75
|
+
setNormal(state, null);
|
76
|
+
return 'section';
|
77
|
+
} else {
|
78
|
+
stream.backUp(i + 1);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
if (sol && stream.match(reDirectiveMarker)) {
|
83
|
+
if (!stream.eol()) {
|
84
|
+
setState(state, directive);
|
85
|
+
}
|
86
|
+
|
87
|
+
return 'directive-marker';
|
88
|
+
}
|
89
|
+
|
90
|
+
if (stream.match(reVerbatimMarker)) {
|
91
|
+
if (!verbatimMode) {
|
92
|
+
setState(state, verbatim);
|
93
|
+
} else {
|
94
|
+
var mode = verbatimMode;
|
95
|
+
|
96
|
+
setState(state, verbatim, {
|
97
|
+
mode: mode,
|
98
|
+
local: mode.startState()
|
99
|
+
});
|
100
|
+
}
|
101
|
+
|
102
|
+
return 'verbatim-marker';
|
103
|
+
}
|
104
|
+
|
105
|
+
if (sol && stream.match(reExamples, false)) {
|
106
|
+
if (!pythonMode) {
|
107
|
+
setState(state, verbatim);
|
108
|
+
return 'verbatim-marker';
|
109
|
+
} else {
|
110
|
+
var mode = pythonMode;
|
111
|
+
|
112
|
+
setState(state, verbatim, {
|
113
|
+
mode: mode,
|
114
|
+
local: mode.startState()
|
115
|
+
});
|
116
|
+
|
117
|
+
return null;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
if (sol && (stream.match(reEnumeratedList) ||
|
122
|
+
stream.match(reBulletedList))) {
|
123
|
+
setNormal(state, stream);
|
124
|
+
return 'list';
|
125
|
+
}
|
126
|
+
|
127
|
+
function testBackward(re) {
|
128
|
+
return sol || !state.ctx.back || re.test(state.ctx.back);
|
129
|
+
}
|
130
|
+
|
131
|
+
function testForward(re) {
|
132
|
+
return stream.eol() || stream.match(re, false);
|
133
|
+
}
|
134
|
+
|
135
|
+
function testInline(re) {
|
136
|
+
return stream.match(re) && testBackward(/\W/) && testForward(/\W/);
|
137
|
+
}
|
138
|
+
|
139
|
+
if (testInline(reFootnoteRef)) {
|
140
|
+
setNormal(state, stream);
|
141
|
+
return 'footnote';
|
142
|
+
}
|
143
|
+
|
144
|
+
if (testInline(reCitationRef)) {
|
145
|
+
setNormal(state, stream);
|
146
|
+
return 'citation';
|
147
|
+
}
|
148
|
+
|
149
|
+
ch = stream.next();
|
150
|
+
|
151
|
+
if (testBackward(rePreInline)) {
|
152
|
+
if ((ch === ':' || ch === '|') && stream.eat(/\S/)) {
|
153
|
+
var token;
|
154
|
+
|
155
|
+
if (ch === ':') {
|
156
|
+
token = 'role';
|
157
|
+
} else {
|
158
|
+
token = 'replacement';
|
159
|
+
}
|
160
|
+
|
161
|
+
setState(state, inline, {
|
162
|
+
ch: ch,
|
163
|
+
wide: false,
|
164
|
+
prev: null,
|
165
|
+
token: token
|
166
|
+
});
|
167
|
+
|
168
|
+
return token;
|
169
|
+
}
|
170
|
+
|
171
|
+
if (ch === '*' || ch === '`') {
|
172
|
+
var orig = ch,
|
173
|
+
wide = false;
|
174
|
+
|
175
|
+
ch = stream.next();
|
176
|
+
|
177
|
+
if (ch == orig) {
|
178
|
+
wide = true;
|
179
|
+
ch = stream.next();
|
180
|
+
}
|
181
|
+
|
182
|
+
if (ch && !/\s/.test(ch)) {
|
183
|
+
var token;
|
184
|
+
|
185
|
+
if (orig === '*') {
|
186
|
+
token = wide ? 'strong' : 'emphasis';
|
187
|
+
} else {
|
188
|
+
token = wide ? 'inline' : 'interpreted';
|
189
|
+
}
|
190
|
+
|
191
|
+
setState(state, inline, {
|
192
|
+
ch: orig, // inline() has to know what to search for
|
193
|
+
wide: wide, // are we looking for `ch` or `chch`
|
194
|
+
prev: null, // terminator must not be preceeded with whitespace
|
195
|
+
token: token // I don't want to recompute this all the time
|
196
|
+
});
|
197
|
+
|
198
|
+
return token;
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
setNormal(state, ch);
|
204
|
+
return null;
|
205
|
+
}
|
206
|
+
|
207
|
+
function inline(stream, state) {
|
208
|
+
var ch = stream.next(),
|
209
|
+
token = state.ctx.token;
|
210
|
+
|
211
|
+
function finish(ch) {
|
212
|
+
state.ctx.prev = ch;
|
213
|
+
return token;
|
214
|
+
}
|
215
|
+
|
216
|
+
if (ch != state.ctx.ch) {
|
217
|
+
return finish(ch);
|
218
|
+
}
|
219
|
+
|
220
|
+
if (/\s/.test(state.ctx.prev)) {
|
221
|
+
return finish(ch);
|
222
|
+
}
|
223
|
+
|
224
|
+
if (state.ctx.wide) {
|
225
|
+
ch = stream.next();
|
226
|
+
|
227
|
+
if (ch != state.ctx.ch) {
|
228
|
+
return finish(ch);
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
if (!stream.eol() && !rePostInline.test(stream.peek())) {
|
233
|
+
if (state.ctx.wide) {
|
234
|
+
stream.backUp(1);
|
235
|
+
}
|
236
|
+
|
237
|
+
return finish(ch);
|
238
|
+
}
|
239
|
+
|
240
|
+
setState(state, normal);
|
241
|
+
setNormal(state, ch);
|
242
|
+
|
243
|
+
return token;
|
244
|
+
}
|
245
|
+
|
246
|
+
function directive(stream, state) {
|
247
|
+
var token = null;
|
248
|
+
|
249
|
+
if (stream.match(reDirective)) {
|
250
|
+
token = 'directive';
|
251
|
+
} else if (stream.match(reHyperlink)) {
|
252
|
+
token = 'hyperlink';
|
253
|
+
} else if (stream.match(reFootnote)) {
|
254
|
+
token = 'footnote';
|
255
|
+
} else if (stream.match(reCitation)) {
|
256
|
+
token = 'citation';
|
257
|
+
} else {
|
258
|
+
stream.eatSpace();
|
259
|
+
|
260
|
+
if (stream.eol()) {
|
261
|
+
setNormal(state, stream);
|
262
|
+
return null;
|
263
|
+
} else {
|
264
|
+
stream.skipToEnd();
|
265
|
+
setState(state, comment);
|
266
|
+
return 'comment';
|
267
|
+
}
|
268
|
+
}
|
269
|
+
|
270
|
+
setState(state, body, {start: true});
|
271
|
+
return token;
|
272
|
+
}
|
273
|
+
|
274
|
+
function body(stream, state) {
|
275
|
+
var token = 'body';
|
276
|
+
|
277
|
+
if (!state.ctx.start || stream.sol()) {
|
278
|
+
return block(stream, state, token);
|
279
|
+
}
|
280
|
+
|
281
|
+
stream.skipToEnd();
|
282
|
+
setCtx(state);
|
283
|
+
|
284
|
+
return token;
|
285
|
+
}
|
286
|
+
|
287
|
+
function comment(stream, state) {
|
288
|
+
return block(stream, state, 'comment');
|
289
|
+
}
|
290
|
+
|
291
|
+
function verbatim(stream, state) {
|
292
|
+
if (!verbatimMode) {
|
293
|
+
return block(stream, state, 'verbatim');
|
294
|
+
} else {
|
295
|
+
if (stream.sol()) {
|
296
|
+
if (!stream.eatSpace()) {
|
297
|
+
setNormal(state, stream);
|
298
|
+
}
|
299
|
+
|
300
|
+
return null;
|
301
|
+
}
|
302
|
+
|
303
|
+
return verbatimMode.token(stream, state.ctx.local);
|
304
|
+
}
|
305
|
+
}
|
306
|
+
|
307
|
+
function block(stream, state, token) {
|
308
|
+
if (stream.eol() || stream.eatSpace()) {
|
309
|
+
stream.skipToEnd();
|
310
|
+
return token;
|
311
|
+
} else {
|
312
|
+
setNormal(state, stream);
|
313
|
+
return null;
|
314
|
+
}
|
315
|
+
}
|
316
|
+
|
317
|
+
return {
|
318
|
+
startState: function() {
|
319
|
+
return {fn: normal, ctx: {}};
|
320
|
+
},
|
321
|
+
|
322
|
+
copyState: function(state) {
|
323
|
+
return {fn: state.fn, ctx: state.ctx};
|
324
|
+
},
|
325
|
+
|
326
|
+
token: function(stream, state) {
|
327
|
+
var token = state.fn(stream, state);
|
328
|
+
return token;
|
329
|
+
}
|
330
|
+
};
|
331
|
+
});
|
332
|
+
|
333
|
+
CodeMirror.defineMIME("text/x-rst", "rst");
|
@@ -0,0 +1,65 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeMirror 2: Scheme mode</title>
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
7
|
+
<script src="scheme.js"></script>
|
8
|
+
<link rel="stylesheet" href="../../theme/default.css">
|
9
|
+
<style>.CodeMirror {background: #f8f8f8;}</style>
|
10
|
+
<link rel="stylesheet" href="../../css/docs.css">
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>CodeMirror 2: Scheme mode</h1>
|
14
|
+
<form><textarea id="code" name="code">
|
15
|
+
; See if the input starts with a given symbol.
|
16
|
+
(define (match-symbol input pattern)
|
17
|
+
(cond ((null? (remain input)) #f)
|
18
|
+
((eqv? (car (remain input)) pattern) (r-cdr input))
|
19
|
+
(else #f)))
|
20
|
+
|
21
|
+
; Allow the input to start with one of a list of patterns.
|
22
|
+
(define (match-or input pattern)
|
23
|
+
(cond ((null? pattern) #f)
|
24
|
+
((match-pattern input (car pattern)))
|
25
|
+
(else (match-or input (cdr pattern)))))
|
26
|
+
|
27
|
+
; Allow a sequence of patterns.
|
28
|
+
(define (match-seq input pattern)
|
29
|
+
(if (null? pattern)
|
30
|
+
input
|
31
|
+
(let ((match (match-pattern input (car pattern))))
|
32
|
+
(if match (match-seq match (cdr pattern)) #f))))
|
33
|
+
|
34
|
+
; Match with the pattern but no problem if it does not match.
|
35
|
+
(define (match-opt input pattern)
|
36
|
+
(let ((match (match-pattern input (car pattern))))
|
37
|
+
(if match match input)))
|
38
|
+
|
39
|
+
; Match anything (other than '()), until pattern is found. The rather
|
40
|
+
; clumsy form of requiring an ending pattern is needed to decide where
|
41
|
+
; the end of the match is. If none is given, this will match the rest
|
42
|
+
; of the sentence.
|
43
|
+
(define (match-any input pattern)
|
44
|
+
(cond ((null? (remain input)) #f)
|
45
|
+
((null? pattern) (f-cons (remain input) (clear-remain input)))
|
46
|
+
(else
|
47
|
+
(let ((accum-any (collector)))
|
48
|
+
(define (match-pattern-any input pattern)
|
49
|
+
(cond ((null? (remain input)) #f)
|
50
|
+
(else (accum-any (car (remain input)))
|
51
|
+
(cond ((match-pattern (r-cdr input) pattern))
|
52
|
+
(else (match-pattern-any (r-cdr input) pattern))))))
|
53
|
+
(let ((retval (match-pattern-any input (car pattern))))
|
54
|
+
(if retval
|
55
|
+
(f-cons (accum-any) retval)
|
56
|
+
#f))))))
|
57
|
+
</textarea></form>
|
58
|
+
<script>
|
59
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
60
|
+
</script>
|
61
|
+
|
62
|
+
<p><strong>MIME types defined:</strong> <code>text/x-scheme</code>.</p>
|
63
|
+
|
64
|
+
</body>
|
65
|
+
</html>
|