af7b012955996316a14afcf804c441e7.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. ace.define("ace/mode/tex_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module){/*
  2. * tex_highlight_rules.js
  3. *
  4. * Copyright (C) 2009-11 by RStudio, Inc.
  5. *
  6. * The Initial Developer of the Original Code is
  7. * Ajax.org B.V.
  8. * Portions created by the Initial Developer are Copyright (C) 2010
  9. * the Initial Developer. All Rights Reserved.
  10. *
  11. * Distributed under the BSD license:
  12. *
  13. * Copyright (c) 2010, Ajax.org B.V.
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted provided that the following conditions are met:
  18. * * Redistributions of source code must retain the above copyright
  19. * notice, this list of conditions and the following disclaimer.
  20. * * Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * * Neither the name of Ajax.org B.V. nor the
  24. * names of its contributors may be used to endorse or promote products
  25. * derived from this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  28. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  29. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  31. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  32. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  33. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  34. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  36. *
  37. */
  38. "use strict";
  39. var oop = require("../lib/oop");
  40. var lang = require("../lib/lang");
  41. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  42. var TexHighlightRules = function (textClass) {
  43. if (!textClass)
  44. textClass = "text";
  45. this.$rules = {
  46. "start": [
  47. {
  48. token: "comment",
  49. regex: "%.*$"
  50. }, {
  51. token: textClass,
  52. regex: "\\\\[$&%#\\{\\}]"
  53. }, {
  54. token: "keyword",
  55. regex: "\\\\(?:documentclass|usepackage|newcounter|setcounter|addtocounter|value|arabic|stepcounter|newenvironment|renewenvironment|ref|vref|eqref|pageref|label|cite[a-zA-Z]*|tag|begin|end|bibitem)\\b",
  56. next: "nospell"
  57. }, {
  58. token: "keyword",
  59. regex: "\\\\(?:[a-zA-Z0-9]+|[^a-zA-Z0-9])"
  60. }, {
  61. token: "paren.keyword.operator",
  62. regex: "[[({]"
  63. }, {
  64. token: "paren.keyword.operator",
  65. regex: "[\\])}]"
  66. }, {
  67. token: textClass,
  68. regex: "\\s+"
  69. }
  70. ],
  71. "nospell": [
  72. {
  73. token: "comment",
  74. regex: "%.*$",
  75. next: "start"
  76. }, {
  77. token: "nospell." + textClass,
  78. regex: "\\\\[$&%#\\{\\}]"
  79. }, {
  80. token: "keyword",
  81. regex: "\\\\(?:documentclass|usepackage|newcounter|setcounter|addtocounter|value|arabic|stepcounter|newenvironment|renewenvironment|ref|vref|eqref|pageref|label|cite[a-zA-Z]*|tag|begin|end|bibitem)\\b"
  82. }, {
  83. token: "keyword",
  84. regex: "\\\\(?:[a-zA-Z0-9]+|[^a-zA-Z0-9])",
  85. next: "start"
  86. }, {
  87. token: "paren.keyword.operator",
  88. regex: "[[({]"
  89. }, {
  90. token: "paren.keyword.operator",
  91. regex: "[\\])]"
  92. }, {
  93. token: "paren.keyword.operator",
  94. regex: "}",
  95. next: "start"
  96. }, {
  97. token: "nospell." + textClass,
  98. regex: "\\s+"
  99. }, {
  100. token: "nospell." + textClass,
  101. regex: "\\w+"
  102. }
  103. ]
  104. };
  105. };
  106. oop.inherits(TexHighlightRules, TextHighlightRules);
  107. exports.TexHighlightRules = TexHighlightRules;
  108. });
  109. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  110. var Range = require("../range").Range;
  111. var MatchingBraceOutdent = function () { };
  112. (function () {
  113. this.checkOutdent = function (line, input) {
  114. if (!/^\s+$/.test(line))
  115. return false;
  116. return /^\s*\}/.test(input);
  117. };
  118. this.autoOutdent = function (doc, row) {
  119. var line = doc.getLine(row);
  120. var match = line.match(/^(\s*\})/);
  121. if (!match)
  122. return 0;
  123. var column = match[1].length;
  124. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  125. if (!openBracePos || openBracePos.row == row)
  126. return 0;
  127. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  128. doc.replace(new Range(row, 0, row, column - 1), indent);
  129. };
  130. this.$getIndent = function (line) {
  131. return line.match(/^\s*/)[0];
  132. };
  133. }).call(MatchingBraceOutdent.prototype);
  134. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  135. });
  136. ace.define("ace/mode/tex",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/text_highlight_rules","ace/mode/tex_highlight_rules","ace/mode/matching_brace_outdent"], function(require, exports, module){/*
  137. * tex.js
  138. *
  139. * Copyright (C) 2009-11 by RStudio, Inc.
  140. *
  141. * The Initial Developer of the Original Code is
  142. * Ajax.org B.V.
  143. * Portions created by the Initial Developer are Copyright (C) 2010
  144. * the Initial Developer. All Rights Reserved.
  145. *
  146. * Distributed under the BSD license:
  147. *
  148. * Copyright (c) 2010, Ajax.org B.V.
  149. * All rights reserved.
  150. *
  151. * Redistribution and use in source and binary forms, with or without
  152. * modification, are permitted provided that the following conditions are met:
  153. * * Redistributions of source code must retain the above copyright
  154. * notice, this list of conditions and the following disclaimer.
  155. * * Redistributions in binary form must reproduce the above copyright
  156. * notice, this list of conditions and the following disclaimer in the
  157. * documentation and/or other materials provided with the distribution.
  158. * * Neither the name of Ajax.org B.V. nor the
  159. * names of its contributors may be used to endorse or promote products
  160. * derived from this software without specific prior written permission.
  161. *
  162. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  163. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  164. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  165. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  166. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  167. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  168. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  169. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  170. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  171. *
  172. */
  173. "use strict";
  174. var oop = require("../lib/oop");
  175. var TextMode = require("./text").Mode;
  176. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  177. var TexHighlightRules = require("./tex_highlight_rules").TexHighlightRules;
  178. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  179. var Mode = function (suppressHighlighting) {
  180. if (suppressHighlighting)
  181. this.HighlightRules = TextHighlightRules;
  182. else
  183. this.HighlightRules = TexHighlightRules;
  184. this.$outdent = new MatchingBraceOutdent();
  185. this.$behaviour = this.$defaultBehaviour;
  186. };
  187. oop.inherits(Mode, TextMode);
  188. (function () {
  189. this.lineCommentStart = "%";
  190. this.getNextLineIndent = function (state, line, tab) {
  191. return this.$getIndent(line);
  192. };
  193. this.allowAutoInsert = function () {
  194. return false;
  195. };
  196. this.$id = "ace/mode/tex";
  197. this.snippetFileId = "ace/snippets/tex";
  198. }).call(Mode.prototype);
  199. exports.Mode = Mode;
  200. }); (function() {
  201. ace.require(["ace/mode/tex"], function(m) {
  202. if (typeof module == "object" && typeof exports == "object" && module) {
  203. module.exports = m;
  204. }
  205. });
  206. })();