corrade-nucleus-nucleons – Blame information for rev 20
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | define("ace/mode/latex_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { |
2 | "use strict"; |
||
3 | |||
4 | var oop = require("../lib/oop"); |
||
5 | var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
||
6 | |||
7 | var LatexHighlightRules = function() { |
||
8 | |||
9 | this.$rules = { |
||
10 | "start" : [{ |
||
11 | token : "comment", |
||
12 | regex : "%.*$" |
||
13 | }, { |
||
14 | token : ["keyword", "lparen", "variable.parameter", "rparen", "lparen", "storage.type", "rparen"], |
||
15 | regex : "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)([^}]*)(})" |
||
16 | }, { |
||
17 | token : ["keyword","lparen", "variable.parameter", "rparen"], |
||
18 | regex : "(\\\\(?:label|v?ref|cite(?:[^{]*)))(?:({)([^}]*)(}))?" |
||
19 | }, { |
||
20 | token : ["storage.type", "lparen", "variable.parameter", "rparen"], |
||
21 | regex : "(\\\\(?:begin|end))({)(\\w*)(})" |
||
22 | }, { |
||
23 | token : "storage.type", |
||
24 | regex : "\\\\[a-zA-Z]+" |
||
25 | }, { |
||
26 | token : "lparen", |
||
27 | regex : "[[({]" |
||
28 | }, { |
||
29 | token : "rparen", |
||
30 | regex : "[\\])}]" |
||
31 | }, { |
||
32 | token : "constant.character.escape", |
||
33 | regex : "\\\\[^a-zA-Z]?" |
||
34 | }, { |
||
35 | token : "string", |
||
36 | regex : "\\${1,2}", |
||
37 | next : "equation" |
||
38 | }], |
||
39 | "equation" : [{ |
||
40 | token : "comment", |
||
41 | regex : "%.*$" |
||
42 | }, { |
||
43 | token : "string", |
||
44 | regex : "\\${1,2}", |
||
45 | next : "start" |
||
46 | }, { |
||
47 | token : "constant.character.escape", |
||
48 | regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)" |
||
49 | }, { |
||
50 | token : "error", |
||
51 | regex : "^\\s*$", |
||
52 | next : "start" |
||
53 | }, { |
||
54 | defaultToken : "string" |
||
55 | }] |
||
56 | |||
57 | }; |
||
58 | }; |
||
59 | oop.inherits(LatexHighlightRules, TextHighlightRules); |
||
60 | |||
61 | exports.LatexHighlightRules = LatexHighlightRules; |
||
62 | |||
63 | }); |
||
64 | |||
65 | define("ace/mode/folding/latex",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range","ace/token_iterator"], function(require, exports, module) { |
||
66 | "use strict"; |
||
67 | |||
68 | var oop = require("../../lib/oop"); |
||
69 | var BaseFoldMode = require("./fold_mode").FoldMode; |
||
70 | var Range = require("../../range").Range; |
||
71 | var TokenIterator = require("../../token_iterator").TokenIterator; |
||
72 | |||
73 | var FoldMode = exports.FoldMode = function() {}; |
||
74 | |||
75 | oop.inherits(FoldMode, BaseFoldMode); |
||
76 | |||
77 | (function() { |
||
78 | |||
79 | this.foldingStartMarker = /^\s*\\(begin)|(section|subsection|paragraph)\b|{\s*$/; |
||
80 | this.foldingStopMarker = /^\s*\\(end)\b|^\s*}/; |
||
81 | |||
82 | this.getFoldWidgetRange = function(session, foldStyle, row) { |
||
83 | var line = session.doc.getLine(row); |
||
84 | var match = this.foldingStartMarker.exec(line); |
||
85 | if (match) { |
||
86 | if (match[1]) |
||
87 | return this.latexBlock(session, row, match[0].length - 1); |
||
88 | if (match[2]) |
||
89 | return this.latexSection(session, row, match[0].length - 1); |
||
90 | |||
91 | return this.openingBracketBlock(session, "{", row, match.index); |
||
92 | } |
||
93 | |||
94 | var match = this.foldingStopMarker.exec(line); |
||
95 | if (match) { |
||
96 | if (match[1]) |
||
97 | return this.latexBlock(session, row, match[0].length - 1); |
||
98 | |||
99 | return this.closingBracketBlock(session, "}", row, match.index + match[0].length); |
||
100 | } |
||
101 | }; |
||
102 | |||
103 | this.latexBlock = function(session, row, column) { |
||
104 | var keywords = { |
||
105 | "\\begin": 1, |
||
106 | "\\end": -1 |
||
107 | }; |
||
108 | |||
109 | var stream = new TokenIterator(session, row, column); |
||
110 | var token = stream.getCurrentToken(); |
||
111 | if (!token || !(token.type == "storage.type" || token.type == "constant.character.escape")) |
||
112 | return; |
||
113 | |||
114 | var val = token.value; |
||
115 | var dir = keywords[val]; |
||
116 | |||
117 | var getType = function() { |
||
118 | var token = stream.stepForward(); |
||
119 | var type = token.type == "lparen" ?stream.stepForward().value : ""; |
||
120 | if (dir === -1) { |
||
121 | stream.stepBackward(); |
||
122 | if (type) |
||
123 | stream.stepBackward(); |
||
124 | } |
||
125 | return type; |
||
126 | }; |
||
127 | var stack = [getType()]; |
||
128 | var startColumn = dir === -1 ? stream.getCurrentTokenColumn() : session.getLine(row).length; |
||
129 | var startRow = row; |
||
130 | |||
131 | stream.step = dir === -1 ? stream.stepBackward : stream.stepForward; |
||
132 | while(token = stream.step()) { |
||
133 | if (!token || !(token.type == "storage.type" || token.type == "constant.character.escape")) |
||
134 | continue; |
||
135 | var level = keywords[token.value]; |
||
136 | if (!level) |
||
137 | continue; |
||
138 | var type = getType(); |
||
139 | if (level === dir) |
||
140 | stack.unshift(type); |
||
141 | else if (stack.shift() !== type || !stack.length) |
||
142 | break; |
||
143 | } |
||
144 | |||
145 | if (stack.length) |
||
146 | return; |
||
147 | |||
148 | var row = stream.getCurrentTokenRow(); |
||
149 | if (dir === -1) |
||
150 | return new Range(row, session.getLine(row).length, startRow, startColumn); |
||
151 | stream.stepBackward(); |
||
152 | return new Range(startRow, startColumn, row, stream.getCurrentTokenColumn()); |
||
153 | }; |
||
154 | |||
155 | this.latexSection = function(session, row, column) { |
||
156 | var keywords = ["\\subsection", "\\section", "\\begin", "\\end", "\\paragraph"]; |
||
157 | |||
158 | var stream = new TokenIterator(session, row, column); |
||
159 | var token = stream.getCurrentToken(); |
||
160 | if (!token || token.type != "storage.type") |
||
161 | return; |
||
162 | |||
163 | var startLevel = keywords.indexOf(token.value); |
||
164 | var stackDepth = 0 |
||
165 | var endRow = row; |
||
166 | |||
167 | while(token = stream.stepForward()) { |
||
168 | if (token.type !== "storage.type") |
||
169 | continue; |
||
170 | var level = keywords.indexOf(token.value); |
||
171 | |||
172 | if (level >= 2) { |
||
173 | if (!stackDepth) |
||
174 | endRow = stream.getCurrentTokenRow() - 1; |
||
175 | stackDepth += level == 2 ? 1 : - 1; |
||
176 | if (stackDepth < 0) |
||
177 | break |
||
178 | } else if (level >= startLevel) |
||
179 | break; |
||
180 | } |
||
181 | |||
182 | if (!stackDepth) |
||
183 | endRow = stream.getCurrentTokenRow() - 1; |
||
184 | |||
185 | while (endRow > row && !/\S/.test(session.getLine(endRow))) |
||
186 | endRow--; |
||
187 | |||
188 | return new Range( |
||
189 | row, session.getLine(row).length, |
||
190 | endRow, session.getLine(endRow).length |
||
191 | ); |
||
192 | }; |
||
193 | |||
194 | }).call(FoldMode.prototype); |
||
195 | |||
196 | }); |
||
197 | |||
198 | define("ace/mode/latex",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/latex_highlight_rules","ace/mode/folding/latex"], function(require, exports, module) { |
||
199 | "use strict"; |
||
200 | |||
201 | var oop = require("../lib/oop"); |
||
202 | var TextMode = require("./text").Mode; |
||
203 | var LatexHighlightRules = require("./latex_highlight_rules").LatexHighlightRules; |
||
204 | var LatexFoldMode = require("./folding/latex").FoldMode; |
||
205 | |||
206 | var Mode = function() { |
||
207 | this.HighlightRules = LatexHighlightRules; |
||
208 | this.foldingRules = new LatexFoldMode(); |
||
209 | this.$behaviour = this.$defaultBehaviour; |
||
210 | }; |
||
211 | oop.inherits(Mode, TextMode); |
||
212 | |||
213 | (function() { |
||
214 | this.type = "text"; |
||
215 | |||
216 | this.lineCommentStart = "%"; |
||
217 | |||
218 | this.$id = "ace/mode/latex"; |
||
219 | }).call(Mode.prototype); |
||
220 | |||
221 | exports.Mode = Mode; |
||
222 | |||
223 | }); |