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

Support for ligatures in JavaScript? #1133

Closed
FezVrasta opened this issue May 4, 2017 · 11 comments
Closed

Support for ligatures in JavaScript? #1133

FezVrasta opened this issue May 4, 2017 · 11 comments

Comments

@FezVrasta
Copy link

FezVrasta commented May 4, 2017

Hi, I see that if I write => it gets converted in:

<span class="token operator">=</span>
<span class="token operator">></span>

But this breaks the ligature of the font I'm using (Fira Code).

Could it be possible to group together tokens of the same type to allow ligatures?
Ideally the markup should be:

<span class="token operator">=></span>
@Golmote
Copy link
Contributor

Golmote commented May 4, 2017

Hi, what language are you highlighting?

@FezVrasta
Copy link
Author

JavaScript.

@Golmote Golmote closed this as completed in 9f649fb May 8, 2017
@Golmote
Copy link
Contributor

Golmote commented May 8, 2017

Thanks for reporting. This should be fixed now.

@hax
Copy link

hax commented Aug 10, 2017

@Golmote Could you publish a new version on npm?

@ManuelRauber
Copy link

Is this really fixed?

image

Seems not to work for C# code

@RunDevelopment
Copy link
Member

RunDevelopment commented Aug 16, 2018

Well, it is fixed in JavaScript but not C#.

The title is was kind of ambiguous.

@FezVrasta FezVrasta changed the title Support for ligatures? Support for ligatures in JavaScript? Aug 16, 2018
mAAdhaTTah pushed a commit that referenced this issue Dec 1, 2018
Solve the issue of [C# breaking ligature fonts with the `=>` operator](#1133 (comment)). `=>` is now an operator.

There are also some other changes.

1. `?` and `:` are now all included by `punctuation`.
    Because `:` cannot be included in `operator` (because it is also used for inheritance)
the `?` shouldn't be an `operator` either.
2.  `??` and `?.` were added to `punctuation`.
    They weren't explicitly supported before.
3. An operator-test was added.
ggrossetie pushed a commit to ggrossetie/prism that referenced this issue Mar 11, 2019
Solve the issue of [C# breaking ligature fonts with the `=>` operator](PrismJS#1133 (comment)). `=>` is now an operator.

There are also some other changes.

1. `?` and `:` are now all included by `punctuation`.
    Because `:` cannot be included in `operator` (because it is also used for inheritance)
the `?` shouldn't be an `operator` either.
2.  `??` and `?.` were added to `punctuation`.
    They weren't explicitly supported before.
3. An operator-test was added.
@dsvensson
Copy link

@Golmote Same applies to Rust, :: at least.. perhaps more.

@RunDevelopment
Copy link
Member

RunDevelopment commented Mar 27, 2019

@dsvensson Does this also apply for other Rust operators?
I found that the .. operator has the same problem and wanted to ask whether there are other multi-character operators in Rust.

Edit: Nvm. I tested .. with the wrong language...

@dsvensson
Copy link

@RunDevelopment Nice... the documentation actually has a complete table of all operators, https://doc.rust-lang.org/book/appendix-02-operators.html

@VFDan
Copy link

VFDan commented May 2, 2020

=> isn't the only operator in JavaScript with ligatures; ?? exists, and many others. I think that this could break the way Prism works though... Maybe groups of token operators could be put into the same group.

This is ridiculous:
image

@RunDevelopment
Copy link
Member

@VFDan
Prism generally captures operators as a whole even if composed of several characters. E.g. ..., =>, and ?? will all be matched as one token. This requires some maintenance but is also more useful when processing Prism's token stream because Prism has some real understanding of the code. A neat little side-effect is that font ligature is natively supported.

Point is: ligatures breaking is usually just a sign that Prism tokenization isn't correct.

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

No branches or pull requests

7 participants