From 59ef51dbc3c7787611c421808e657ae03d113557 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Fri, 10 Dec 2021 14:33:36 +0100 Subject: [PATCH] PHP extras: Improved `scope` and `this` (#3243) --- components/prism-php-extras.js | 9 ++++++--- components/prism-php-extras.min.js | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/components/prism-php-extras.js b/components/prism-php-extras.js index c62c42cdae..ead82a620a 100644 --- a/components/prism-php-extras.js +++ b/components/prism-php-extras.js @@ -1,11 +1,14 @@ Prism.languages.insertBefore('php', 'variable', { - 'this': /\$this\b/, + 'this': { + pattern: /\$this\b/, + alias: 'keyword' + }, 'global': /\$(?:GLOBALS|HTTP_RAW_POST_DATA|_(?:COOKIE|ENV|FILES|GET|POST|REQUEST|SERVER|SESSION)|argc|argv|http_response_header|php_errormsg)\b/, 'scope': { pattern: /\b[\w\\]+::/, inside: { - keyword: /parent|self|static/, - punctuation: /::|\\/ + 'keyword': /\b(?:parent|self|static)\b/, + 'punctuation': /::|\\/ } } }); diff --git a/components/prism-php-extras.min.js b/components/prism-php-extras.min.js index e60a99eedf..50fc6a2cb9 100644 --- a/components/prism-php-extras.min.js +++ b/components/prism-php-extras.min.js @@ -1 +1 @@ -Prism.languages.insertBefore("php","variable",{this:/\$this\b/,global:/\$(?:GLOBALS|HTTP_RAW_POST_DATA|_(?:COOKIE|ENV|FILES|GET|POST|REQUEST|SERVER|SESSION)|argc|argv|http_response_header|php_errormsg)\b/,scope:{pattern:/\b[\w\\]+::/,inside:{keyword:/parent|self|static/,punctuation:/::|\\/}}}); \ No newline at end of file +Prism.languages.insertBefore("php","variable",{this:{pattern:/\$this\b/,alias:"keyword"},global:/\$(?:GLOBALS|HTTP_RAW_POST_DATA|_(?:COOKIE|ENV|FILES|GET|POST|REQUEST|SERVER|SESSION)|argc|argv|http_response_header|php_errormsg)\b/,scope:{pattern:/\b[\w\\]+::/,inside:{keyword:/\b(?:parent|self|static)\b/,punctuation:/::|\\/}}}); \ No newline at end of file