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

Update javascript lexer #1814

Merged
merged 6 commits into from Jul 18, 2021
Merged

Update javascript lexer #1814

merged 6 commits into from Jul 18, 2021

Conversation

Mesteery
Copy link
Contributor

@Mesteery Mesteery commented May 23, 2021

Partially resolves #1781.

@Mesteery Mesteery mentioned this pull request Jun 20, 2021
9 tasks
@Anteru Anteru merged commit fe572dc into pygments:master Jul 18, 2021
@Anteru
Copy link
Collaborator

Anteru commented Jul 18, 2021

Merged, thanks! What's the rationale for removing .tsx as a Typescript alias?

@Anteru Anteru added this to the 2.10 milestone Jul 18, 2021
@Anteru Anteru self-assigned this Jul 18, 2021
@Anteru Anteru added the changelog-update Items which need to get mentioned in the changelog label Jul 18, 2021
@Mesteery
Copy link
Contributor Author

What's the rationale for removing .tsx as a Typescript alias?

Because this lexer doesn't really support TSX.

@Mesteery Mesteery deleted the update-js-lexer branch July 18, 2021 08:54
@Anteru Anteru added A-lexing area: changes to individual lexers and removed changelog-update Items which need to get mentioned in the changelog labels Aug 8, 2021
@vlakoff
Copy link

vlakoff commented Oct 18, 2022

Using a variable named from in plain JavaScript code, I noticed it was highlighted as a reserved word (though it isn't a reserved word actually).

I pinpointed the cause to the following code, introduced by this PR:

# Match stuff like: constructor
(r'\b(constructor|from|as)\b', Keyword.Reserved),

@Mesteery
Copy link
Contributor Author

Mesteery commented Oct 19, 2022

from is a reserved word. By the way, when you use 'strict mode', your code will fail if you use from as a variable name.
from is used with import like import something from 'package'.

@vlakoff
Copy link

vlakoff commented Oct 19, 2022

My code is in strict mode, and it is currently using a variable named from, which doesn't fail.

I think that's because import, then subsequently from, is reserved only if the script if interpreted as a module. See the import documentation on MDN:

In order to use the import declaration in a source file, the file must be interpreted by the runtime as a module. In HTML, this is done by adding type="module" to the <script> tag. Modules are automatically interpreted in strict mode.

Though, I don't think Pygments can distinguish between the "regular" and "module" types…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lexing area: changes to individual lexers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants