Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-bibtex.js

raw symbols SCIP
1 ace.define("ace/mode/bibtex_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
2 var oop = require("../lib/oop");
3 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
4 var BibTeXHighlightRules = function () {
5 this.$rules = {
6 start: [
7 {
8 token: "comment",
9 regex: /@Comment\{/,
10 stateName: "bibtexComment",
11 push: [
12 {
13 token: "comment",
14 regex: /}/,
15 next: "pop"
16 }, {
17 token: "comment",
18 regex: /\{/,
19 push: "bibtexComment"
20 }, {
21 defaultToken: "comment"
22 }
23 ]
24 }, {
25 token: [
26 "keyword", "text", "paren.lparen", "text", "variable", "text", "keyword.operator"
27 ],
28 regex: /(@String)(\s*)(\{)(\s*)([a-zA-Z]*)(\s*)(=)/,
29 push: [
30 {
31 token: "paren.rparen",
32 regex: /\}/,
33 next: "pop"
34 }, {
35 include: "#misc"
36 }, {
37 defaultToken: "text"
38 }
39 ]
40 }, {
41 token: [
42 "keyword", "text", "paren.lparen", "text", "variable", "text", "keyword.operator"
43 ],
44 regex: /(@String)(\s*)(\()(\s*)([a-zA-Z]*)(\s*)(=)/,
45 push: [
46 {
47 token: "paren.rparen",
48 regex: /\)/,
49 next: "pop"
50 }, {
51 include: "#misc"
52 }, {
53 defaultToken: "text"
54 }
55 ]
56 }, {
57 token: [
58 "keyword", "text", "paren.lparen"
59 ],
60 regex: /(@preamble)(\s*)(\()/,
61 push: [
62 {
63 token: "paren.rparen",
64 regex: /\)/,
65 next: "pop"
66 }, {
67 include: "#misc"
68 }, {
69 defaultToken: "text"
70 }
71 ]
72 }, {
73 token: [
74 "keyword", "text", "paren.lparen"
75 ],
76 regex: /(@preamble)(\s*)(\{)/,
77 push: [
78 {
79 token: "paren.rparen",
80 regex: /\}/,
81 next: "pop"
82 }, {
83 include: "#misc"
84 }, {
85 defaultToken: "text"
86 }
87 ]
88 }, {
89 token: [
90 "keyword", "text", "paren.lparen", "text", "support.class"
91 ],
92 regex: /(@[a-zA-Z]+)(\s*)(\{)(\s*)([\w-]+)/,
93 push: [
94 {
95 token: "paren.rparen",
96 regex: /\}/,
97 next: "pop"
98 }, {
99 token: [
100 "variable", "text", "keyword.operator"
101 ],
102 regex: /([a-zA-Z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+)(\s*)(=)/,
103 push: [
104 {
105 token: "text",
106 regex: /(?=[,}])/,
107 next: "pop"
108 }, {
109 include: "#misc"
110 }, {
111 include: "#integer"
112 }, {
113 defaultToken: "text"
114 }
115 ]
116 }, {
117 token: "punctuation",
118 regex: /,/
119 }, {
120 defaultToken: "text"
121 }
122 ]
123 }, {
124 defaultToken: "comment"
125 }
126 ],
127 "#integer": [
128 {
129 token: "constant.numeric.bibtex",
130 regex: /\d+/
131 }
132 ],
133 "#misc": [
134 {
135 token: "string",
136 regex: /"/,
137 push: "#string_quotes"
138 }, {
139 token: "paren.lparen",
140 regex: /\{/,
141 push: "#string_braces"
142 }, {
143 token: "keyword.operator",
144 regex: /#/
145 }
146 ],
147 "#string_braces": [
148 {
149 token: "paren.rparen",
150 regex: /\}/,
151 next: "pop"
152 }, {
153 token: "invalid.illegal",
154 regex: /@/
155 }, {
156 include: "#misc"
157 }, {
158 defaultToken: "string"
159 }
160 ],
161 "#string_quotes": [
162 {
163 token: "string",
164 regex: /"/,
165 next: "pop"
166 }, {
167 include: "#misc"
168 }, {
169 defaultToken: "string"
170 }
171 ]
172 };
173 this.normalizeRules();
174 };
175 oop.inherits(BibTeXHighlightRules, TextHighlightRules);
176 exports.BibTeXHighlightRules = BibTeXHighlightRules;
177
178 });
179
180 ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
181 var oop = require("../../lib/oop");
182 var Range = require("../../range").Range;
183 var BaseFoldMode = require("./fold_mode").FoldMode;
184 var FoldMode = exports.FoldMode = function (commentRegex) {
185 if (commentRegex) {
186 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
187 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
188 }
189 };
190 oop.inherits(FoldMode, BaseFoldMode);
191 (function () {
192 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
193 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
194 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
195 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
196 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
197 this._getFoldWidgetBase = this.getFoldWidget;
198 this.getFoldWidget = function (session, foldStyle, row) {
199 var line = session.getLine(row);
200 if (this.singleLineBlockCommentRe.test(line)) {
201 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
202 return "";
203 }
204 var fw = this._getFoldWidgetBase(session, foldStyle, row);
205 if (!fw && this.startRegionRe.test(line))
206 return "start"; // lineCommentRegionStart
207 return fw;
208 };
209 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
210 var line = session.getLine(row);
211 if (this.startRegionRe.test(line))
212 return this.getCommentRegionBlock(session, line, row);
213 var match = line.match(this.foldingStartMarker);
214 if (match) {
215 var i = match.index;
216 if (match[1])
217 return this.openingBracketBlock(session, match[1], row, i);
218 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
219 if (range && !range.isMultiLine()) {
220 if (forceMultiline) {
221 range = this.getSectionRange(session, row);
222 }
223 else if (foldStyle != "all")
224 range = null;
225 }
226 return range;
227 }
228 if (foldStyle === "markbegin")
229 return;
230 var match = line.match(this.foldingStopMarker);
231 if (match) {
232 var i = match.index + match[0].length;
233 if (match[1])
234 return this.closingBracketBlock(session, match[1], row, i);
235 return session.getCommentFoldRange(row, i, -1);
236 }
237 };
238 this.getSectionRange = function (session, row) {
239 var line = session.getLine(row);
240 var startIndent = line.search(/\S/);
241 var startRow = row;
242 var startColumn = line.length;
243 row = row + 1;
244 var endRow = row;
245 var maxRow = session.getLength();
246 while (++row < maxRow) {
247 line = session.getLine(row);
248 var indent = line.search(/\S/);
249 if (indent === -1)
250 continue;
251 if (startIndent > indent)
252 break;
253 var subRange = this.getFoldWidgetRange(session, "all", row);
254 if (subRange) {
255 if (subRange.start.row <= startRow) {
256 break;
257 }
258 else if (subRange.isMultiLine()) {
259 row = subRange.end.row;
260 }
261 else if (startIndent == indent) {
262 break;
263 }
264 }
265 endRow = row;
266 }
267 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
268 };
269 this.getCommentRegionBlock = function (session, line, row) {
270 var startColumn = line.search(/\s*$/);
271 var maxRow = session.getLength();
272 var startRow = row;
273 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
274 var depth = 1;
275 while (++row < maxRow) {
276 line = session.getLine(row);
277 var m = re.exec(line);
278 if (!m)
279 continue;
280 if (m[1])
281 depth--;
282 else
283 depth++;
284 if (!depth)
285 break;
286 }
287 var endRow = row;
288 if (endRow > startRow) {
289 return new Range(startRow, startColumn, endRow, line.length);
290 }
291 };
292 }).call(FoldMode.prototype);
293
294 });
295
296 ace.define("ace/mode/bibtex",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/bibtex_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
297 var oop = require("../lib/oop");
298 var TextMode = require("./text").Mode;
299 var BibTeXHighlightRules = require("./bibtex_highlight_rules").BibTeXHighlightRules;
300 var FoldMode = require("./folding/cstyle").FoldMode;
301 var Mode = function () {
302 this.HighlightRules = BibTeXHighlightRules;
303 this.foldingRules = new FoldMode();
304 };
305 oop.inherits(Mode, TextMode);
306 (function () {
307 this.$id = "ace/mode/bibtex";
308 }).call(Mode.prototype);
309 exports.Mode = Mode;
310
311 }); (function() {
312 ace.require(["ace/mode/bibtex"], function(m) {
313 if (typeof module == "object" && typeof exports == "object" && module) {
314 module.exports = m;
315 }
316 });
317 })();
318