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

Typescript, adding keywords satisfies and as to the lexer #2014

Merged
merged 1 commit into from
May 13, 2024

Conversation

Eunoia
Copy link
Contributor

@Eunoia Eunoia commented Dec 10, 2023

Howdy!

Noticed some less than perfect syntax highlighting on a blog post, and thought to fix the issue upstream in rouge.

In typescript, 'as' and 'satisfies' are type assertion operator, while 'satisfies' is a type operator. There is no 'as' keyword in javascript, and the way the rule was written, functions named "as" were being marked as keywords, rather than functions.

I took the rule from a textmate grammar, and modified it to work in rouge.

I also tested this commit against my blog, and noticed the improved syntax highlighting there.

Now, "satisfies" and "as" are marked as keywords where they are used in a keyword way.

Here are three screenshots, before, after, and delta of visual lexer test.

Before

The "satisfies" is not bolded, and the "as" in the function names are bolded. Not ideal.
Screenshot 2023-12-09 at 5 19 53 PM

After

The "satisfies" is bolded, and the function names are not bolded, with no regressions to the other "as"
Screenshot 2023-12-09 at 5 19 13 PM

Delta

white is unchanged, teal is text that was made unbolded, and yellow is bolded.
Screenshot 2023-12-10 at 10 58 35 AM

@tancnle tancnle added the needs-review The PR needs to be reviewed label Dec 24, 2023
@tancnle tancnle self-requested a review December 24, 2023 00:34
@tancnle
Copy link
Collaborator

tancnle commented May 13, 2024

Thanks, @Eunoia. Change LGTM 🚀

@tancnle tancnle added this pull request to the merge queue May 13, 2024
Merged via the queue into rouge-ruby:master with commit 9266cbd May 13, 2024
7 checks passed
brandonb927 pushed a commit to brandonb927/brandonb-sites that referenced this pull request Jul 25, 2024
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [rouge](http://rouge.jneen.net/) ([source](https://github.com/rouge-ruby/rouge), [changelog](https://github.com/rouge-ruby/rouge/blob/master/CHANGELOG.md)) | minor | `4.2.1` -> `4.3.0` |

---

### Release Notes

<details>
<summary>rouge-ruby/rouge (rouge)</summary>

### [`v4.3.0`](https://github.com/rouge-ruby/rouge/blob/HEAD/CHANGELOG.md#version-430-2024-06-14)

[Compare Source](rouge-ruby/rouge@v4.2.1...v4.3.0)

[Comparison with the previous version](rouge-ruby/rouge@v4.2.1...v4.3.0)

\_ General

-   Align the base-16 default dark colour palette ([#&#8203;2040](rouge-ruby/rouge#2040) by Tan Le)
-   Brainfuck Lexer
    -   Add "bf" as an alias for brainfuck ([#&#8203;2038](rouge-ruby/rouge#2038) by Boris Verkhovskiy)
-   Eiffel Lexer
    -   Add some unicode operators in Eiffel ([#&#8203;2048](rouge-ruby/rouge#2048) by Ilgiz Mustafin)
-   HCL Lexer
    -   Add Operator support to the HCL Lexer ([#&#8203;2047](rouge-ruby/rouge#2047) by Simon Heather)
-   IecST Lexer (**NEW**)
    -   Add lexer for IEC 61131-3 Structured Text ([#&#8203;2027](rouge-ruby/rouge#2027) by Martin Waitz)
-   JavaScript & TypeScript Lexer
    -   Adding type operators satisfies and as ([#&#8203;2014](rouge-ruby/rouge#2014) by Evan R)
-   Markdown Lexer
    -   Support bold and italics at the same time ([#&#8203;2053](rouge-ruby/rouge#2053) by Tan Le)
-   Mathematica Lexer
    -   Add "wolfram" as an alias for Mathematica ([#&#8203;2042](rouge-ruby/rouge#2042) by Boris Verkhovskiy)
-   Objective-C Lexer
    -   Add "objective-c" as an alias for Objective-C ([#&#8203;2037](rouge-ruby/rouge#2037) by Boris Verkhovskiy)
-   Ruby & Crystal Lexer
    -   Add Ruby and Crystal unicode samples ([#&#8203;2036](rouge-ruby/rouge#2036) by Tan Le)
    -   Fix non-ascii characters in names in Crystal and Ruby ([#&#8203;1894](rouge-ruby/rouge#1894) by Kolesár András)
-   TCL Lexer
    -   Fix comment highlight in TCL lexer ([#&#8203;2041](rouge-ruby/rouge#2041) by Tan Le)
-   TOML Lexer
    -   toml: support all date formats ([#&#8203;2033](rouge-ruby/rouge#2033) by Martin Tournoij)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.brandonb.ca/brandon/personal-sites/pulls/8
Co-authored-by: Renovate Bot <renovate-bot@brandonb.ca>
Co-committed-by: Renovate Bot <renovate-bot@brandonb.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review The PR needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants