fix #1241 PHP highlighting of closing tag in comment

This commit is contained in:
nightwing 2013-02-11 18:58:04 +04:00
commit 6001ba815c
3 changed files with 25 additions and 20 deletions

View file

@ -899,11 +899,7 @@ var PhpLangHighlightRules = function() {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
{
token : "comment",
regex : "#.*$"
regex : /(?:#|\/\/)(?:[^?]|\?[^>])*/
},
docComment.getStartRule("doc-start"),
{
@ -1059,7 +1055,7 @@ var PhpHighlightRules = function() {
this.$rules[i].unshift({
token : "support.php_tag", // php open tag
regex : "<\\?(?:php|=)?",
next : {push: "php-start"}
push : "php-start"
});
}

View file

@ -3,7 +3,7 @@
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
@ -14,7 +14,7 @@
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@ -77,7 +77,7 @@ var TextHighlightRules = function() {
for (var key in embedRules)
states.push(prefix + key);
}
this.addRules(embedRules, prefix);
if (escapeRules) {
@ -94,7 +94,7 @@ var TextHighlightRules = function() {
this.getEmbeds = function() {
return this.$embeds;
};
var pushState = function(currentState, stack) {
if (currentState != "start")
stack.unshift(this.nextState, currentState);
@ -124,22 +124,27 @@ var TextHighlightRules = function() {
}, {
token: rule.token + ".end",
regex: rule.end || rule.start,
next: key
next: "pop"
});
rule.token = rule.token + ".start";
rule.push = true;
}
if (rule.next && Array.isArray(rule.next)) {
var next = rule.next || rule.push;
if (next && Array.isArray(next)) {
var stateName = rule.stateName || (rule.token + id++);
rules[stateName] = rule.next;
rules[stateName] = next;
rule.next = stateName;
processState(stateName);
} else if (rule.next && typeof rule.next == "object") {
var next = rule.next;
rule.nextState = next.push;
rule.next = pushState;
} else if (rule.next == "pop") {
} else if (next == "pop") {
rule.next = popState;
}
if (rule.push) {
rule.nextState = rule.next || rule.push;
rule.next = pushState;
delete rule.push;
}
if (rule.rules) {
for (var r in rule.rules) {
if (rules[r]) {
@ -152,7 +157,7 @@ var TextHighlightRules = function() {
}
if (rule.include || typeof rule == "string") {
var includeName = rule.include || rule;
var toInsert = rules[includeName];
var toInsert = rules[includeName];
} else if (Array.isArray(rule))
toInsert = rule;

View file

@ -208,7 +208,11 @@ var Tokenizer = function(rules) {
: rule.token;
if (rule.next) {
currentState = rule.next;
if (typeof rule.next == "string")
currentState = rule.next;
else
currentState = rule.next(currentState, stack);
state = this.states[currentState];
if (!state) {
window.console && console.error && console.error(currentState, "doesn't exist");