57

The Swift language isn't listed in the complete list of every identifier that you can use in the language hint for syntax highlighting.

Currently, the tag is configured for default language hint (so using <!-- language: swift --> is the same as <!-- language: default -->). But that's not enough for Swift, as it won't colorize keywords correctly like:

func
guard
protocol
extension
fileprivate
open
mutating
inout
fallthrough
typealias
willSet
didSet
subscript
Self
convenience
required
init
deinit
unowned
lazy
defer
optional
associatedtype
prefix
infix

It will also wrongly recognize some keywords which aren't existing in Swift:

union
select

I understand that internally, Stack Exchange uses Google Code Prettify, but I also noticed that the Swift extension for Prettify does exist. Sadly, it doesn't seem installed yet on Stack Overflow.

9
  • 7
    Note that it would be <!-- language: lang-swift -->, not <!-- language: swift -->. Commented May 8, 2017 at 2:46
  • 9
    @Xufox Specifying a tag name there looks up the tag and uses the language assigned to that tag.
    – animuson StaffMod
    Commented May 8, 2017 at 2:47
  • 1
    @animuson I know. I don’t really see how this relates to my comment. Commented May 8, 2017 at 2:49
  • 4
    @Xufox once lang-swift is added to Stack Exchange, then <!-- language: swift --> will be the same as <!-- language: lang-swift --> instead of <!-- language: default -->
    – Cœur
    Commented May 8, 2017 at 2:52
  • Ah, that’s what you mean. Commented May 8, 2017 at 2:58
  • 13
    This would be good, especially because the #selectors turning to gray due to # being a comment in default.
    – Papershine
    Commented May 8, 2017 at 10:07
  • @paper1111 - useful comment. That's really the only syntax/code issue that matters to me. If it's trivial to add this - and one could believe it is - it would be much appreciated.
    – user7014451
    Commented May 8, 2017 at 20:01
  • We need to add prettify support before adjusting the tag defaults - that JavaScript change (addition) will be in the next deploy, then we can wrap this up.
    – Nick Craver Mod
    Commented May 9, 2017 at 21:54
  • Apple is gonna be dead eventually coz Steve died.. No need to include. a phone without headphone slot? Rofl.. dongles!
    – Gogol
    Commented May 12, 2017 at 19:35

1 Answer 1

10

Done! The prettifier for Swift is now installed and working.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .