Skip to content

Commit

Permalink
chore(php) add list of valid whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
wkania committed Dec 15, 2021
1 parent 7603452 commit d6e220e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/languages/php.js
Expand Up @@ -46,6 +46,8 @@ export default function(hljs) {
end: /[ \t]*(\w+)\b/,
contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
});
// list of valid whitespaces because non-breaking space might be part of a name
const WHITESPACE = '[ \t\n]';
const STRING = {
className: 'string',
variants: [
Expand Down Expand Up @@ -303,11 +305,11 @@ export default function(hljs) {
{
match: [
/new/,
/ +/,
regex.concat(WHITESPACE, "+"),
// to prevent built ins from being confused as the class constructor call
regex.concat("(?!", normalizeKeywords(BUILT_INS).join("\\b|"), "\\b)"),
/\\?\w+/,
/ *\(/,
regex.concat(WHITESPACE, "*\\("),
],
scope: {
1: "keyword",
Expand All @@ -324,7 +326,7 @@ export default function(hljs) {
// to prevent keywords from being confused as the function title
regex.concat("(?!fn\\b|function\\b|", normalizeKeywords(KWS).join("\\b|"), "|", normalizeKeywords(BUILT_INS).join("\\b|"), "\\b)"),
/\w+/,
/ */,
regex.concat(WHITESPACE, "*"),
regex.lookahead(/(?=\()/)
],
scope: {
Expand Down Expand Up @@ -374,7 +376,11 @@ export default function(hljs) {
FUNCTION_INVOKE,
{
// swallow composed identifiers to avoid parsing them as keywords
begin: /(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?! *\()(?![a-zA-Z0-9_\x7f-\xff])/,
match: regex.concat(
/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,
regex.concat("(?!", WHITESPACE, "*\\()"),
/(?![a-zA-Z0-9_\x7f-\xff])/
),
// scope:"wrong"
},
CONSTRUCTOR_CALL,
Expand Down

0 comments on commit d6e220e

Please sign in to comment.