Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/asciidoc_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 AsciidocHighlightRules = function () {
5 var identifierRe = "[a-zA-Z\u00a1-\uffff]+\\b";
6 this.$rules = {
7 "start": [
8 { token: "empty", regex: /$/ },
9 { token: "literal", regex: /^\.{4,}\s*$/, next: "listingBlock" },
10 { token: "literal", regex: /^-{4,}\s*$/, next: "literalBlock" },
11 { token: "string", regex: /^\+{4,}\s*$/, next: "passthroughBlock" },
12 { token: "keyword", regex: /^={4,}\s*$/ },
13 { token: "text", regex: /^\s*$/ },
14 { token: "empty", regex: "", next: "dissallowDelimitedBlock" }
15 ],
16 "dissallowDelimitedBlock": [
17 { include: "paragraphEnd" },
18 { token: "comment", regex: '^//.+$' },
19 { token: "keyword", regex: "^(?:NOTE|TIP|IMPORTANT|WARNING|CAUTION):" },
20 { include: "listStart" },
21 { token: "literal", regex: /^\s+.+$/, next: "indentedBlock" },
22 { token: "empty", regex: "", next: "text" }
23 ],
24 "paragraphEnd": [
25 { token: "doc.comment", regex: /^\/{4,}\s*$/, next: "commentBlock" },
26 { token: "tableBlock", regex: /^\s*[|!]=+\s*$/, next: "tableBlock" },
27 { token: "keyword", regex: /^(?:--|''')\s*$/, next: "start" },
28 { token: "option", regex: /^\[.*\]\s*$/, next: "start" },
29 { token: "pageBreak", regex: /^>{3,}$/, next: "start" },
30 { token: "literal", regex: /^\.{4,}\s*$/, next: "listingBlock" },
31 { token: "titleUnderline", regex: /^(?:={2,}|-{2,}|~{2,}|\^{2,}|\+{2,})\s*$/, next: "start" },
32 { token: "singleLineTitle", regex: /^={1,5}\s+\S.*$/, next: "start" },
33 { token: "otherBlock", regex: /^(?:\*{2,}|_{2,})\s*$/, next: "start" },
34 { token: "optionalTitle", regex: /^\.[^.\s].+$/, next: "start" }
35 ],
36 "listStart": [
37 { token: "keyword", regex: /^\s*(?:\d+\.|[a-zA-Z]\.|[ixvmIXVM]+\)|\*{1,5}|-|\.{1,5})\s/, next: "listText" },
38 { token: "meta.tag", regex: /^.+(?::{2,4}|;;)(?: |$)/, next: "listText" },
39 { token: "support.function.list.callout", regex: /^(?:<\d+>|\d+>|>) /, next: "text" },
40 { token: "keyword", regex: /^\+\s*$/, next: "start" }
41 ],
42 "text": [
43 { token: ["link", "variable.language"], regex: /((?:https?:\/\/|ftp:\/\/|file:\/\/|mailto:|callto:)[^\s\[]+)(\[.*?\])/ },
44 { token: "link", regex: /(?:https?:\/\/|ftp:\/\/|file:\/\/|mailto:|callto:)[^\s\[]+/ },
45 { token: "link", regex: /\b[\w\.\/\-]+@[\w\.\/\-]+\b/ },
46 { include: "macros" },
47 { include: "paragraphEnd" },
48 { token: "literal", regex: /\+{3,}/, next: "smallPassthrough" },
49 { token: "escape", regex: /\((?:C|TM|R)\)|\.{3}|->|<-|=>|<=|&#(?:\d+|x[a-fA-F\d]+);|(?: |^)--(?=\s+\S)/ },
50 { token: "escape", regex: /\\[_*'`+#]|\\{2}[_*'`+#]{2}/ },
51 { token: "keyword", regex: /\s\+$/ },
52 { token: "text", regex: identifierRe },
53 { token: ["keyword", "string", "keyword"],
54 regex: /(<<[\w\d\-$]+,)(.*?)(>>|$)/ },
55 { token: "keyword", regex: /<<[\w\d\-$]+,?|>>/ },
56 { token: "constant.character", regex: /\({2,3}.*?\){2,3}/ },
57 { token: "keyword", regex: /\[\[.+?\]\]/ },
58 { token: "support", regex: /^\[{3}[\w\d =\-]+\]{3}/ },
59 { include: "quotes" },
60 { token: "empty", regex: /^\s*$/, next: "start" }
61 ],
62 "listText": [
63 { include: "listStart" },
64 { include: "text" }
65 ],
66 "indentedBlock": [
67 { token: "literal", regex: /^[\s\w].+$/, next: "indentedBlock" },
68 { token: "literal", regex: "", next: "start" }
69 ],
70 "listingBlock": [
71 { token: "literal", regex: /^\.{4,}\s*$/, next: "dissallowDelimitedBlock" },
72 { token: "constant.numeric", regex: '<\\d+>' },
73 { token: "literal", regex: '[^<]+' },
74 { token: "literal", regex: '<' }
75 ],
76 "literalBlock": [
77 { token: "literal", regex: /^-{4,}\s*$/, next: "dissallowDelimitedBlock" },
78 { token: "constant.numeric", regex: '<\\d+>' },
79 { token: "literal", regex: '[^<]+' },
80 { token: "literal", regex: '<' }
81 ],
82 "passthroughBlock": [
83 { token: "literal", regex: /^\+{4,}\s*$/, next: "dissallowDelimitedBlock" },
84 { token: "literal", regex: identifierRe + "|\\d+" },
85 { include: "macros" },
86 { token: "literal", regex: "." }
87 ],
88 "smallPassthrough": [
89 { token: "literal", regex: /[+]{3,}/, next: "dissallowDelimitedBlock" },
90 { token: "literal", regex: /^\s*$/, next: "dissallowDelimitedBlock" },
91 { token: "literal", regex: identifierRe + "|\\d+" },
92 { include: "macros" }
93 ],
94 "commentBlock": [
95 { token: "doc.comment", regex: /^\/{4,}\s*$/, next: "dissallowDelimitedBlock" },
96 { token: "doc.comment", regex: '^.*$' }
97 ],
98 "tableBlock": [
99 { token: "tableBlock", regex: /^\s*\|={3,}\s*$/, next: "dissallowDelimitedBlock" },
100 { token: "tableBlock", regex: /^\s*!={3,}\s*$/, next: "innerTableBlock" },
101 { token: "tableBlock", regex: /\|/ },
102 { include: "text", noEscape: true }
103 ],
104 "innerTableBlock": [
105 { token: "tableBlock", regex: /^\s*!={3,}\s*$/, next: "tableBlock" },
106 { token: "tableBlock", regex: /^\s*|={3,}\s*$/, next: "dissallowDelimitedBlock" },
107 { token: "tableBlock", regex: /!/ }
108 ],
109 "macros": [
110 { token: "macro", regex: /{[\w\-$]+}/ },
111 { token: ["text", "string", "text", "constant.character", "text"], regex: /({)([\w\-$]+)(:)?(.+)?(})/ },
112 { token: ["text", "markup.list.macro", "keyword", "string"], regex: /(\w+)(footnote(?:ref)?::?)([^\s\[]+)?(\[.*?\])?/ },
113 { token: ["markup.list.macro", "keyword", "string"], regex: /([a-zA-Z\-][\w\.\/\-]*::?)([^\s\[]+)(\[.*?\])?/ },
114 { token: ["markup.list.macro", "keyword"], regex: /([a-zA-Z\-][\w\.\/\-]+::?)(\[.*?\])/ },
115 { token: "keyword", regex: /^:.+?:(?= |$)/ }
116 ],
117 "quotes": [
118 { token: "string.italic", regex: /__[^_\s].*?__/ },
119 { token: "string.italic", regex: quoteRule("_") },
120 { token: "keyword.bold", regex: /\*\*[^*\s].*?\*\*/ },
121 { token: "keyword.bold", regex: quoteRule("\\*") },
122 { token: "literal", regex: quoteRule("\\+") },
123 { token: "literal", regex: /\+\+[^+\s].*?\+\+/ },
124 { token: "literal", regex: /\$\$.+?\$\$/ },
125 { token: "literal", regex: quoteRule("`") },
126 { token: "keyword", regex: quoteRule("^") },
127 { token: "keyword", regex: quoteRule("~") },
128 { token: "keyword", regex: /##?/ },
129 { token: "keyword", regex: /(?:\B|^)``|\b''/ }
130 ]
131 };
132 function quoteRule(ch) {
133 var prefix = /\w/.test(ch) ? "\\b" : "(?:\\B|^)";
134 return prefix + ch + "[^" + ch + "].*?" + ch + "(?![\\w*])";
135 }
136 var tokenMap = {
137 macro: "constant.character",
138 tableBlock: "doc.comment",
139 titleUnderline: "markup.heading",
140 singleLineTitle: "markup.heading",
141 pageBreak: "string",
142 option: "string.regexp",
143 otherBlock: "markup.list",
144 literal: "support.function",
145 optionalTitle: "constant.numeric",
146 escape: "constant.language.escape",
147 link: "markup.underline.list"
148 };
149 for (var state in this.$rules) {
150 var stateRules = this.$rules[state];
151 for (var i = stateRules.length; i--;) {
152 var rule = stateRules[i];
153 if (rule.include || typeof rule == "string") {
154 var args = [i, 1].concat(this.$rules[rule.include || rule]);
155 if (rule.noEscape) {
156 args = args.filter(function (x) {
157 return !x.next;
158 });
159 }
160 stateRules.splice.apply(stateRules, args);
161 }
162 else if (rule.token in tokenMap) {
163 rule.token = tokenMap[rule.token];
164 }
165 }
166 }
167 };
168 oop.inherits(AsciidocHighlightRules, TextHighlightRules);
169 exports.AsciidocHighlightRules = AsciidocHighlightRules;
170
171 });
172
173 ace.define("ace/mode/folding/asciidoc",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module){"use strict";
174 var oop = require("../../lib/oop");
175 var BaseFoldMode = require("./fold_mode").FoldMode;
176 var Range = require("../../range").Range;
177 var FoldMode = exports.FoldMode = function () { };
178 oop.inherits(FoldMode, BaseFoldMode);
179 (function () {
180 this.foldingStartMarker = /^(?:\|={10,}|[\.\/=\-~^+]{4,}\s*$|={1,5} )/;
181 this.singleLineHeadingRe = /^={1,5}(?=\s+\S)/;
182 this.getFoldWidget = function (session, foldStyle, row) {
183 var line = session.getLine(row);
184 if (!this.foldingStartMarker.test(line))
185 return "";
186 if (line[0] == "=") {
187 if (this.singleLineHeadingRe.test(line))
188 return "start";
189 if (session.getLine(row - 1).length != session.getLine(row).length)
190 return "";
191 return "start";
192 }
193 if (session.bgTokenizer.getState(row) == "dissallowDelimitedBlock")
194 return "end";
195 return "start";
196 };
197 this.getFoldWidgetRange = function (session, foldStyle, row) {
198 var line = session.getLine(row);
199 var startColumn = line.length;
200 var maxRow = session.getLength();
201 var startRow = row;
202 var endRow = row;
203 if (!line.match(this.foldingStartMarker))
204 return;
205 var token;
206 function getTokenType(row) {
207 token = session.getTokens(row)[0];
208 return token && token.type;
209 }
210 var levels = ["=", "-", "~", "^", "+"];
211 var heading = "markup.heading";
212 var singleLineHeadingRe = this.singleLineHeadingRe;
213 function getLevel() {
214 var match = token.value.match(singleLineHeadingRe);
215 if (match)
216 return match[0].length;
217 var level = levels.indexOf(token.value[0]) + 1;
218 if (level == 1) {
219 if (session.getLine(row - 1).length != session.getLine(row).length)
220 return Infinity;
221 }
222 return level;
223 }
224 if (getTokenType(row) == heading) {
225 var startHeadingLevel = getLevel();
226 while (++row < maxRow) {
227 if (getTokenType(row) != heading)
228 continue;
229 var level = getLevel();
230 if (level <= startHeadingLevel)
231 break;
232 }
233 var isSingleLineHeading = token && token.value.match(this.singleLineHeadingRe);
234 endRow = isSingleLineHeading ? row - 1 : row - 2;
235 if (endRow > startRow) {
236 while (endRow > startRow && (!getTokenType(endRow) || token.value[0] == "["))
237 endRow--;
238 }
239 if (endRow > startRow) {
240 var endColumn = session.getLine(endRow).length;
241 return new Range(startRow, startColumn, endRow, endColumn);
242 }
243 }
244 else {
245 var state = session.bgTokenizer.getState(row);
246 if (state == "dissallowDelimitedBlock") {
247 while (row-- > 0) {
248 if (session.bgTokenizer.getState(row).lastIndexOf("Block") == -1)
249 break;
250 }
251 endRow = row + 1;
252 if (endRow < startRow) {
253 var endColumn = session.getLine(row).length;
254 return new Range(endRow, 5, startRow, startColumn - 5);
255 }
256 }
257 else {
258 while (++row < maxRow) {
259 if (session.bgTokenizer.getState(row) == "dissallowDelimitedBlock")
260 break;
261 }
262 endRow = row;
263 if (endRow > startRow) {
264 var endColumn = session.getLine(row).length;
265 return new Range(startRow, 5, endRow, endColumn - 5);
266 }
267 }
268 }
269 };
270 }).call(FoldMode.prototype);
271
272 });
273
274 ace.define("ace/mode/asciidoc",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/asciidoc_highlight_rules","ace/mode/folding/asciidoc"], function(require, exports, module){"use strict";
275 var oop = require("../lib/oop");
276 var TextMode = require("./text").Mode;
277 var AsciidocHighlightRules = require("./asciidoc_highlight_rules").AsciidocHighlightRules;
278 var AsciidocFoldMode = require("./folding/asciidoc").FoldMode;
279 var Mode = function () {
280 this.HighlightRules = AsciidocHighlightRules;
281 this.foldingRules = new AsciidocFoldMode();
282 };
283 oop.inherits(Mode, TextMode);
284 (function () {
285 this.type = "text";
286 this.getNextLineIndent = function (state, line, tab) {
287 if (state == "listblock") {
288 var match = /^((?:.+)?)([-+*][ ]+)/.exec(line);
289 if (match) {
290 return new Array(match[1].length + 1).join(" ") + match[2];
291 }
292 else {
293 return "";
294 }
295 }
296 else {
297 return this.$getIndent(line);
298 }
299 };
300 this.$id = "ace/mode/asciidoc";
301 }).call(Mode.prototype);
302 exports.Mode = Mode;
303
304 }); (function() {
305 ace.require(["ace/mode/asciidoc"], function(m) {
306 if (typeof module == "object" && typeof exports == "object" && module) {
307 module.exports = m;
308 }
309 });
310 })();
311