rhtml_highlight_rules.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * rhtml_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. * This program is licensed to you under the terms of version 3 of the
  12. * GNU Affero General Public License. This program is distributed WITHOUT
  13. * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
  14. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
  15. * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
  16. *
  17. */
  18. define(function(require, exports, module) {
  19. "use strict";
  20. var oop = require("../lib/oop");
  21. var RHighlightRules = require("./r_highlight_rules").RHighlightRules;
  22. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  23. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  24. var RHtmlHighlightRules = function() {
  25. HtmlHighlightRules.call(this);
  26. this.$rules["start"].unshift({
  27. token: "support.function.codebegin",
  28. regex: "^<" + "!--\\s*begin.rcode\\s*(?:.*)",
  29. next: "r-start"
  30. });
  31. this.embedRules(RHighlightRules, "r-", [{
  32. token: "support.function.codeend",
  33. regex: "^\\s*end.rcode\\s*-->",
  34. next: "start"
  35. }], ["start"]);
  36. this.normalizeRules();
  37. };
  38. oop.inherits(RHtmlHighlightRules, TextHighlightRules);
  39. exports.RHtmlHighlightRules = RHtmlHighlightRules;
  40. });