Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maoyama/SyntaxHighlight
TextMate-style syntax highlighting for SwiftUI
https://github.com/maoyama/SyntaxHighlight
ios macos swiftui syntax-highlighting
Last synced: 3 months ago
JSON representation
TextMate-style syntax highlighting for SwiftUI
- Host: GitHub
- URL: https://github.com/maoyama/SyntaxHighlight
- Owner: maoyama
- License: mit
- Created: 2020-09-20T02:03:04.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-10-19T00:52:52.000Z (about 4 years ago)
- Last Synced: 2024-07-13T16:51:59.843Z (4 months ago)
- Topics: ios, macos, swiftui, syntax-highlighting
- Language: Swift
- Homepage:
- Size: 396 KB
- Stars: 39
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-swiftui - SyntaxHighlight: TextMate-style syntax highlighting for SwiftUI
README
# SyntaxHighlight
SyntaxHighlight makes TextMate-style syntax highlighting easy for SwiftUI.
## Usage
SyntaxHighlight uses `.tmTheme` and `.tmLanguage.json` files to highlight source code. None are provided with SyntaxHighlight. Thankfully, there are tons available at [Visual Studio Code Extensions](https://github.com/microsoft/vscode/tree/master/extensions) and [TextMate's GitHub org](https://github.com/textmate).
```swift
import SwiftUI
import SyntaxHighlightstruct ContentView: View {
var theme = try! Theme(contentsOf: Bundle.main.url(forResource: "Tomorrow", withExtension: "tmTheme")!)
var grammar = try! Grammar(contentsOf: Bundle.main.url(forResource: "JavaScript.tmLanguage", withExtension: "json")!)
var body: some View {
Text(from: Highlighter(string: "// JavaScript", theme: theme, grammar: grammar))
}
}
```## Installation
SyntaxHighlight is available through [Swift Package Manager](https://github.com/apple/swift-package-manager/).
```swift
let package = Package(
...
dependencies: [
.package(url: "https://github.com/maoyama/SyntaxHighlight.git", from: "0.1.0")
],
...
)
```## Requirements
- iOS13+
- macOS Catalina