Syntax highlighting using SwiftSyntax
HighlightSwiftSyntax
Outputs highlighted Swift Code as NSAttributedString using apple/swift-syntax
let inputCode = """
let inputCode: String
let rangeToKind: [NSRange: MyWordKind]
override public func visit(_ node: TupleExprElementSyntax) -> Syntax {
if let label = node.label {
updateDict(location: label.positionAfterSkippingLeadingTrivia.utf8Offset,
length: label.contentLength.utf8Length,
kind: .argument)
}
return super.visit(node)
}
"""
let output = try SwiftHighlighter.highlight(inputCode)
Theme
Currently it uses the theme from https://github.com/atacan/Amaze-Midnight. Custom theme functionality is coming soon…