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

[Markdown] Fix ligature tokanization #2151

Merged
merged 1 commit into from
Oct 29, 2019

Conversation

deathaxe
Copy link
Collaborator

Fixes #1453

This PR is an attempt to fix the issue #1453.

@@ -319,6 +320,9 @@ contexts:
Markdown will convert this for us. We match it so that the
HTML grammar will not mark it up as invalid.
scope: meta.other.valid-ampersand.markdown
ligatures:
- match: '<=>' # <=>
- match: '<[-=<]' # <- <= <<
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, Sublime Text internally passes sequences of symbols that are part of the same token to the text shaper. That is to say, every ascii code point > 32 and < 127 that is not alphanumeric. If we want to form as many ligatures as possible, we'd ideally want to tokenize those. However, it will get complicated since we don't want to consume any symbols that are part of valid Markdown syntax.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This context doesn't intend to match all possible ligatures. It instead tries to handle the edge case caused by the html tag matching or the valid-bracket rule. I could also try to add some lookaheads or things like that to the corresponding rules to avoid matching the tokens, but I found it a bit more complicated due to the several levels of lookaheads etc.

I found this the most secure way to fix the issue - maybe not the most elegant one.

Another edge case is the **= operator which is not recognized as ligature, but as the ** is used to open bold regions, I am worried about breaking things by matching it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that sounds like a good approach for now, let's try it.

@wbond wbond merged commit 7ab8555 into sublimehq:master Oct 29, 2019
@deathaxe deathaxe deleted the pr/markdown/fix-ligatures branch November 1, 2019 14:49
mitranim pushed a commit to mitranim/Packages that referenced this pull request Mar 25, 2022
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.

[Markdown] Ligatures that start with < aren't rendering
2 participants