fix #1241 PHP highlighting of closing tag in comment
This commit is contained in:
parent
c83f48b371
commit
6001ba815c
3 changed files with 25 additions and 20 deletions
|
|
@ -899,11 +899,7 @@ var PhpLangHighlightRules = function() {
|
||||||
"start" : [
|
"start" : [
|
||||||
{
|
{
|
||||||
token : "comment",
|
token : "comment",
|
||||||
regex : "\\/\\/.*$"
|
regex : /(?:#|\/\/)(?:[^?]|\?[^>])*/
|
||||||
},
|
|
||||||
{
|
|
||||||
token : "comment",
|
|
||||||
regex : "#.*$"
|
|
||||||
},
|
},
|
||||||
docComment.getStartRule("doc-start"),
|
docComment.getStartRule("doc-start"),
|
||||||
{
|
{
|
||||||
|
|
@ -1059,7 +1055,7 @@ var PhpHighlightRules = function() {
|
||||||
this.$rules[i].unshift({
|
this.$rules[i].unshift({
|
||||||
token : "support.php_tag", // php open tag
|
token : "support.php_tag", // php open tag
|
||||||
regex : "<\\?(?:php|=)?",
|
regex : "<\\?(?:php|=)?",
|
||||||
next : {push: "php-start"}
|
push : "php-start"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
* Copyright (c) 2010, Ajax.org B.V.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
* * Neither the name of Ajax.org B.V. nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* 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
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
|
@ -77,7 +77,7 @@ var TextHighlightRules = function() {
|
||||||
for (var key in embedRules)
|
for (var key in embedRules)
|
||||||
states.push(prefix + key);
|
states.push(prefix + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addRules(embedRules, prefix);
|
this.addRules(embedRules, prefix);
|
||||||
|
|
||||||
if (escapeRules) {
|
if (escapeRules) {
|
||||||
|
|
@ -94,7 +94,7 @@ var TextHighlightRules = function() {
|
||||||
this.getEmbeds = function() {
|
this.getEmbeds = function() {
|
||||||
return this.$embeds;
|
return this.$embeds;
|
||||||
};
|
};
|
||||||
|
|
||||||
var pushState = function(currentState, stack) {
|
var pushState = function(currentState, stack) {
|
||||||
if (currentState != "start")
|
if (currentState != "start")
|
||||||
stack.unshift(this.nextState, currentState);
|
stack.unshift(this.nextState, currentState);
|
||||||
|
|
@ -124,22 +124,27 @@ var TextHighlightRules = function() {
|
||||||
}, {
|
}, {
|
||||||
token: rule.token + ".end",
|
token: rule.token + ".end",
|
||||||
regex: rule.end || rule.start,
|
regex: rule.end || rule.start,
|
||||||
next: key
|
next: "pop"
|
||||||
});
|
});
|
||||||
rule.token = rule.token + ".start";
|
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++);
|
var stateName = rule.stateName || (rule.token + id++);
|
||||||
rules[stateName] = rule.next;
|
rules[stateName] = next;
|
||||||
rule.next = stateName;
|
rule.next = stateName;
|
||||||
processState(stateName);
|
processState(stateName);
|
||||||
} else if (rule.next && typeof rule.next == "object") {
|
} else if (next == "pop") {
|
||||||
var next = rule.next;
|
|
||||||
rule.nextState = next.push;
|
|
||||||
rule.next = pushState;
|
|
||||||
} else if (rule.next == "pop") {
|
|
||||||
rule.next = popState;
|
rule.next = popState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rule.push) {
|
||||||
|
rule.nextState = rule.next || rule.push;
|
||||||
|
rule.next = pushState;
|
||||||
|
delete rule.push;
|
||||||
|
}
|
||||||
|
|
||||||
if (rule.rules) {
|
if (rule.rules) {
|
||||||
for (var r in rule.rules) {
|
for (var r in rule.rules) {
|
||||||
if (rules[r]) {
|
if (rules[r]) {
|
||||||
|
|
@ -152,7 +157,7 @@ var TextHighlightRules = function() {
|
||||||
}
|
}
|
||||||
if (rule.include || typeof rule == "string") {
|
if (rule.include || typeof rule == "string") {
|
||||||
var includeName = rule.include || rule;
|
var includeName = rule.include || rule;
|
||||||
var toInsert = rules[includeName];
|
var toInsert = rules[includeName];
|
||||||
} else if (Array.isArray(rule))
|
} else if (Array.isArray(rule))
|
||||||
toInsert = rule;
|
toInsert = rule;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,11 @@ var Tokenizer = function(rules) {
|
||||||
: rule.token;
|
: rule.token;
|
||||||
|
|
||||||
if (rule.next) {
|
if (rule.next) {
|
||||||
currentState = rule.next;
|
if (typeof rule.next == "string")
|
||||||
|
currentState = rule.next;
|
||||||
|
else
|
||||||
|
currentState = rule.next(currentState, stack);
|
||||||
|
|
||||||
state = this.states[currentState];
|
state = this.states[currentState];
|
||||||
if (!state) {
|
if (!state) {
|
||||||
window.console && console.error && console.error(currentState, "doesn't exist");
|
window.console && console.error && console.error(currentState, "doesn't exist");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue