Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(python) identifiers starting with underscore not highlighted #3221

Merged
merged 1 commit into from Jun 3, 2021

Conversation

anlambert
Copy link
Contributor

Hello and thanks for maintaining that great library.

I noticed a regression in highlightjs.js 11.0, Python identifiers starting with an underscore
character (__init__ for instance) are no longer highlighted (introduced in 952fa0a).

That PR fixes that issue and add new markup tests to cover it.

On a related note, Python 3.0 introduces additional characters from outside the ASCII range for identifiers. Adding support for those in highlight.js is out of that PR scope and does not seem easy to implement but I could try to have a look when I have some time.

@anlambert anlambert changed the title fix(python) identifiers starting with underscore no longer highlighted fix(python) identifiers starting with underscore not highlighted Jun 2, 2021
@joshgoebel
Copy link
Member

On a related note, Python 3.0 introduces additional characters from outside the ASCII range for identifiers.

If it's along the lines of #2756 then it's not a high priority and needs some considerable effort and further research.

@anlambert
Copy link
Contributor Author

anlambert commented Jun 2, 2021

On a related note, Python 3.0 introduces additional characters from outside the ASCII range for identifiers.

If it's along the lines of #2756 then it's not a high priority and needs some considerable effort and further research.

That's what I thought too, ECMA 2018 could help here with its unicode category support in RegExp but it is only supported in recent browsers. So yes, this needs considerable effort and testing on the subject.

@joshgoebel
Copy link
Member

joshgoebel commented Jun 2, 2021

only supported in recent browsers

We're mostly fine with supporting only more recent browsers. Safari is a hold out on look-behind regex, but we're mostly ES2015/2018 already otherwise in several ways...

unicode category support in RegExp

If you skim the other issue you'll see the issue is /u seemed significantly slower in testing - and for a feature that no one is asking for (you make only the second person to mention it) it doesn't seem worth any slow down, much less a significant one. So it's pretty much just on hold until someone who cares a lot pours some time into it.

@joshgoebel
Copy link
Member

Please add changelog entry.

Since hljs version 11, python identifiers starting with an underscore
character were no longer highlighted (regression introduced in 952fa0a).

Add new python markup test related to identifiers highlighting.
@anlambert
Copy link
Contributor Author

Please add changelog entry.

Done. I also updated new markup test with the class starting with an underscore case.

@joshgoebel joshgoebel merged commit 45187c2 into highlightjs:main Jun 3, 2021
@joshgoebel
Copy link
Member

Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants