mode-textile.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. ace.define("ace/mode/textile_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var TextileHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [
  8. {
  9. token : function(value) {
  10. if (value.charAt(0) == "h")
  11. return "markup.heading." + value.charAt(1);
  12. else
  13. return "markup.heading";
  14. },
  15. regex : "h1|h2|h3|h4|h5|h6|bq|p|bc|pre",
  16. next : "blocktag"
  17. },
  18. {
  19. token : "keyword",
  20. regex : "[\\*]+|[#]+"
  21. },
  22. {
  23. token : "text",
  24. regex : ".+"
  25. }
  26. ],
  27. "blocktag" : [
  28. {
  29. token : "keyword",
  30. regex : "\\. ",
  31. next : "start"
  32. },
  33. {
  34. token : "keyword",
  35. regex : "\\(",
  36. next : "blocktagproperties"
  37. }
  38. ],
  39. "blocktagproperties" : [
  40. {
  41. token : "keyword",
  42. regex : "\\)",
  43. next : "blocktag"
  44. },
  45. {
  46. token : "string",
  47. regex : "[a-zA-Z0-9\\-_]+"
  48. },
  49. {
  50. token : "keyword",
  51. regex : "#"
  52. }
  53. ]
  54. };
  55. };
  56. oop.inherits(TextileHighlightRules, TextHighlightRules);
  57. exports.TextileHighlightRules = TextileHighlightRules;
  58. });
  59. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  60. "use strict";
  61. var Range = require("../range").Range;
  62. var MatchingBraceOutdent = function() {};
  63. (function() {
  64. this.checkOutdent = function(line, input) {
  65. if (! /^\s+$/.test(line))
  66. return false;
  67. return /^\s*\}/.test(input);
  68. };
  69. this.autoOutdent = function(doc, row) {
  70. var line = doc.getLine(row);
  71. var match = line.match(/^(\s*\})/);
  72. if (!match) return 0;
  73. var column = match[1].length;
  74. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  75. if (!openBracePos || openBracePos.row == row) return 0;
  76. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  77. doc.replace(new Range(row, 0, row, column-1), indent);
  78. };
  79. this.$getIndent = function(line) {
  80. return line.match(/^\s*/)[0];
  81. };
  82. }).call(MatchingBraceOutdent.prototype);
  83. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  84. });
  85. ace.define("ace/mode/textile",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/textile_highlight_rules","ace/mode/matching_brace_outdent"], function(require, exports, module) {
  86. "use strict";
  87. var oop = require("../lib/oop");
  88. var TextMode = require("./text").Mode;
  89. var TextileHighlightRules = require("./textile_highlight_rules").TextileHighlightRules;
  90. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  91. var Mode = function() {
  92. this.HighlightRules = TextileHighlightRules;
  93. this.$outdent = new MatchingBraceOutdent();
  94. this.$behaviour = this.$defaultBehaviour;
  95. };
  96. oop.inherits(Mode, TextMode);
  97. (function() {
  98. this.type = "text";
  99. this.getNextLineIndent = function(state, line, tab) {
  100. if (state == "intag")
  101. return tab;
  102. return "";
  103. };
  104. this.checkOutdent = function(state, line, input) {
  105. return this.$outdent.checkOutdent(line, input);
  106. };
  107. this.autoOutdent = function(state, doc, row) {
  108. this.$outdent.autoOutdent(doc, row);
  109. };
  110. this.$id = "ace/mode/textile";
  111. }).call(Mode.prototype);
  112. exports.Mode = Mode;
  113. });