add css and js highlighting to php mode

This commit is contained in:
nightwing 2012-08-31 19:27:52 +04:00
commit c4716740c2
2 changed files with 46 additions and 136 deletions

View file

@ -1,6 +1,6 @@
[
{
"state": "start",
"state": "php-start",
"values": [
"<?php"
],
@ -9,12 +9,12 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [],
"types": []
},
{
"state": "start",
"state": "php-start",
"values": [
"function",
" ",
@ -37,7 +37,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [
" ",
"if",
@ -68,7 +68,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [
" ",
"return",
@ -85,7 +85,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [
" ",
"}"
@ -96,7 +96,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [
" ",
"else",
@ -111,7 +111,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [
" ",
"return",
@ -150,7 +150,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [
" ",
"}"
@ -161,7 +161,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [
"}"
],
@ -170,12 +170,12 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [],
"types": []
},
{
"state": "start",
"state": "php-start",
"values": [
"echo",
" ",
@ -260,7 +260,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [
"$num",
" ",
@ -291,12 +291,12 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [],
"types": []
},
{
"state": "start",
"state": "php-start",
"values": [
"// ===== PROCESS - Determing the factorial of the input number ====="
],
@ -305,7 +305,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [
"$output",
" ",
@ -386,7 +386,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [
"echo",
" ",
@ -401,7 +401,7 @@
]
},
{
"state": "start",
"state": "php-start",
"values": [],
"types": []
},

View file

@ -43,8 +43,9 @@ var oop = require("../lib/oop");
var lang = require("../lib/lang");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
var PhpHighlightRules = function() {
var PhpLangHighlightRules = function() {
var docComment = DocCommentHighlightRules;
// http://php.net/quickref.php
var builtinFunctions = lang.arrayToMap(
@ -904,33 +905,6 @@ var PhpHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "support.php_tag", // php open tag
regex : "<\\?(?:php|\\=)"
},
{
token : "support.php_tag", // php close tag
regex : "\\?>"
},
{
token : "comment",
regex : "<\\!--",
next : "htmlcomment"
},
{
token : "meta.tag",
regex : "<style",
next : "css"
},
{
token : "meta.tag", // opening tag
regex : "<\\/?[-_a-zA-Z0-9:]+",
next : "htmltag"
},
{
token : 'meta.tag',
regex : '<\!DOCTYPE.*?>'
},
{
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;
});