mode-textile-uncompressed.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is Ajax.org Code Editor (ACE).
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Ajax.org B.V.
  18. * Portions created by the Initial Developer are Copyright (C) 2010
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. * Kelley van Evert <kelley.vanevert@gmail.com>
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. define('ace/mode/textile', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/textile_highlight_rules', 'ace/mode/matching_brace_outdent'], function(require, exports, module) {
  38. "use strict";
  39. var oop = require("../lib/oop");
  40. var TextMode = require("./text").Mode;
  41. var Tokenizer = require("../tokenizer").Tokenizer;
  42. var TextileHighlightRules = require("./textile_highlight_rules").TextileHighlightRules;
  43. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  44. var Mode = function() {
  45. this.$tokenizer = new Tokenizer(new TextileHighlightRules().getRules());
  46. this.$outdent = new MatchingBraceOutdent();
  47. };
  48. oop.inherits(Mode, TextMode);
  49. (function() {
  50. this.getNextLineIndent = function(state, line, tab) {
  51. if (state == "intag")
  52. return tab;
  53. return "";
  54. };
  55. this.checkOutdent = function(state, line, input) {
  56. return this.$outdent.checkOutdent(line, input);
  57. };
  58. this.autoOutdent = function(state, doc, row) {
  59. this.$outdent.autoOutdent(doc, row);
  60. };
  61. }).call(Mode.prototype);
  62. exports.Mode = Mode;
  63. });
  64. /* ***** BEGIN LICENSE BLOCK *****
  65. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  66. *
  67. * The contents of this file are subject to the Mozilla Public License Version
  68. * 1.1 (the "License"); you may not use this file except in compliance with
  69. * the License. You may obtain a copy of the License at
  70. * http://www.mozilla.org/MPL/
  71. *
  72. * Software distributed under the License is distributed on an "AS IS" basis,
  73. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  74. * for the specific language governing rights and limitations under the
  75. * License.
  76. *
  77. * The Original Code is Ajax.org Code Editor (ACE).
  78. *
  79. * The Initial Developer of the Original Code is
  80. * Ajax.org B.V.
  81. * Portions created by the Initial Developer are Copyright (C) 2010
  82. * the Initial Developer. All Rights Reserved.
  83. *
  84. * Contributor(s):
  85. * Kelley van Evert <kelley.vanevert@gmail.com>
  86. *
  87. * Alternatively, the contents of this file may be used under the terms of
  88. * either the GNU General Public License Version 2 or later (the "GPL"), or
  89. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  90. * in which case the provisions of the GPL or the LGPL are applicable instead
  91. * of those above. If you wish to allow use of your version of this file only
  92. * under the terms of either the GPL or the LGPL, and not to allow others to
  93. * use your version of this file under the terms of the MPL, indicate your
  94. * decision by deleting the provisions above and replace them with the notice
  95. * and other provisions required by the GPL or the LGPL. If you do not delete
  96. * the provisions above, a recipient may use your version of this file under
  97. * the terms of any one of the MPL, the GPL or the LGPL.
  98. *
  99. * ***** END LICENSE BLOCK ***** */
  100. define('ace/mode/textile_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  101. "use strict";
  102. var oop = require("../lib/oop");
  103. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  104. var TextileHighlightRules = function() {
  105. this.$rules = {
  106. "start" : [
  107. {
  108. token : function(value) {
  109. if (value.match(/^h\d$/))
  110. return "markup.heading." + value.charAt(1);
  111. else
  112. return "markup.heading";
  113. },
  114. regex : "h1|h2|h3|h4|h5|h6|bq|p|bc|pre",
  115. next : "blocktag"
  116. },
  117. {
  118. token : "keyword",
  119. regex : "[\\*]+|[#]+"
  120. },
  121. {
  122. token : "text",
  123. regex : ".+"
  124. }
  125. ],
  126. "blocktag" : [
  127. {
  128. token : "keyword",
  129. regex : "\\. ",
  130. next : "start"
  131. },
  132. {
  133. token : "keyword",
  134. regex : "\\(",
  135. next : "blocktagproperties"
  136. }
  137. ],
  138. "blocktagproperties" : [
  139. {
  140. token : "keyword",
  141. regex : "\\)",
  142. next : "blocktag"
  143. },
  144. {
  145. token : "string",
  146. regex : "[a-zA-Z0-9\\-_]+"
  147. },
  148. {
  149. token : "keyword",
  150. regex : "#"
  151. }
  152. ]
  153. };
  154. };
  155. oop.inherits(TextileHighlightRules, TextHighlightRules);
  156. exports.TextileHighlightRules = TextileHighlightRules;
  157. });
  158. /* ***** BEGIN LICENSE BLOCK *****
  159. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  160. *
  161. * The contents of this file are subject to the Mozilla Public License Version
  162. * 1.1 (the "License"); you may not use this file except in compliance with
  163. * the License. You may obtain a copy of the License at
  164. * http://www.mozilla.org/MPL/
  165. *
  166. * Software distributed under the License is distributed on an "AS IS" basis,
  167. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  168. * for the specific language governing rights and limitations under the
  169. * License.
  170. *
  171. * The Original Code is Ajax.org Code Editor (ACE).
  172. *
  173. * The Initial Developer of the Original Code is
  174. * Ajax.org B.V.
  175. * Portions created by the Initial Developer are Copyright (C) 2010
  176. * the Initial Developer. All Rights Reserved.
  177. *
  178. * Contributor(s):
  179. * Fabian Jakobs <fabian AT ajax DOT org>
  180. *
  181. * Alternatively, the contents of this file may be used under the terms of
  182. * either the GNU General Public License Version 2 or later (the "GPL"), or
  183. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  184. * in which case the provisions of the GPL or the LGPL are applicable instead
  185. * of those above. If you wish to allow use of your version of this file only
  186. * under the terms of either the GPL or the LGPL, and not to allow others to
  187. * use your version of this file under the terms of the MPL, indicate your
  188. * decision by deleting the provisions above and replace them with the notice
  189. * and other provisions required by the GPL or the LGPL. If you do not delete
  190. * the provisions above, a recipient may use your version of this file under
  191. * the terms of any one of the MPL, the GPL or the LGPL.
  192. *
  193. * ***** END LICENSE BLOCK ***** */
  194. define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  195. "use strict";
  196. var Range = require("../range").Range;
  197. var MatchingBraceOutdent = function() {};
  198. (function() {
  199. this.checkOutdent = function(line, input) {
  200. if (! /^\s+$/.test(line))
  201. return false;
  202. return /^\s*\}/.test(input);
  203. };
  204. this.autoOutdent = function(doc, row) {
  205. var line = doc.getLine(row);
  206. var match = line.match(/^(\s*\})/);
  207. if (!match) return 0;
  208. var column = match[1].length;
  209. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  210. if (!openBracePos || openBracePos.row == row) return 0;
  211. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  212. doc.replace(new Range(row, 0, row, column-1), indent);
  213. };
  214. this.$getIndent = function(line) {
  215. var match = line.match(/^(\s+)/);
  216. if (match) {
  217. return match[1];
  218. }
  219. return "";
  220. };
  221. }).call(MatchingBraceOutdent.prototype);
  222. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  223. });