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

(Swift) class func foo() not highlighted properly #4121

Open
fel1x-developer opened this issue Sep 28, 2024 · 0 comments
Open

(Swift) class func foo() not highlighted properly #4121

fel1x-developer opened this issue Sep 28, 2024 · 0 comments
Labels
bug help welcome Could use help from community language

Comments

@fel1x-developer
Copy link

Describe the issue

In Swift

class func foo()

works like

static func foo()

But highlight.js interpret func as the class name in this case. Both class and func should be interpreted as keywords.

For example,

class func foo() async throws -> [Bar]

becomes

<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>

Whereas,

static func foo() async throws -> [Bar]

becomes

<span class="hljs-keyword">static</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>

Which language seems to have the issue?

Swift, manually selected and tested on highlight.js demo page

Are you using highlight or highlightAuto?

I believe when the language is set to Swift on the demo page it uses highlight.

Sample Code to Reproduce

class func foo() async throws -> [Bar]

Expected behavior

<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>

Additional context

swift-docc-render uses a customized function to resolve this issue. See here

@fel1x-developer fel1x-developer added bug help welcome Could use help from community language labels Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help welcome Could use help from community language
Projects
None yet
Development

No branches or pull requests

1 participant