Closed
Description
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>
-> [
<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>
-> [
<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>
-> [
<span class="hljs-type">Bar</span>
Additional context
swift-docc-render uses a customized function to resolve this issue. See here