diff --git a/CHANGES.md b/CHANGES.md index 9a544f449e..c4b136e3a3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ Core Grammars: +- enh(perl) fix false-positive variable match at end of string [Josh Goebel][] - fix(cpp) not all kinds of number literals are highlighted correctly [Lê Duy Quang][] - fix(css) fix overly greedy pseudo class matching [Bradley Mackey][] - enh(arcade) updated to ArcGIS Arcade version 1.24 [Kristian Ekenes][] @@ -43,6 +44,7 @@ Themes: [Robloxian Demo]: https://github.com/RobloxianDemo [Paul Tsnobiladzé]: https://github.com/tsnobip [Jonah Jeleniewski]: https://github.com/cirras +[Josh Goebel]: https://github.com/joshgoebel [CY Fung]: https://github.com/cyfung1031 [Vitaly Barilko]: https://github.com/Diversus23 diff --git a/src/languages/perl.js b/src/languages/perl.js index f8923b8884..677dc48beb 100644 --- a/src/languages/perl.js +++ b/src/languages/perl.js @@ -270,7 +270,7 @@ export default function(hljs) { variants: [ { begin: /\$\d/ }, { begin: regex.concat( - /[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/, + /[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/, // negative look-ahead tries to avoid matching patterns that are not // Perl at all like $ident$, @ident@, etc. `(?![A-Za-z])(?![@$%])` @@ -278,7 +278,7 @@ export default function(hljs) { }, { // Only $= is a special Perl variable and one can't declare @= or %=. - begin: /[$%@][^\s\w{=]|\$=/, + begin: /[$%@](?!")[^\s\w{=]|\$=/, relevance: 0 } ], diff --git a/test/markup/perl/default.expect.txt b/test/markup/perl/default.expect.txt index 715278d4fe..149bd1f41e 100644 --- a/test/markup/perl/default.expect.txt +++ b/test/markup/perl/default.expect.txt @@ -25,6 +25,10 @@ # GH-117 my $g = glob("/usr/bin/*"); + # GH-3934 + print "@"; + print; + return $o; } diff --git a/test/markup/perl/default.txt b/test/markup/perl/default.txt index 3b08442d07..b98a443f76 100644 --- a/test/markup/perl/default.txt +++ b/test/markup/perl/default.txt @@ -25,6 +25,10 @@ sub load # GH-117 my $g = glob("/usr/bin/*"); + # GH-3934 + print "@"; + print; + return $o; }