123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- ace.define("ace/mode/rst_highlight_rules",[], function(require, exports, module) {
- "use strict";
- var oop = require("../lib/oop");
- var lang = require("../lib/lang");
- var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
- var RSTHighlightRules = function() {
- var tokens = {
- title: "markup.heading",
- list: "markup.heading",
- table: "constant",
- directive: "keyword.operator",
- entity: "string",
- link: "markup.underline.list",
- bold: "markup.bold",
- italic: "markup.italic",
- literal: "support.function",
- comment: "comment"
- };
- var startStringPrefix = "(^|\\s|[\"'(<\\[{\\-/:])";
- var endStringSuffix = "(?:$|(?=\\s|[\\\\.,;!?\\-/:\"')>\\]}]))";
- this.$rules = {
- "start": [
- {
- token : tokens.title,
- regex : "(^)([\\=\\-`:\\.'\"~\\^_\\*\\+#])(\\2{2,}\\s*$)"
- },
- {
- token : ["text", tokens.directive, tokens.literal],
- regex : "(^\\s*\\.\\. )([^: ]+::)(.*$)",
- next : "codeblock"
- },
- {
- token : tokens.directive,
- regex : "::$",
- next : "codeblock"
- },
- {
- token : [tokens.entity, tokens.link],
- regex : "(^\\.\\. _[^:]+:)(.*$)"
- },
- {
- token : [tokens.entity, tokens.link],
- regex : "(^__ )(https?://.*$)"
- },
- {
- token : tokens.entity,
- regex : "^\\.\\. \\[[^\\]]+\\] "
- },
- {
- token : tokens.comment,
- regex : "^\\.\\. .*$",
- next : "comment"
- },
- {
- token : tokens.list,
- regex : "^\\s*[\\*\\+-] "
- },
- {
- token : tokens.list,
- regex : "^\\s*(?:[A-Za-z]|[0-9]+|[ivxlcdmIVXLCDM]+)\\. "
- },
- {
- token : tokens.list,
- regex : "^\\s*\\(?(?:[A-Za-z]|[0-9]+|[ivxlcdmIVXLCDM]+)\\) "
- },
- {
- token : tokens.table,
- regex : "^={2,}(?: +={2,})+$"
- },
- {
- token : tokens.table,
- regex : "^\\+-{2,}(?:\\+-{2,})+\\+$"
- },
- {
- token : tokens.table,
- regex : "^\\+={2,}(?:\\+={2,})+\\+$"
- },
- {
- token : ["text", tokens.literal],
- regex : startStringPrefix + "(``)(?=\\S)",
- next : "code"
- },
- {
- token : ["text", tokens.bold],
- regex : startStringPrefix + "(\\*\\*)(?=\\S)",
- next : "bold"
- },
- {
- token : ["text", tokens.italic],
- regex : startStringPrefix + "(\\*)(?=\\S)",
- next : "italic"
- },
- {
- token : tokens.entity,
- regex : "\\|[\\w\\-]+?\\|"
- },
- {
- token : tokens.entity,
- regex : ":[\\w-:]+:`\\S",
- next : "entity"
- },
- {
- token : ["text", tokens.entity],
- regex : startStringPrefix + "(_`)(?=\\S)",
- next : "entity"
- },
- {
- token : tokens.entity,
- regex : "_[A-Za-z0-9\\-]+?"
- },
- {
- token : ["text", tokens.link],
- regex : startStringPrefix + "(`)(?=\\S)",
- next : "link"
- },
- {
- token : tokens.link,
- regex : "[A-Za-z0-9\\-]+?__?"
- },
- {
- token : tokens.link,
- regex : "\\[[^\\]]+?\\]_"
- },
- {
- token : tokens.link,
- regex : "https?://\\S+"
- },
- {
- token : tokens.table,
- regex : "\\|"
- }
- ],
- "codeblock": [
- {
- token : tokens.literal,
- regex : "^ +.+$",
- next : "codeblock"
- },
- {
- token : tokens.literal,
- regex : '^$',
- next: "codeblock"
- },
- {
- token : "empty",
- regex : "",
- next : "start"
- }
- ],
- "code": [
- {
- token : tokens.literal,
- regex : "\\S``" + endStringSuffix,
- next : "start"
- },
- {
- defaultToken: tokens.literal
- }
- ],
- "bold": [
- {
- token : tokens.bold,
- regex : "\\S\\*\\*" + endStringSuffix,
- next : "start"
- },
- {
- defaultToken: tokens.bold
- }
- ],
- "italic": [
- {
- token : tokens.italic,
- regex : "\\S\\*" + endStringSuffix,
- next : "start"
- },
- {
- defaultToken: tokens.italic
- }
- ],
- "entity": [
- {
- token : tokens.entity,
- regex : "\\S`" + endStringSuffix,
- next : "start"
- },
- {
- defaultToken: tokens.entity
- }
- ],
- "link": [
- {
- token : tokens.link,
- regex : "\\S`__?" + endStringSuffix,
- next : "start"
- },
- {
- defaultToken: tokens.link
- }
- ],
- "comment": [
- {
- token : tokens.comment,
- regex : "^ +.+$",
- next : "comment"
- },
- {
- token : tokens.comment,
- regex : '^$',
- next: "comment"
- },
- {
- token : "empty",
- regex : "",
- next : "start"
- }
- ]
- };
- };
- oop.inherits(RSTHighlightRules, TextHighlightRules);
- exports.RSTHighlightRules = RSTHighlightRules;
- });
- ace.define("ace/mode/rst",[], function(require, exports, module) {
- "use strict";
- var oop = require("../lib/oop");
- var TextMode = require("./text").Mode;
- var RSTHighlightRules = require("./rst_highlight_rules").RSTHighlightRules;
- var Mode = function() {
- this.HighlightRules = RSTHighlightRules;
- };
- oop.inherits(Mode, TextMode);
- (function() {
- this.type = "text";
- this.$id = "ace/mode/rst";
- }).call(Mode.prototype);
- exports.Mode = Mode;
- });
- (function() {
- ace.require(["ace/mode/rst"], function(m) {
- if (typeof module == "object" && typeof exports == "object" && module) {
- module.exports = m;
- }
- });
- })();
-
|