a2892f98db7a4df3c9483669ddb59ec2.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. ace.define("ace/mode/latex_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 LatexHighlightRules = function () {
  5. this.$rules = {
  6. "start": [{
  7. token: "comment",
  8. regex: "%.*$"
  9. }, {
  10. token: ["keyword", "lparen", "variable.parameter", "rparen", "lparen", "storage.type", "rparen"],
  11. regex: "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)([^}]*)(})"
  12. }, {
  13. token: ["keyword", "lparen", "variable.parameter", "rparen"],
  14. regex: "(\\\\(?:label|v?ref|cite(?:[^{]*)))(?:({)([^}]*)(}))?"
  15. }, {
  16. token: ["storage.type", "lparen", "variable.parameter", "rparen"],
  17. regex: "(\\\\begin)({)(verbatim)(})",
  18. next: "verbatim"
  19. }, {
  20. token: ["storage.type", "lparen", "variable.parameter", "rparen"],
  21. regex: "(\\\\begin)({)(lstlisting)(})",
  22. next: "lstlisting"
  23. }, {
  24. token: ["storage.type", "lparen", "variable.parameter", "rparen"],
  25. regex: "(\\\\(?:begin|end))({)([\\w*]*)(})"
  26. }, {
  27. token: "storage.type",
  28. regex: /\\verb\b\*?/,
  29. next: [{
  30. token: ["keyword.operator", "string", "keyword.operator"],
  31. regex: "(.)(.*?)(\\1|$)|",
  32. next: "start"
  33. }]
  34. }, {
  35. token: "storage.type",
  36. regex: "\\\\[a-zA-Z]+"
  37. }, {
  38. token: "lparen",
  39. regex: "[[({]"
  40. }, {
  41. token: "rparen",
  42. regex: "[\\])}]"
  43. }, {
  44. token: "constant.character.escape",
  45. regex: "\\\\[^a-zA-Z]?"
  46. }, {
  47. token: "string",
  48. regex: "\\${1,2}",
  49. next: "equation"
  50. }],
  51. "equation": [{
  52. token: "comment",
  53. regex: "%.*$"
  54. }, {
  55. token: "string",
  56. regex: "\\${1,2}",
  57. next: "start"
  58. }, {
  59. token: "constant.character.escape",
  60. regex: "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
  61. }, {
  62. token: "error",
  63. regex: "^\\s*$",
  64. next: "start"
  65. }, {
  66. defaultToken: "string"
  67. }],
  68. "verbatim": [{
  69. token: ["storage.type", "lparen", "variable.parameter", "rparen"],
  70. regex: "(\\\\end)({)(verbatim)(})",
  71. next: "start"
  72. }, {
  73. defaultToken: "text"
  74. }],
  75. "lstlisting": [{
  76. token: ["storage.type", "lparen", "variable.parameter", "rparen"],
  77. regex: "(\\\\end)({)(lstlisting)(})",
  78. next: "start"
  79. }, {
  80. defaultToken: "text"
  81. }]
  82. };
  83. this.normalizeRules();
  84. };
  85. oop.inherits(LatexHighlightRules, TextHighlightRules);
  86. exports.LatexHighlightRules = LatexHighlightRules;
  87. });
  88. ace.define("ace/mode/rdoc_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules","ace/mode/latex_highlight_rules"], function(require, exports, module){/*
  89. * rdoc_highlight_rules.js
  90. *
  91. * Copyright (C) 2009-11 by RStudio, Inc.
  92. *
  93. * Distributed under the BSD license:
  94. *
  95. * Copyright (c) 2010, Ajax.org B.V.
  96. * All rights reserved.
  97. *
  98. * Redistribution and use in source and binary forms, with or without
  99. * modification, are permitted provided that the following conditions are met:
  100. * * Redistributions of source code must retain the above copyright
  101. * notice, this list of conditions and the following disclaimer.
  102. * * Redistributions in binary form must reproduce the above copyright
  103. * notice, this list of conditions and the following disclaimer in the
  104. * documentation and/or other materials provided with the distribution.
  105. * * Neither the name of Ajax.org B.V. nor the
  106. * names of its contributors may be used to endorse or promote products
  107. * derived from this software without specific prior written permission.
  108. *
  109. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  110. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  111. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  112. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  113. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  114. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  115. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  116. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  117. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  118. *
  119. */
  120. "use strict";
  121. var oop = require("../lib/oop");
  122. var lang = require("../lib/lang");
  123. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  124. var LaTeXHighlightRules = require("./latex_highlight_rules");
  125. var RDocHighlightRules = function () {
  126. this.$rules = {
  127. "start": [
  128. {
  129. token: "comment",
  130. regex: "%.*$"
  131. }, {
  132. token: "text",
  133. regex: "\\\\[$&%#\\{\\}]"
  134. }, {
  135. token: "keyword",
  136. regex: "\\\\(?:name|alias|method|S3method|S4method|item|code|preformatted|kbd|pkg|var|env|option|command|author|email|url|source|cite|acronym|href|code|preformatted|link|eqn|deqn|keyword|usage|examples|dontrun|dontshow|figure|if|ifelse|Sexpr|RdOpts|inputencoding|usepackage)\\b",
  137. next: "nospell"
  138. }, {
  139. token: "keyword",
  140. regex: "\\\\(?:[a-zA-Z0-9]+|[^a-zA-Z0-9])"
  141. }, {
  142. token: "paren.keyword.operator",
  143. regex: "[[({]"
  144. }, {
  145. token: "paren.keyword.operator",
  146. regex: "[\\])}]"
  147. }, {
  148. token: "text",
  149. regex: "\\s+"
  150. }
  151. ],
  152. "nospell": [
  153. {
  154. token: "comment",
  155. regex: "%.*$",
  156. next: "start"
  157. }, {
  158. token: "nospell.text",
  159. regex: "\\\\[$&%#\\{\\}]"
  160. }, {
  161. token: "keyword",
  162. regex: "\\\\(?:name|alias|method|S3method|S4method|item|code|preformatted|kbd|pkg|var|env|option|command|author|email|url|source|cite|acronym|href|code|preformatted|link|eqn|deqn|keyword|usage|examples|dontrun|dontshow|figure|if|ifelse|Sexpr|RdOpts|inputencoding|usepackage)\\b"
  163. }, {
  164. token: "keyword",
  165. regex: "\\\\(?:[a-zA-Z0-9]+|[^a-zA-Z0-9])",
  166. next: "start"
  167. }, {
  168. token: "paren.keyword.operator",
  169. regex: "[[({]"
  170. }, {
  171. token: "paren.keyword.operator",
  172. regex: "[\\])]"
  173. }, {
  174. token: "paren.keyword.operator",
  175. regex: "}",
  176. next: "start"
  177. }, {
  178. token: "nospell.text",
  179. regex: "\\s+"
  180. }, {
  181. token: "nospell.text",
  182. regex: "\\w+"
  183. }
  184. ]
  185. };
  186. };
  187. oop.inherits(RDocHighlightRules, TextHighlightRules);
  188. exports.RDocHighlightRules = RDocHighlightRules;
  189. });
  190. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  191. var Range = require("../range").Range;
  192. var MatchingBraceOutdent = function () { };
  193. (function () {
  194. this.checkOutdent = function (line, input) {
  195. if (!/^\s+$/.test(line))
  196. return false;
  197. return /^\s*\}/.test(input);
  198. };
  199. this.autoOutdent = function (doc, row) {
  200. var line = doc.getLine(row);
  201. var match = line.match(/^(\s*\})/);
  202. if (!match)
  203. return 0;
  204. var column = match[1].length;
  205. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  206. if (!openBracePos || openBracePos.row == row)
  207. return 0;
  208. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  209. doc.replace(new Range(row, 0, row, column - 1), indent);
  210. };
  211. this.$getIndent = function (line) {
  212. return line.match(/^\s*/)[0];
  213. };
  214. }).call(MatchingBraceOutdent.prototype);
  215. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  216. });
  217. ace.define("ace/mode/rdoc",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/rdoc_highlight_rules","ace/mode/matching_brace_outdent"], function(require, exports, module){/*
  218. * rdoc.js
  219. *
  220. * Copyright (C) 2009-11 by RStudio, Inc.
  221. *
  222. * The Initial Developer of the Original Code is
  223. * Ajax.org B.V.
  224. * Portions created by the Initial Developer are Copyright (C) 2010
  225. * the Initial Developer. All Rights Reserved.
  226. *
  227. * Distributed under the BSD license:
  228. *
  229. * Copyright (c) 2010, Ajax.org B.V.
  230. * All rights reserved.
  231. *
  232. * Redistribution and use in source and binary forms, with or without
  233. * modification, are permitted provided that the following conditions are met:
  234. * * Redistributions of source code must retain the above copyright
  235. * notice, this list of conditions and the following disclaimer.
  236. * * Redistributions in binary form must reproduce the above copyright
  237. * notice, this list of conditions and the following disclaimer in the
  238. * documentation and/or other materials provided with the distribution.
  239. * * Neither the name of Ajax.org B.V. nor the
  240. * names of its contributors may be used to endorse or promote products
  241. * derived from this software without specific prior written permission.
  242. *
  243. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  244. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  245. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  246. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  247. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  248. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  249. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  250. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  251. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  252. *
  253. */
  254. "use strict";
  255. var oop = require("../lib/oop");
  256. var TextMode = require("./text").Mode;
  257. var RDocHighlightRules = require("./rdoc_highlight_rules").RDocHighlightRules;
  258. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  259. var Mode = function (suppressHighlighting) {
  260. this.HighlightRules = RDocHighlightRules;
  261. this.$outdent = new MatchingBraceOutdent();
  262. this.$behaviour = this.$defaultBehaviour;
  263. };
  264. oop.inherits(Mode, TextMode);
  265. (function () {
  266. this.getNextLineIndent = function (state, line, tab) {
  267. return this.$getIndent(line);
  268. };
  269. this.$id = "ace/mode/rdoc";
  270. }).call(Mode.prototype);
  271. exports.Mode = Mode;
  272. }); (function() {
  273. ace.require(["ace/mode/rdoc"], function(m) {
  274. if (typeof module == "object" && typeof exports == "object" && module) {
  275. module.exports = m;
  276. }
  277. });
  278. })();