Skip to content

fix(swift) - add proper syntax highlighting for class func/var declarations #4154

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

Merged
merged 3 commits into from
Oct 31, 2024
Merged

Conversation

guuido
Copy link
Contributor

@guuido guuido commented Oct 29, 2024

Fixes the syntax highlighting for class functions and variables

Resolves #4121

Changes

Before the declaration of class func and class var was not handled correctly, for example

class func foo() async throws -> [Bar]
class var someProperty: Int { get }

was interpreted as

<span class="hljs-keyword">class</span> <span class="hljs-title class_">func</span> foo() <span class="hljs-keyword">async</span> <span class="hljs-keyword">throws</span> -&gt; [<span class="hljs-type">Bar</span>]
<span class="hljs-keyword">class</span> <span class="hljs-title class_">var</span> someProperty: <span class="hljs-type">Int</span> { <span class="hljs-keyword">get</span> }

After the fix the result is the following:

<span class="hljs-keyword">class </span><span class="hljs-keyword">func</span> <span class="hljs-title function_">foo</span>() <span class="hljs-keyword">async</span> <span class="hljs-keyword">throws</span> -&gt; [<span class="hljs-type">Bar</span>]
<span class="hljs-keyword">class </span><span class="hljs-keyword">var</span> someProperty: <span class="hljs-type">Int</span> { <span class="hljs-keyword">get</span> }

Checklist

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md

Copy link
Member

@joshgoebel joshgoebel left a comment

Choose a reason for hiding this comment

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

Some small thoughts, but looks like we're headed the right direction.

@guuido
Copy link
Contributor Author

guuido commented Oct 30, 2024

@joshgoebel thanks for your patience (it's my first contribution to the project), now it should be ok

@guuido guuido requested a review from joshgoebel October 30, 2024 10:18
Copy link
Member

@joshgoebel joshgoebel left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +120 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB +1 B
es/highlight.min.js 8.18 KB 8.18 KB +1 B
es/languages/swift.min.js 3.55 KB 3.61 KB +59 B
highlight.min.js 8.22 KB 8.22 KB +1 B
languages/swift.min.js 3.56 KB 3.62 KB +58 B

@joshgoebel joshgoebel merged commit 0dd843b into highlightjs:main Oct 31, 2024
19 checks passed
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.

(Swift) class func foo() not highlighted properly
2 participants