diff --git a/lib/ace/mode/_test/tokens_php.json b/lib/ace/mode/_test/tokens_php.json index 13dfbea4..8de22fe6 100644 --- a/lib/ace/mode/_test/tokens_php.json +++ b/lib/ace/mode/_test/tokens_php.json @@ -1,6 +1,6 @@ [ { - "state": "start", + "state": "php-start", "values": [ "" - }, - { - token : "comment", - regex : "<\\!--", - next : "htmlcomment" - }, - { - token : "meta.tag", - regex : "' - }, { token : "comment", regex : "\\/\\/.*$" @@ -1063,103 +1037,39 @@ var PhpHighlightRules = function() { token : "string", regex : ".+?" } - ], - "htmlcomment" : [ - { - token : "comment", - regex : ".*?-->", - next : "start" - }, { - token : "comment", - regex : ".+" - } - ], - "htmltag" : [ - { - token : "meta.tag", - regex : ">", - next : "start" - }, { - token : "text", - regex : "[-_a-zA-Z0-9:]+" - }, { - token : "text", - regex : "\\s+" - }, { - token : "string", - regex : '".*?"' - }, { - token : "string", - regex : "'.*?'" - } - ], - "css" : [ - { - token : "meta.tag", - regex : "<\/style>", - next : "htmltag" - }, { - token : "meta.tag", - regex : ">" - }, { - token : 'text', - regex : "(?:media|type|href)" - }, { - token : 'string', - regex : '=".*?"' - }, { - token : "paren.lparen", - regex : "\{", - next : "cssdeclaration" - }, { - token : "keyword", - regex : "#[A-Za-z0-9\-\_\.]+" - }, { - token : "variable", - regex : "\\.[A-Za-z0-9\-\_\.]+" - }, { - token : "constant", - regex : "[A-Za-z0-9]+" - } - ], - "cssdeclaration" : [ - { - token : "support.type", - regex : "[\-a-zA-Z]+", - next : "cssvalue" - }, - { - token : "paren.rparen", - regex : '\}', - next : "css" - } - ], - "cssvalue" : [ - { - token : "text", - regex : "\:" - }, - { - token : "constant", - regex : "#[0-9a-zA-Z]+" - }, - { - token : "text", - regex : "[\-\_0-9a-zA-Z\"' ,%]+" - }, - { - token : "text", - regex : ";", - next : "cssdeclaration" - } - ] + ] }; this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]); }; +oop.inherits(PhpLangHighlightRules, TextHighlightRules); + + +var PhpHighlightRules = function() { + this.$rules = new HtmlHighlightRules().getRules(); + + for (var i in this.$rules) { + this.$rules[i].unshift({ + token : "support.php_tag", // php open tag + regex : "<\\?(?:php|\\=)", + next : "php-start" + }); + } + + this.embedRules(PhpLangHighlightRules, "php-"); + + this.$rules["php-start"].unshift({ + token : "support.php_tag", // php close tag + regex : "\\?>", + next : "start" + }); +}; + oop.inherits(PhpHighlightRules, TextHighlightRules); + + exports.PhpHighlightRules = PhpHighlightRules; });