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

Javascript lexer misclassifies async #1150

Closed
Anteru opened this issue Aug 31, 2019 · 8 comments
Closed

Javascript lexer misclassifies async #1150

Anteru opened this issue Aug 31, 2019 · 8 comments
Labels
S-major severity: major T-bug type: a bug X-imported imported from Bitbucket

Comments

@Anteru
Copy link
Collaborator

Anteru commented Aug 31, 2019

(Original issue 1446 created by Xavdidtheshadow on 2018-06-14T05:05:44.112262+00:00)

Hi there!

When using the JS lexer, the "await" keyword is listed as "Token.Name.Other" rather than "Token.Keyword.Reserved". This extends to other related tokens, such as "async"

My test input was:

#!javascript

const j = async () => await Promise.resolve(3)
@Anteru Anteru added T-bug type: a bug X-imported imported from Bitbucket S-major severity: major labels Aug 31, 2019
@Anteru
Copy link
Collaborator Author

Anteru commented Aug 31, 2019

(Original comment by peterbe on 2019-02-06T15:31:12.023318+00:00)

Demonstrated here: http://pygments.org/demo/6783285/

@Anteru
Copy link
Collaborator Author

Anteru commented Aug 31, 2019

(Original comment by jonluca on 2019-02-16T04:50:23.374630+00:00)

There is also an ancillary issue to JavaSript's async keyword - it's incorrectly colored when it is the name of a variable in a function definition, as below:

function testFunc(param1, param2, async){
    // do something
}

An example can be found here, near the bottom of the page, at XMLHttpRequest.prototype.open = function (method, url, async, user, pass).

@Domiii
Copy link

Domiii commented Dec 14, 2020

This forces me to switch from minted to listings for my writing needs.

Great project, but insufficient for my use case :/

@Anteru
Copy link
Collaborator Author

Anteru commented Dec 14, 2020

We are quite interested in improving any lexer -- but we don't have the bandwidth nor the knowledge of all languages to do it, so we rely on the community to contribute. Would you mind preparing a PR for the issues you're facing? I'll be happy to review it so we can get it integrated into Pygments.

@Domiii
Copy link

Domiii commented Dec 15, 2020

I just checked and it does list async and await as keywords.

Not sure why it did not highlight them? I used v2.7.3.

Here it is in the lexer.

@xavdid
Copy link

xavdid commented Dec 16, 2020

(I'm the OP from bitbucket)

Looks like this was fixed in #1605. I had no idea it was so straightforward or I would have just done it back in 2018 🙈

Thanks a bunch!

@Anteru
Copy link
Collaborator Author

Anteru commented Dec 16, 2020

@xavdid Thanks! :) Given it was merged 29 days ago, that means it should be in 2.7.3 -- @Domiii , can you please double-check you're using 2.7.3?

@Domiii
Copy link

Domiii commented Dec 26, 2020

Ok, I found the problem. I assumed it was using my pip-installed version, but it in fact used some version that was installed by Anaconda and of the wrong version. Apologies!

(On a separate note: Having a -v (--version) flag helps with this. I got the version via pip list pygments, not knowing I had to use conda show pygments to get the right one. Considering the chaos that Python and it's many difference environments bring, having your own dedicated version command would be super helpful :) )

@Anteru Anteru closed this as completed Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-major severity: major T-bug type: a bug X-imported imported from Bitbucket
Projects
None yet
Development

No branches or pull requests

3 participants