20b085f014791c3916e38d818e76ef3c.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. 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";
  179. var oop = require("../../lib/oop");
  180. var Range = require("../../range").Range;
  181. var BaseFoldMode = require("./fold_mode").FoldMode;
  182. var FoldMode = exports.FoldMode = function (commentRegex) {
  183. if (commentRegex) {
  184. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  185. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  186. }
  187. };
  188. oop.inherits(FoldMode, BaseFoldMode);
  189. (function () {
  190. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  191. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  192. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  193. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  194. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  195. this._getFoldWidgetBase = this.getFoldWidget;
  196. this.getFoldWidget = function (session, foldStyle, row) {
  197. var line = session.getLine(row);
  198. if (this.singleLineBlockCommentRe.test(line)) {
  199. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  200. return "";
  201. }
  202. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  203. if (!fw && this.startRegionRe.test(line))
  204. return "start"; // lineCommentRegionStart
  205. return fw;
  206. };
  207. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  208. var line = session.getLine(row);
  209. if (this.startRegionRe.test(line))
  210. return this.getCommentRegionBlock(session, line, row);
  211. var match = line.match(this.foldingStartMarker);
  212. if (match) {
  213. var i = match.index;
  214. if (match[1])
  215. return this.openingBracketBlock(session, match[1], row, i);
  216. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  217. if (range && !range.isMultiLine()) {
  218. if (forceMultiline) {
  219. range = this.getSectionRange(session, row);
  220. }
  221. else if (foldStyle != "all")
  222. range = null;
  223. }
  224. return range;
  225. }
  226. if (foldStyle === "markbegin")
  227. return;
  228. var match = line.match(this.foldingStopMarker);
  229. if (match) {
  230. var i = match.index + match[0].length;
  231. if (match[1])
  232. return this.closingBracketBlock(session, match[1], row, i);
  233. return session.getCommentFoldRange(row, i, -1);
  234. }
  235. };
  236. this.getSectionRange = function (session, row) {
  237. var line = session.getLine(row);
  238. var startIndent = line.search(/\S/);
  239. var startRow = row;
  240. var startColumn = line.length;
  241. row = row + 1;
  242. var endRow = row;
  243. var maxRow = session.getLength();
  244. while (++row < maxRow) {
  245. line = session.getLine(row);
  246. var indent = line.search(/\S/);
  247. if (indent === -1)
  248. continue;
  249. if (startIndent > indent)
  250. break;
  251. var subRange = this.getFoldWidgetRange(session, "all", row);
  252. if (subRange) {
  253. if (subRange.start.row <= startRow) {
  254. break;
  255. }
  256. else if (subRange.isMultiLine()) {
  257. row = subRange.end.row;
  258. }
  259. else if (startIndent == indent) {
  260. break;
  261. }
  262. }
  263. endRow = row;
  264. }
  265. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  266. };
  267. this.getCommentRegionBlock = function (session, line, row) {
  268. var startColumn = line.search(/\s*$/);
  269. var maxRow = session.getLength();
  270. var startRow = row;
  271. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  272. var depth = 1;
  273. while (++row < maxRow) {
  274. line = session.getLine(row);
  275. var m = re.exec(line);
  276. if (!m)
  277. continue;
  278. if (m[1])
  279. depth--;
  280. else
  281. depth++;
  282. if (!depth)
  283. break;
  284. }
  285. var endRow = row;
  286. if (endRow > startRow) {
  287. return new Range(startRow, startColumn, endRow, line.length);
  288. }
  289. };
  290. }).call(FoldMode.prototype);
  291. });
  292. 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";
  293. var oop = require("../lib/oop");
  294. var TextMode = require("./text").Mode;
  295. var BibTeXHighlightRules = require("./bibtex_highlight_rules").BibTeXHighlightRules;
  296. var FoldMode = require("./folding/cstyle").FoldMode;
  297. var Mode = function () {
  298. this.HighlightRules = BibTeXHighlightRules;
  299. this.foldingRules = new FoldMode();
  300. };
  301. oop.inherits(Mode, TextMode);
  302. (function () {
  303. this.$id = "ace/mode/bibtex";
  304. }).call(Mode.prototype);
  305. exports.Mode = Mode;
  306. }); (function() {
  307. ace.require(["ace/mode/bibtex"], function(m) {
  308. if (typeof module == "object" && typeof exports == "object" && module) {
  309. module.exports = m;
  310. }
  311. });
  312. })();