mode-rdoc.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. define("ace/mode/latex_highlight_rules",["ace_require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(ace_require, exports, module) {
  2. "use strict";
  3. var oop = ace_require("../lib/oop");
  4. var TextHighlightRules = ace_require("./text_highlight_rules").TextHighlightRules;
  5. var LatexHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [{
  8. token : "comment",
  9. regex : "%.*$"
  10. }, {
  11. token : ["keyword", "lparen", "variable.parameter", "rparen", "lparen", "storage.type", "rparen"],
  12. regex : "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)([^}]*)(})"
  13. }, {
  14. token : ["keyword","lparen", "variable.parameter", "rparen"],
  15. regex : "(\\\\(?:label|v?ref|cite(?:[^{]*)))(?:({)([^}]*)(}))?"
  16. }, {
  17. token : ["storage.type", "lparen", "variable.parameter", "rparen"],
  18. regex : "(\\\\begin)({)(verbatim)(})",
  19. next : "verbatim"
  20. }, {
  21. token : ["storage.type", "lparen", "variable.parameter", "rparen"],
  22. regex : "(\\\\begin)({)(lstlisting)(})",
  23. next : "lstlisting"
  24. }, {
  25. token : ["storage.type", "lparen", "variable.parameter", "rparen"],
  26. regex : "(\\\\(?:begin|end))({)([\\w*]*)(})"
  27. }, {
  28. token : "storage.type",
  29. regex : /\\verb\b\*?/,
  30. next : [{
  31. token : ["keyword.operator", "string", "keyword.operator"],
  32. regex : "(.)(.*?)(\\1|$)|",
  33. next : "start"
  34. }]
  35. }, {
  36. token : "storage.type",
  37. regex : "\\\\[a-zA-Z]+"
  38. }, {
  39. token : "lparen",
  40. regex : "[[({]"
  41. }, {
  42. token : "rparen",
  43. regex : "[\\])}]"
  44. }, {
  45. token : "constant.character.escape",
  46. regex : "\\\\[^a-zA-Z]?"
  47. }, {
  48. token : "string",
  49. regex : "\\${1,2}",
  50. next : "equation"
  51. }],
  52. "equation" : [{
  53. token : "comment",
  54. regex : "%.*$"
  55. }, {
  56. token : "string",
  57. regex : "\\${1,2}",
  58. next : "start"
  59. }, {
  60. token : "constant.character.escape",
  61. regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
  62. }, {
  63. token : "error",
  64. regex : "^\\s*$",
  65. next : "start"
  66. }, {
  67. defaultToken : "string"
  68. }],
  69. "verbatim": [{
  70. token : ["storage.type", "lparen", "variable.parameter", "rparen"],
  71. regex : "(\\\\end)({)(verbatim)(})",
  72. next : "start"
  73. }, {
  74. defaultToken : "text"
  75. }],
  76. "lstlisting": [{
  77. token : ["storage.type", "lparen", "variable.parameter", "rparen"],
  78. regex : "(\\\\end)({)(lstlisting)(})",
  79. next : "start"
  80. }, {
  81. defaultToken : "text"
  82. }]
  83. };
  84. this.normalizeRules();
  85. };
  86. oop.inherits(LatexHighlightRules, TextHighlightRules);
  87. exports.LatexHighlightRules = LatexHighlightRules;
  88. });
  89. define("ace/mode/rdoc_highlight_rules",["ace_require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules","ace/mode/latex_highlight_rules"], function(ace_require, exports, module) {
  90. "use strict";
  91. var oop = ace_require("../lib/oop");
  92. var lang = ace_require("../lib/lang");
  93. var TextHighlightRules = ace_require("./text_highlight_rules").TextHighlightRules;
  94. var LaTeXHighlightRules = ace_require("./latex_highlight_rules");
  95. var RDocHighlightRules = function() {
  96. this.$rules = {
  97. "start" : [
  98. {
  99. token : "comment",
  100. regex : "%.*$"
  101. }, {
  102. token : "text", // non-command
  103. regex : "\\\\[$&%#\\{\\}]"
  104. }, {
  105. token : "keyword", // command
  106. 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",
  107. next : "nospell"
  108. }, {
  109. token : "keyword", // command
  110. regex : "\\\\(?:[a-zA-Z0-9]+|[^a-zA-Z0-9])"
  111. }, {
  112. token : "paren.keyword.operator",
  113. regex : "[[({]"
  114. }, {
  115. token : "paren.keyword.operator",
  116. regex : "[\\])}]"
  117. }, {
  118. token : "text",
  119. regex : "\\s+"
  120. }
  121. ],
  122. "nospell" : [
  123. {
  124. token : "comment",
  125. regex : "%.*$",
  126. next : "start"
  127. }, {
  128. token : "nospell.text", // non-command
  129. regex : "\\\\[$&%#\\{\\}]"
  130. }, {
  131. token : "keyword", // command
  132. 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"
  133. }, {
  134. token : "keyword", // command
  135. regex : "\\\\(?:[a-zA-Z0-9]+|[^a-zA-Z0-9])",
  136. next : "start"
  137. }, {
  138. token : "paren.keyword.operator",
  139. regex : "[[({]"
  140. }, {
  141. token : "paren.keyword.operator",
  142. regex : "[\\])]"
  143. }, {
  144. token : "paren.keyword.operator",
  145. regex : "}",
  146. next : "start"
  147. }, {
  148. token : "nospell.text",
  149. regex : "\\s+"
  150. }, {
  151. token : "nospell.text",
  152. regex : "\\w+"
  153. }
  154. ]
  155. };
  156. };
  157. oop.inherits(RDocHighlightRules, TextHighlightRules);
  158. exports.RDocHighlightRules = RDocHighlightRules;
  159. });
  160. define("ace/mode/matching_brace_outdent",["ace_require","exports","module","ace/range"], function(ace_require, exports, module) {
  161. "use strict";
  162. var Range = ace_require("../range").Range;
  163. var MatchingBraceOutdent = function() {};
  164. (function() {
  165. this.checkOutdent = function(line, input) {
  166. if (! /^\s+$/.test(line))
  167. return false;
  168. return /^\s*\}/.test(input);
  169. };
  170. this.autoOutdent = function(doc, row) {
  171. var line = doc.getLine(row);
  172. var match = line.match(/^(\s*\})/);
  173. if (!match) return 0;
  174. var column = match[1].length;
  175. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  176. if (!openBracePos || openBracePos.row == row) return 0;
  177. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  178. doc.replace(new Range(row, 0, row, column-1), indent);
  179. };
  180. this.$getIndent = function(line) {
  181. return line.match(/^\s*/)[0];
  182. };
  183. }).call(MatchingBraceOutdent.prototype);
  184. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  185. });
  186. define("ace/mode/rdoc",["ace_require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/rdoc_highlight_rules","ace/mode/matching_brace_outdent"], function(ace_require, exports, module) {
  187. "use strict";
  188. var oop = ace_require("../lib/oop");
  189. var TextMode = ace_require("./text").Mode;
  190. var RDocHighlightRules = ace_require("./rdoc_highlight_rules").RDocHighlightRules;
  191. var MatchingBraceOutdent = ace_require("./matching_brace_outdent").MatchingBraceOutdent;
  192. var Mode = function(suppressHighlighting) {
  193. this.HighlightRules = RDocHighlightRules;
  194. this.$outdent = new MatchingBraceOutdent();
  195. this.$behaviour = this.$defaultBehaviour;
  196. };
  197. oop.inherits(Mode, TextMode);
  198. (function() {
  199. this.getNextLineIndent = function(state, line, tab) {
  200. return this.$getIndent(line);
  201. };
  202. this.$id = "ace/mode/rdoc";
  203. }).call(Mode.prototype);
  204. exports.Mode = Mode;
  205. }); (function() {
  206. window.ace_require(["ace/mode/rdoc"], function(m) {
  207. if (typeof module == "object" && typeof exports == "object" && module) {
  208. module.exports = m;
  209. }
  210. });
  211. })();