highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.31k stars 3.52k forks source link

(perl) "@" breaks highlighting #3934

Closed h3xx closed 6 months ago

h3xx commented 7 months ago

Describe the issue

A @ or % at the end of a double-quoted string is highlighted wrong.

It seems to highlight @ surrounded by whitespace correctly.

Perl won't interpolate @ or % when NOT followed by an identifier or variable:

# These print literal '@' characters
print "@";
print "user @ host";

Which language seems to have the issue?

Are you using highlight or highlightAuto? Whichever one https://highlightjs.org/demo uses.

Sample Code to Reproduce

print "@";
print 'highlighting for the rest of the file is broken'; # until " is encountered

- OR -

print "%";
print 'highlighting for the rest of the file is broken'; # until " is encountered

Expected behavior Expected to highlight the file as if the @ or % were any other character.

Additional context Tested on https://highlightjs.org/demo

joshgoebel commented 7 months ago

Can you confirm the fix? Any other cases we need to cover here?

h3xx commented 7 months ago

I added a test in my fork: d68f0814719d1b677deeb551b4a815ef7b13029c

It seems to pass given your changes.