highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.31k stars 3.52k forks source link

enh(swift) highlight function and macro call usage #3959

Open bradleymackey opened 5 months ago

bradleymackey commented 5 months ago

Improve fidelity by highlighting function calls in addition to definitions. This is already done by javascript, for example.

Before After
Screenshot 2024-01-07 at 14 03 24 Screenshot 2024-01-07 at 14 05 49

Changes

Next Steps (for a future PR)

Checklist

github-actions[bot] commented 5 months ago

Build Size Report

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

4 files changed

Total change +241 B

View Changes | file | base | pr | diff | | --- | --- | --- | --- | | es/core.min.js | 8.17 KB | 8.17 KB | +1 B | | es/highlight.min.js | 8.17 KB | 8.17 KB | +1 B | | es/languages/swift.min.js | 3.55 KB | 3.67 KB | +120 B | | languages/swift.min.js | 3.56 KB | 3.68 KB | +119 B |
github-actions[bot] commented 5 months ago

Build Size Report

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

3 files changed

Total change +231 B

View Changes | file | base | pr | diff | | --- | --- | --- | --- | | es/languages/swift.min.js | 3.55 KB | 3.67 KB | +116 B | | highlight.min.js | 8.21 KB | 8.21 KB | -1 B | | languages/swift.min.js | 3.56 KB | 3.68 KB | +116 B |
github-actions[bot] commented 5 months ago

Build Size Report

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

5 files changed

Total change +241 B

View Changes | file | base | pr | diff | | --- | --- | --- | --- | | es/core.min.js | 8.17 KB | 8.17 KB | +1 B | | es/highlight.min.js | 8.17 KB | 8.17 KB | +1 B | | es/languages/swift.min.js | 3.55 KB | 3.67 KB | +120 B | | highlight.min.js | 8.21 KB | 8.21 KB | -1 B | | languages/swift.min.js | 3.56 KB | 3.68 KB | +120 B |
github-actions[bot] commented 5 months ago

Build Size Report

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

5 files changed

Total change +207 B

View Changes | file | base | pr | diff | | --- | --- | --- | --- | | es/core.min.js | 8.17 KB | 8.18 KB | +2 B | | es/highlight.min.js | 8.17 KB | 8.18 KB | +2 B | | es/languages/swift.min.js | 3.55 KB | 3.65 KB | +101 B | | highlight.min.js | 8.21 KB | 8.21 KB | +2 B | | languages/swift.min.js | 3.56 KB | 3.66 KB | +100 B |
joshgoebel commented 5 months ago

We can't use negative lookahead until v12 though because it's a breaking change. And I don't have a timetable on that yet.

bradleymackey commented 5 months ago

@joshgoebel This is an adapted version of Javascript's implementation which is already using negative lookahead ( see here). My understanding was that only lookbehind is not allowed currently.

github-actions[bot] commented 5 months ago

Build Size Report

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

5 files changed

Total change +207 B

View Changes | file | base | pr | diff | | --- | --- | --- | --- | | es/core.min.js | 8.17 KB | 8.17 KB | +2 B | | es/highlight.min.js | 8.17 KB | 8.17 KB | +2 B | | es/languages/swift.min.js | 3.55 KB | 3.65 KB | +101 B | | highlight.min.js | 8.2 KB | 8.21 KB | +2 B | | languages/swift.min.js | 3.56 KB | 3.66 KB | +100 B |
bradleymackey commented 5 months ago

@joshgoebel Is there a way forward for this PR? If the concern is a language-specific breaking change, the Swift language itself is already using negative lookahead as well, here.