├── .gitignore ├── .swiftpm └── xcode │ └── xcshareddata │ └── xcschemes │ └── HighlightSwift.xcscheme ├── LICENSE.md ├── Package.swift ├── README.md ├── Sources └── HighlightSwift │ ├── CodeText │ ├── CodeText.swift │ ├── CodeTextCardView.swift │ ├── CodeTextColors.swift │ ├── CodeTextModifiers.swift │ ├── CodeTextStyle.swift │ └── CodeTextView.swift │ ├── HLJS │ ├── HLJS.swift │ ├── HLJSError.swift │ └── HLJSResult.swift │ ├── Highlight │ ├── Highlight.swift │ ├── HighlightBackground.swift │ ├── HighlightCSS.swift │ ├── HighlightColors.swift │ ├── HighlightEntry.swift │ ├── HighlightLanguage.swift │ ├── HighlightMode.swift │ ├── HighlightResult.swift │ └── HighlightTheme.swift │ └── HighlightJS │ ├── LICENSE.md │ └── highlight.min.js └── Tests └── HighlightSwiftTests └── HighlightSwiftTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | DerivedData/ 7 | .swiftpm/config/registries.json 8 | .swiftpm/xcode/package.xcworkspace 9 | .netrc 10 | -------------------------------------------------------------------------------- /.swiftpm/xcode/xcshareddata/xcschemes/HighlightSwift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 45 | 46 | 48 | 54 | 55 | 56 | 57 | 58 | 68 | 69 | 75 | 76 | 82 | 83 | 84 | 85 | 87 | 88 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Stefan Britton 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.10 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "HighlightSwift", 7 | platforms: [ 8 | .iOS(.v15), 9 | .tvOS(.v15), 10 | .macOS(.v13) 11 | ], 12 | products: [ 13 | .library( 14 | name: "HighlightSwift", 15 | targets: ["HighlightSwift"]), 16 | ], 17 | targets: [ 18 | .target( 19 | name: "HighlightSwift", 20 | resources: [.process("HighlightJS")], 21 | swiftSettings: [ 22 | .enableExperimentalFeature("StrictConcurrency") 23 | ]), 24 | .testTarget( 25 | name: "HighlightSwiftTests", 26 | dependencies: ["HighlightSwift"]), 27 | ] 28 | ) 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HighlightSwift 2 | 3 | ![](https://img.shields.io/github/v/release/appstefan/highlightswift) 4 | ![](https://img.shields.io/github/license/appstefan/highlightswift) 5 | [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fappstefan%2FHighlightSwift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/appstefan/HighlightSwift) 6 | [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fappstefan%2FHighlightSwift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/appstefan/HighlightSwift) 7 | 8 | Syntax Highlighting for Swift and SwiftUI 9 | 10 | 11 | 12 | 13 | CodeCard 14 | 15 | 16 | ## Contents 17 | 18 | #### `Highlight` 19 | Swift class to convert a `String` of code into a syntax highlighted `AttributedString` 20 | * 🔍 Automatic language detection 21 | * 📚 Support for 50+ common languages 22 | * 🌈 Choose from 30 built-in color themes or use custom CSS 23 | * 🧰 Built with [highlight.js](https://github.com/highlightjs/highlight.js) & `JavaScriptCore` 24 | * ☑️ Complete concurrency checking enabled 25 | * 🖥️ Works on iOS, iPadOS, macOS, and tvOS 26 | 27 | #### `CodeText` 28 | SwiftUI view to display a `String` of code with syntax highlighting 29 | * 🌗 Color theme syncs automatically with Dark Mode 30 | * 📜 Theme background color included with `.card` style 31 | * 🔠 Works with `Text` modifiers like `.bold()` or `.font()` 32 | * ⚙️ Includes modifiers to set the color theme, style & language 33 | * 📫 Callback modifiers to get the highlight results, language & score 34 | * 🍃 Memory efficient using an internal `Highlight` environment entry 35 | 36 | ## Highlight 37 | 38 | Create an instance of `Highlight` and convert a `String` of code into a syntax highlighted `AttributedString`: 39 | ```swift 40 | let someCode = """ 41 | print(\"Hello World\") 42 | """ 43 | let highlight = Highlight() 44 | let attributedText = try await highlight.attributedText(someCode) 45 | ``` 46 | 47 | Add the `language:` parameter to set the language and disable automatic language detection: 48 | ```swift 49 | let attributedText = try await highlight.attributedText(someCode, language: "swift") 50 | ``` 51 | 52 | Use the `colors:` parameter to change the color theme. 53 | ```swift 54 | let attributedText = try await highlight.attributedText(someCode, colors: .dark(.github)) 55 | ``` 56 | 57 | Apply a custom CSS theme with the `.custom` option. 58 | Refer to the highlight.js [Theme Guide](https://highlightjs.readthedocs.io/en/latest/theme-guide.html#) for details: 59 | ```swift 60 | let someCSS = """ 61 | .hljs { 62 | display: block; 63 | overflow-x: auto; 64 | padding: 0.5em; 65 | } 66 | """ 67 | let attributedText = try await highlight.attributedText(someCode, colors: .custom(css: someCSS)) 68 | ``` 69 | 70 | The `.request()` function returns a `HighlightResult` with extra information: 71 | ```swift 72 | let result: HighlightResult = try await highlight.request(someCode) 73 | print(result) 74 | ``` 75 | ```swift 76 | HighlightResult( 77 | attributedText: "...", 78 | relevance: 5, 79 | language: "swift", 80 | languageName: "Swift?", 81 | backgroundColor: #1F2024FF, 82 | hasIllegal: false, 83 | isUndefined: false) 84 | ``` 85 | 86 | ## 87 | ### `CodeText` 88 | 89 | Create a `CodeText` view with some code: 90 | ```swift 91 | let someCode: String = """ 92 | print(\"Hello World\") 93 | """ 94 | 95 | var body: some View { 96 | CodeText(someCode) 97 | } 98 | ``` 99 | 100 | The font design is always `.monospaced`. 101 | Other text modifiers can be applied: 102 | ```swift 103 | CodeText(someCode) 104 | .font(.callout) 105 | .fontWeight(.semibold) 106 | ``` 107 | 108 | Add the `.highlightLanguage()` modifier to set the language and disable automatic detection: 109 | ```swift 110 | CodeText(someCode) 111 | .highlightLanguage(.swift) 112 | ``` 113 | 114 | #### Colors 115 | Add the `.codeTextColors()` modifier to set the color theme. The built-in color themes update automatically with Dark Mode to the corresponding dark variant. 116 | ```swift 117 | CodeText(someCode) 118 | .codeTextColors(.github) 119 | ``` 120 | 121 | Choose the `.custom` option to use any custom CSS color theme. Refer to the official highlight.js [Theme Guide](https://highlightjs.readthedocs.io/en/latest/theme-guide.html#) for more info. 122 | ```swift 123 | CodeText(someCode) 124 | .codeTextColors(.custom(dark: .custom(css: someDarkCSS), light: .custom(css: someLightCSS))) 125 | ``` 126 | 127 | #### Styles 128 | The default style is `.plain` without any background or padding. Some of the color themes are more legible with their corresponding background color. Add the `.codeTextStyle()` modifier and choose the `.card` style to show the background: 129 | ```swift 130 | CodeText(someCode) 131 | .codeTextStyle(.card) 132 | ``` 133 | 134 | The `.card` style has a few customization options, for example: 135 | ```swift 136 | CodeText(someCode) 137 | .codeTextStyle(.card(cornerRadius: 0, stroke: .separator, verticalPadding: 12)) 138 | ``` 139 | 140 | #### Results 141 | Add `.onHighlightSuccess()` to get the highlight results, including the detected language, relevancy score, background color and other details. Unexpected errors are unlikely but can be handled with `.onHighlightFailure()` if necessary for debugging. 142 | ```swift 143 | CodeText(someCode) 144 | .onHighlightSuccess { result in 145 | ... 146 | } 147 | .onHighlightFailure { error in 148 | ... 149 | } 150 | ``` 151 | 152 | There is also a combined `.onHighlightResult()` equivalent of the two callbacks above. 153 | ```swift 154 | CodeText(someCode) 155 | .onHighlightResult { result in 156 | switch result { 157 | case .success: 158 | ... 159 | case .failure: 160 | ... 161 | } 162 | } 163 | ``` 164 | 165 | A previously stored highlight result can be passed to the `CodeText`. 166 | In combination with `.onHighlightSuccess()` the result can be persisted when the view might reappear frequently, such as in a list view: 167 | ```swift 168 | let someCode: String = """ 169 | print(\"Hello World\") 170 | """ 171 | 172 | @State var result: HighlightResult? 173 | 174 | var body: some View { 175 | List { 176 | ... 177 | CodeText(someCode, result: result) 178 | .onHighlightSuccess { result in 179 | self.result = result 180 | } 181 | ... 182 | } 183 | } 184 | ``` 185 | 186 | ## Installation 187 | 188 | ### Project 189 | 190 | 1. In Xcode, go to `File` > `Add packages...` 191 | 2. Enter `https://github.com/appstefan/highlightswift` in the field and click `Add Package` 192 | 193 | ### Package 194 | 195 | In `Package.swift` add this repository as a dependency: 196 | ```swift 197 | dependencies: [ 198 | .package(url: "https://github.com/appstefan/highlightswift.git", from: "1.1") 199 | ], 200 | targets: [ 201 | .target( 202 | name: "YourPackageName", 203 | dependencies: ["HighlightSwift"] 204 | ) 205 | ] 206 | ``` 207 | 208 | ## Author 209 | 210 | Stefan, thrower_ranges.0d@icloud.com 211 | 212 | ## License 213 | 214 | HighlightSwift is available under the MIT license. See the [LICENSE.md](/LICENSE.md) file. 215 | Highlight.js is available under the BSD license. See the [LICENSE.md](/Sources/HighlightSwift/HighlightJS/LICENSE.md) file. 216 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/CodeText/CodeText.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | @available(iOS 16.1, tvOS 16.1, *) 4 | public struct CodeText { 5 | private let text: String 6 | 7 | internal var mode: HighlightMode = .automatic 8 | internal var style: CodeTextStyle = .plain 9 | internal var colors: CodeTextColors = .theme(.xcode) 10 | 11 | internal var success: ((HighlightResult) -> Void)? 12 | internal var failure: ((Error) -> Void)? 13 | internal var result: ((Result) -> Void)? 14 | 15 | @State internal var highlightTask: Task? 16 | @State internal var highlightResult: HighlightResult? 17 | 18 | @Environment(\.highlight) internal var highlight 19 | @Environment(\.colorScheme) internal var colorScheme 20 | 21 | /// Creates a text view that displays syntax highlighted code. 22 | /// - Parameters: 23 | /// - text: Plain text code to be syntax highlighted and displayed. 24 | /// - result: Existing highlight result to display instead of highlighting the text on appear. 25 | public init(_ text: String, result: HighlightResult? = nil) { 26 | self.text = text 27 | self._highlightResult = .init(initialValue: result) 28 | } 29 | 30 | internal var attributedText: AttributedString { 31 | highlightResult?.attributedText ?? AttributedString(stringLiteral: text) 32 | } 33 | 34 | @MainActor 35 | internal func highlightText( 36 | mode: HighlightMode? = nil, 37 | colors: CodeTextColors? = nil, 38 | colorScheme: ColorScheme? = nil 39 | ) async { 40 | let text = self.text 41 | let mode = mode ?? self.mode 42 | let colors = colors ?? self.colors 43 | let scheme = colorScheme ?? self.colorScheme 44 | let schemeColors = scheme == .dark ? colors.dark : colors.light 45 | do { 46 | let highlightResult = try await highlight.request(text, mode: mode, colors: schemeColors) 47 | self.highlightResult = highlightResult 48 | result?(.success(highlightResult)) 49 | success?(highlightResult) 50 | } catch { 51 | result?(.failure(error)) 52 | failure?(error) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/CodeText/CodeTextCardView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct CodeTextCardView: View { 4 | let style: CardCodeTextStyle 5 | let color: Color? 6 | 7 | var body: some View { 8 | ZStack { 9 | if let color { 10 | RoundedRectangle(cornerRadius: style.cornerRadius, style: style.cornerStyle) 11 | .fill(color) 12 | } 13 | RoundedRectangle(cornerRadius: style.cornerRadius, style: style.cornerStyle) 14 | .stroke(AnyShapeStyle(style.stroke), lineWidth: style.lineWidth) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/CodeText/CodeTextColors.swift: -------------------------------------------------------------------------------- 1 | public struct CodeTextColors: Equatable { 2 | public let dark: HighlightColors 3 | public let light: HighlightColors 4 | 5 | public static func theme(_ theme: HighlightTheme) -> CodeTextColors { 6 | CodeTextColors(dark: .dark(theme), light: .light(theme)) 7 | } 8 | 9 | public static func custom(dark: HighlightColors, light: HighlightColors) -> CodeTextColors { 10 | CodeTextColors(dark: dark, light: light) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/CodeText/CodeTextModifiers.swift: -------------------------------------------------------------------------------- 1 | @available(iOS 16.1, tvOS 16.1, *) 2 | extension CodeText { 3 | /// Sets the code text style for this code text. 4 | public func codeTextStyle(_ style: S) -> CodeText where S : CodeTextStyle { 5 | var content = self 6 | content.style = style 7 | return content 8 | } 9 | 10 | /// Sets the highlight color theme for this code text. 11 | public func codeTextColors(_ colors: CodeTextColors) -> CodeText { 12 | var content = self 13 | content.colors = colors 14 | return content 15 | } 16 | 17 | /// Sets the language detection mode for this code text. 18 | /// See also `highlightLanguage(_:)` to simply set a language. 19 | public func highlightMode(_ mode: HighlightMode) -> CodeText { 20 | var content = self 21 | content.mode = mode 22 | return content 23 | } 24 | 25 | /// Sets the language for this code text. 26 | /// Equivalent to `.highlightMode(.language(...))` 27 | public func highlightLanguage(_ language: HighlightLanguage) -> CodeText { 28 | var content = self 29 | content.mode = .language(language) 30 | return content 31 | } 32 | 33 | /// Adds an action to perform after the text has been highlighted or an error occurs. 34 | public func onHighlightResult(_ perform: @escaping ((Result) -> Void)) -> CodeText { 35 | var content = self 36 | content.result = perform 37 | return content 38 | } 39 | 40 | /// Adds an action to perform if an error occurs while highlighting. 41 | public func onHighlightFailure(_ perform: @escaping ((Error) -> Void)) -> CodeText { 42 | var content = self 43 | content.failure = perform 44 | return content 45 | } 46 | 47 | /// Adds an action to perform after the text has been highlighted. 48 | public func onHighlightSuccess(_ perform: @escaping ((HighlightResult) -> Void)) -> CodeText { 49 | var content = self 50 | content.success = perform 51 | return content 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/CodeText/CodeTextStyle.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | public protocol CodeTextStyle { 4 | var verticalPadding: CGFloat { get } 5 | var horizontalPadding: CGFloat { get } 6 | } 7 | 8 | // MARK: - Plain 9 | 10 | public struct PlainCodeTextStyle: CodeTextStyle { 11 | public init() { } 12 | 13 | public let verticalPadding: CGFloat = 0 14 | public let horizontalPadding: CGFloat = 0 15 | } 16 | 17 | extension CodeTextStyle where Self == PlainCodeTextStyle { 18 | 19 | /// The default code text style with no decoration. 20 | public static var plain: PlainCodeTextStyle { 21 | PlainCodeTextStyle() 22 | } 23 | } 24 | 25 | // MARK: - Card 26 | 27 | public struct CardCodeTextStyle: CodeTextStyle { 28 | public let cornerRadius: CGFloat 29 | public let cornerStyle: RoundedCornerStyle 30 | public let stroke: AnyShapeStyle 31 | public let lineWidth: CGFloat 32 | public let verticalPadding: CGFloat 33 | public let horizontalPadding: CGFloat 34 | } 35 | 36 | extension CodeTextStyle where Self == CardCodeTextStyle { 37 | 38 | /// A code text style with the theme background color and a border. 39 | public static var card: CardCodeTextStyle { 40 | CardCodeTextStyle( 41 | cornerRadius: 10, 42 | cornerStyle: .continuous, 43 | stroke: defaultStroke, 44 | lineWidth: 0.333, 45 | verticalPadding: 8, 46 | horizontalPadding: 12 47 | ) 48 | } 49 | 50 | /// A code text style with the theme background color and a border. 51 | public static func card( 52 | cornerRadius: CGFloat = 10, 53 | cornerStyle: RoundedCornerStyle = .continuous, 54 | stroke: S = CardCodeTextStyle.defaultStroke, 55 | lineWidth: CGFloat = 0.333, 56 | verticalPadding: CGFloat = 8, 57 | horizontalPadding: CGFloat = 12 58 | ) -> CardCodeTextStyle { 59 | CardCodeTextStyle( 60 | cornerRadius: cornerRadius, 61 | cornerStyle: cornerStyle, 62 | stroke: AnyShapeStyle(stroke), 63 | lineWidth: lineWidth, 64 | verticalPadding: verticalPadding, 65 | horizontalPadding: horizontalPadding 66 | ) 67 | } 68 | 69 | public static var defaultStroke: AnyShapeStyle { 70 | if #available(iOS 17.0, *) { 71 | AnyShapeStyle(.separator) 72 | } else { 73 | AnyShapeStyle(.secondary.opacity(0.5)) 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/CodeText/CodeTextView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | @available(iOS 16.1, tvOS 16.1, *) 4 | extension CodeText: View { 5 | public var body: some View { 6 | Text(attributedText) 7 | .fontDesign(.monospaced) 8 | .padding(.vertical, style.verticalPadding) 9 | .padding(.horizontal, style.horizontalPadding) 10 | .background { 11 | if let cardStyle = style as? CardCodeTextStyle { 12 | CodeTextCardView( 13 | style: cardStyle, 14 | color: highlightResult?.backgroundColor 15 | ) 16 | } 17 | } 18 | .onAppear { 19 | guard highlightResult == nil else { 20 | return 21 | } 22 | highlightTask = Task { 23 | await highlightText() 24 | } 25 | } 26 | .onDisappear { 27 | highlightTask?.cancel() 28 | } 29 | .onChange(of: mode) { newMode in 30 | highlightTask?.cancel() 31 | highlightTask = Task { 32 | await highlightText(mode: newMode) 33 | } 34 | } 35 | .onChange(of: colors) { newColors in 36 | highlightTask?.cancel() 37 | highlightTask = Task { 38 | await highlightText(colors: newColors) 39 | } 40 | } 41 | .onChange(of: colorScheme) { newColorScheme in 42 | highlightTask?.cancel() 43 | highlightTask = Task { 44 | await highlightText(colorScheme: newColorScheme) 45 | } 46 | } 47 | } 48 | } 49 | 50 | // MARK: - Preview 51 | 52 | @available(iOS 16.1, tvOS 16.1, *) 53 | private struct PreviewCodeText: View { 54 | @State var colors: CodeTextColors = .theme(.xcode) 55 | @State var font: Font = .body 56 | 57 | let code: String = """ 58 | import SwiftUI 59 | 60 | struct SwiftUIView: View { 61 | var body: some View { 62 | Text("Hello World!") 63 | } 64 | } 65 | """ 66 | 67 | var body: some View { 68 | List { 69 | CodeText(code) 70 | .codeTextStyle(.card) 71 | .codeTextColors(colors) 72 | .highlightLanguage(.swift) 73 | .font(font) 74 | Button { 75 | withAnimation { 76 | colors = .theme(randomTheme()) 77 | font = randomFont() 78 | } 79 | } label: { 80 | Text("Random") 81 | } 82 | } 83 | } 84 | 85 | func randomTheme() -> HighlightTheme { 86 | let cases = HighlightTheme.allCases 87 | return cases[.random(in: 0.. Font { 91 | let cases: [Font] = [ 92 | .body, 93 | .callout, 94 | .caption, 95 | .caption2, 96 | .footnote, 97 | .headline, 98 | .largeTitle, 99 | .subheadline, 100 | .title 101 | ] 102 | return cases[.random(in: 0.. JSValue { 7 | if let hljs { 8 | return hljs 9 | } 10 | guard let context = JSContext() else { 11 | throw HLJSError.contextIsNil 12 | } 13 | let highlightPath = Bundle.module.path(forResource: "highlight.min", ofType: "js") 14 | guard let highlightPath else { 15 | throw HLJSError.fileNotFound 16 | } 17 | let highlightScript = try String(contentsOfFile: highlightPath) 18 | context.evaluateScript(highlightScript) 19 | guard let hljs = context.objectForKeyedSubscript("hljs") else { 20 | throw HLJSError.hljsNotFound 21 | } 22 | self.hljs = hljs 23 | return hljs 24 | } 25 | 26 | func highlight(_ text: String, mode: HighlightMode) throws -> HLJSResult { 27 | switch mode { 28 | case .automatic: 29 | return try highlightAuto(text) 30 | case .languageAlias(let alias): 31 | return try highlight(text, language: alias, ignoreIllegals: false) 32 | case .languageAliasIgnoreIllegal(let alias): 33 | return try highlight(text, language: alias, ignoreIllegals: true) 34 | case .language(let language): 35 | return try highlight(text, language: language.alias, ignoreIllegals: false) 36 | case .languageIgnoreIllegal(let language): 37 | return try highlight(text, language: language.alias, ignoreIllegals: true) 38 | } 39 | } 40 | 41 | private func highlightAuto(_ text: String) throws -> HLJSResult { 42 | let hljs = try load() 43 | let jsResult = hljs.invokeMethod( 44 | "highlightAuto", 45 | withArguments: [text] 46 | ) 47 | return try highlightResult(jsResult) 48 | } 49 | 50 | private func highlight(_ text: String, 51 | language: String, 52 | ignoreIllegals: Bool) throws -> HLJSResult { 53 | var languageOptions: [String : Any] = [ 54 | "language": language, 55 | ] 56 | if ignoreIllegals { 57 | languageOptions["ignoreIllegals"] = ignoreIllegals 58 | } 59 | let hljs = try load() 60 | let jsResult = hljs.invokeMethod( 61 | "highlight", 62 | withArguments: [text, languageOptions] 63 | ) 64 | return try highlightResult(jsResult) 65 | } 66 | 67 | private func highlightResult(_ result: JSValue?) throws -> HLJSResult { 68 | guard let result else { 69 | throw HLJSError.valueNotFound 70 | } 71 | let illegal = result.objectForKeyedSubscript("illegal").toBool() 72 | let relevance = result.objectForKeyedSubscript("relevance").toInt32() 73 | guard 74 | let value = result.objectForKeyedSubscript("value").toString(), 75 | let language = result.objectForKeyedSubscript("language").toString() 76 | else { 77 | throw HLJSError.valueNotFound 78 | } 79 | return HLJSResult(value: value, illegal: illegal, language: language, relevance: relevance) 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/HLJS/HLJSError.swift: -------------------------------------------------------------------------------- 1 | enum HLJSError: Error { 2 | case contextIsNil 3 | case fileNotFound 4 | case hljsNotFound 5 | case valueNotFound 6 | } 7 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/HLJS/HLJSResult.swift: -------------------------------------------------------------------------------- 1 | struct HLJSResult { 2 | let value: String 3 | let illegal: Bool 4 | let language: String 5 | let relevance: Int32 6 | } 7 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/Highlight/Highlight.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public final class Highlight: Sendable { 4 | private let hljs = HLJS() 5 | 6 | public init() { 7 | 8 | } 9 | 10 | /// Syntax highlight some text with automatic language detection. 11 | /// - Parameters: 12 | /// - text: The plain text code to highlight. 13 | /// - colors: The highlight colors to use (default: .xcode/.light). 14 | /// - Throws: Either a HighlightError or an Error. 15 | /// - Returns: A syntax highlighted attributed string. 16 | public func attributedText(_ text: String, 17 | colors: HighlightColors = .light(.xcode)) async throws -> AttributedString { 18 | try await request(text, mode: .automatic, colors: colors).attributedText 19 | } 20 | 21 | /// Syntax highlight some text with a specific language. 22 | /// - Parameters: 23 | /// - text: The plain text code to highlight. 24 | /// - language: The supported language to use. 25 | /// - colors: The highlight colors to use (default: .xcode/.light). 26 | /// - Throws: Either a HighlightError or an Error. 27 | /// - Returns: A syntax highlighted attributed string. 28 | public func attributedText(_ text: String, 29 | language: HighlightLanguage, 30 | colors: HighlightColors = .light(.xcode)) async throws -> AttributedString { 31 | try await request(text, mode: .language(language), colors: colors).attributedText 32 | } 33 | 34 | /// Syntax highlight some text with a specific language. 35 | /// - Parameters: 36 | /// - text: The plain text code to highlight. 37 | /// - language: The language alias to use. 38 | /// - colors: The highlight colors to use (default: .xcode/.light). 39 | /// - Throws: Either a HighlightError or an Error. 40 | /// - Returns: A syntax highlighted attributed string. 41 | public func attributedText(_ text: String, 42 | language: String, 43 | colors: HighlightColors = .light(.xcode)) async throws -> AttributedString { 44 | try await request(text, mode: .languageAlias(language), colors: colors).attributedText 45 | } 46 | 47 | /// Syntax highlight some text and return detailed results. 48 | /// - Parameters: 49 | /// - text: The plain text code to highlight. 50 | /// - mode: The highlight mode to use (default: .automatic). 51 | /// - colors: The highlight colors to use (default: .xcode/.light). 52 | /// - Throws: Either a HighlightError or an Error. 53 | /// - Returns: The result of the syntax highlight. 54 | public func request(_ text: String, 55 | mode: HighlightMode = .automatic, 56 | colors: HighlightColors = .light(.xcode)) async throws -> HighlightResult { 57 | let hljsResult = try await hljs.highlight(text, mode: mode) 58 | let isUndefined = hljsResult.value == "undefined" 59 | let attributedText: AttributedString 60 | if isUndefined { 61 | attributedText = AttributedString(stringLiteral: text) 62 | } else { 63 | let data = try htmlDataFromText(hljsResult.value, selectors: colors.css) 64 | attributedText = try attributedTextFromData(data) 65 | } 66 | return HighlightResult( 67 | attributedText: attributedText, 68 | highlightJSResult: hljsResult, 69 | backgroundColorHex: colors.background 70 | ) 71 | } 72 | 73 | private func htmlDataFromText(_ text: String, selectors: String) throws -> Data { 74 | let html = "") 77 | .appending("\n
")
 78 |             .appending(text.trimmingCharacters(in: .whitespacesAndNewlines))
 79 |             .appending("
") 80 | return html.data(using: .utf8) ?? Data() 81 | } 82 | 83 | private func attributedTextFromData(_ data: Data) throws -> AttributedString { 84 | let mutableString = try NSMutableAttributedString( 85 | data: data, 86 | options: [ 87 | .documentType: NSAttributedString.DocumentType.html, 88 | .characterEncoding: String.Encoding.utf8.rawValue 89 | ], 90 | documentAttributes: nil 91 | ) 92 | mutableString.removeAttribute( 93 | .font, 94 | range: NSMakeRange(0, mutableString.length) 95 | ) 96 | let range = NSRange(location: 0, length: mutableString.length - 1) 97 | let attributedString = mutableString.attributedSubstring(from: range) 98 | #if os(macOS) 99 | return try AttributedString(attributedString, including: \.appKit) 100 | #else 101 | return try AttributedString(attributedString, including: \.uiKit) 102 | #endif 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/Highlight/HighlightBackground.swift: -------------------------------------------------------------------------------- 1 | struct HighlightBackground { 2 | static func light(_ theme: HighlightTheme) -> String { 3 | switch theme { 4 | case .a11y: return "#fefefe" 5 | case .atomOne: return "#fafafa" 6 | case .classic: return "#f5f5f5" 7 | case .edge: return "#fafafa" 8 | case .github: return "#fff" 9 | case .google: return "#fff" 10 | case .gradient: return "fff" 11 | case .grayscale: return "#f7f7f7" 12 | case .harmonic16: return "#f7f9fb" 13 | case .heetch: return "#feffff" 14 | case .horizon: return "#fdf0ed" 15 | case .humanoid: return "#f8f8f2" 16 | case .ia: return "#f6f6f6" 17 | case .isblEditor: return "#fff" 18 | case .kimbie: return "#fbebd4" 19 | case .nnfx: return "#fff" 20 | case .pandaSyntax: return "#e6e6e6" 21 | case .papercolor: return "#eee" 22 | case .paraiso: return "#e7e9db" 23 | case .qtcreator: return "#fff" 24 | case .silk: return "#e9f1ef" 25 | case .solarFlare: return "#f5f7fa" 26 | case .solarized: return "#fdf6e3" 27 | case .stackoverflow: return "#f6f6f6" 28 | case .standard: return "#f8f8f8" 29 | case .summerfruit: return "#fff" 30 | case .synthMidnightTerminal: return "#dddfe0" 31 | case .tokyoNight: return "#d5d6db" 32 | case .unikitty: return "#fff" 33 | case .xcode: return "#fff" 34 | } 35 | } 36 | 37 | static func dark(_ theme: HighlightTheme) -> String { 38 | switch theme { 39 | case .a11y: return "#2b2b2b" 40 | case .atomOne: return "#282c34" 41 | case .classic: return "#151515" 42 | case .edge: return "#262729" 43 | case .github: return "#0d1117" 44 | case .google: return "#1d1f21" 45 | case .gradient: return "000" 46 | case .grayscale: return "#101010" 47 | case .harmonic16: return "#0b1c2c" 48 | case .heetch: return "#190134" 49 | case .horizon: return "#1c1e26" 50 | case .humanoid: return "#232629" 51 | case .ia: return "#1a1a1a" 52 | case .isblEditor: return "#404040" 53 | case .kimbie: return "#221a0f" 54 | case .nnfx: return "#333" 55 | case .pandaSyntax: return "#2a2c2d" 56 | case .papercolor: return "#1c1c1c" 57 | case .paraiso: return "#2f1e2e" 58 | case .qtcreator: return "#000" 59 | case .silk: return "#0e3c46" 60 | case .solarFlare: return "#18262f" 61 | case .solarized: return "#002b36" 62 | case .stackoverflow: return "#1c1b1b" 63 | case .standard: return "#181818" 64 | case .summerfruit: return "#151515" 65 | case .synthMidnightTerminal: return "#050608" 66 | case .tokyoNight: return "#1a1b26" 67 | case .unikitty: return "#2e2a31" 68 | case .xcode: return "#1f2024" 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/Highlight/HighlightCSS.swift: -------------------------------------------------------------------------------- 1 | struct HighlightCSS { 2 | static func light(_ theme: HighlightTheme) -> String { 3 | switch theme { 4 | case .a11y: 5 | /* 6 | Theme: a11y-light 7 | Author: @ericwbailey 8 | Maintainer: @ericwbailey 9 | Based on the Tomorrow Night Eighties theme: https://github.com/isagalaev/highlight.js/blob/master/src/styles/tomorrow-night-eighties.css 10 | */ 11 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#545454}.hljs-comment,.hljs-quote{color:#696969}.hljs-deletion,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#d91e18}.hljs-attribute,.hljs-built_in,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-type{color:#aa5d00}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:green}.hljs-section,.hljs-title{color:#007faa}.hljs-keyword,.hljs-selector-tag{color:#7928a1}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}@media screen and (-ms-high-contrast:active){.hljs-addition,.hljs-attribute,.hljs-built_in,.hljs-bullet,.hljs-comment,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-quote,.hljs-string,.hljs-symbol,.hljs-type{color:highlight}.hljs-keyword,.hljs-selector-tag{font-weight:700}}" 12 | case .atomOne: 13 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#383a42}.hljs-comment,.hljs-quote{color:#a0a1a7;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#a626a4}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e45649}.hljs-literal{color:#0184bb}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#50a14f}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#986801}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#4078f2}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#c18401}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}" 14 | case .classic: 15 | /* 16 | Theme: Classic Light 17 | Author: Jason Heeris (http://heeris.id.au) 18 | License: ~ MIT (or more permissive) [via base16-schemes-source] 19 | Maintainer: @highlightjs/core-team 20 | Version: 2021.09.0 21 | */ 22 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#303030}.hljs ::selection,.hljs::selection{color:#303030}.hljs-comment{color:#b0b0b0}.hljs-tag{color:#505050}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#303030}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#ac4142}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#d28445}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#f4bf75}.hljs-strong{font-weight:700;color:#f4bf75}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#90a959}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#75b5aa}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#6a9fb5}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#aa759f}.hljs-emphasis{color:#aa759f;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#8f5536}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 23 | case .edge: 24 | /* 25 | Theme: Edge Light 26 | Author: cjayross (https://github.com/cjayross) 27 | License: ~ MIT (or more permissive) [via base16-schemes-source] 28 | Maintainer: @highlightjs/core-team 29 | Version: 2021.09.0 30 | */ 31 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#5e646f}.hljs ::selection,.hljs::selection{color:#5e646f}.hljs-comment{color:#5e646f}.hljs-tag{color:#6587bf}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#5e646f}.hljs-operator{opacity:.7}.hljs-attr,.hljs-bullet,.hljs-deletion,.hljs-link,.hljs-literal,.hljs-name,.hljs-number,.hljs-selector-tag,.hljs-symbol,.hljs-template-variable,.hljs-variable,.hljs-variable.constant_{color:#db7070}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#d69822}.hljs-strong{font-weight:700;color:#d69822}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#7c9f4b}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#509c93}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#6587bf}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#b870ce}.hljs-emphasis{color:#b870ce;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#509c93}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 32 | case .github: 33 | /* 34 | Theme: Github 35 | Author: Defman21 36 | License: ~ MIT (or more permissive) [via base16-schemes-source] 37 | Maintainer: @highlightjs/core-team 38 | Version: 2021.09.0 39 | */ 40 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#333}.hljs ::selection,.hljs::selection{color:#333}.hljs-comment{color:#969896}.hljs-tag{color:#e8e8e8}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#333}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#ed6a43}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#0086b3}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#795da3}.hljs-strong{font-weight:700;color:#795da3}.hljs-addition,.hljs-built_in,.hljs-code,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp,.hljs-string,.hljs-title.class_.inherited__{color:#183691}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#795da3}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#a71d5d}.hljs-emphasis{color:#a71d5d;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#333}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 41 | case .google: 42 | /* 43 | Theme: Google Light 44 | Author: Seth Wright (http://sethawright.com) 45 | License: ~ MIT (or more permissive) [via base16-schemes-source] 46 | Maintainer: @highlightjs/core-team 47 | Version: 2021.09.0 48 | */ 49 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#373b41}.hljs ::selection,.hljs::selection{color:#373b41}.hljs-comment{color:#b4b7b4}.hljs-tag{color:#969896}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#373b41}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#cc342b}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#f96a38}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#fba922}.hljs-strong{font-weight:700;color:#fba922}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#198844}.hljs-attribute,.hljs-built_in,.hljs-doctag,.hljs-function .hljs-title,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#3971ed}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#a36ac7}.hljs-emphasis{color:#a36ac7;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#3971ed}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 50 | case .gradient: 51 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#250482}.hljs-subtr{color:#01958b}.hljs-comment,.hljs-doctag,.hljs-meta,.hljs-quote{color:#cb7200}.hljs-attr,.hljs-regexp,.hljs-selector-id,.hljs-selector-tag,.hljs-tag,.hljs-template-tag{color:#07bd5f}.hljs-bullet,.hljs-params,.hljs-selector-class{color:#43449f}.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-section,.hljs-symbol,.hljs-type{color:#7d2801}.hljs-addition,.hljs-link,.hljs-number{color:#7f0096}.hljs-string{color:#2681ab}.hljs-addition,.hljs-attribute{color:#296562}.hljs-template-variable,.hljs-variable{color:#025c8f}.hljs-built_in,.hljs-class,.hljs-formula,.hljs-function,.hljs-name,.hljs-title{color:#529117}.hljs-deletion,.hljs-literal,.hljs-selector-pseudo{color:#ad13ff}.hljs-emphasis,.hljs-quote{font-style:italic}.hljs-keyword,.hljs-params,.hljs-section,.hljs-selector-class,.hljs-selector-id,.hljs-selector-tag,.hljs-strong,.hljs-template-tag{font-weight:700}" 52 | case .grayscale: 53 | /* 54 | Theme: Grayscale Light 55 | Author: Alexandre Gavioli (https://github.com/Alexx2/) 56 | License: ~ MIT (or more permissive) [via base16-schemes-source] 57 | Maintainer: @highlightjs/core-team 58 | Version: 2021.09.0 59 | */ 60 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#464646}.hljs ::selection,.hljs::selection{color:#464646}.hljs-comment{color:#ababab}.hljs-tag{color:#525252}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#464646}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#7c7c7c}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#999}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#a0a0a0}.hljs-strong{font-weight:700;color:#a0a0a0}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#8e8e8e}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#868686}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#686868}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#747474}.hljs-emphasis{color:#747474;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#5e5e5e}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 61 | case .harmonic16: 62 | /* 63 | Theme: Harmonic16 Light 64 | Author: Jannik Siebert (https://github.com/janniks) 65 | License: ~ MIT (or more permissive) [via base16-schemes-source] 66 | Maintainer: @highlightjs/core-team 67 | Version: 2021.09.0 68 | */ 69 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#405c79}.hljs ::selection,.hljs::selection{color:#405c79}.hljs-comment{color:#aabcce}.hljs-tag{color:#627e99}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#405c79}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#bf8b56}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#bfbf56}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#8bbf56}.hljs-strong{font-weight:700;color:#8bbf56}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#56bf8b}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#568bbf}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#8b56bf}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#bf568b}.hljs-emphasis{color:#bf568b;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#bf5656}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 70 | case .heetch: 71 | /* 72 | Theme: Heetch Light 73 | Author: Geoffrey Teale (tealeg@gmail.com) 74 | License: ~ MIT (or more permissive) [via base16-schemes-source] 75 | Maintainer: @highlightjs/core-team 76 | Version: 2021.09.0 77 | */ 78 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#5a496e}.hljs ::selection,.hljs::selection{color:#5a496e}.hljs-comment{color:#9c92a8}.hljs-tag{color:#ddd6e5}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#5a496e}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#27d9d5}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#bdb6c5}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#5ba2b6}.hljs-strong{font-weight:700;color:#5ba2b6}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#f80059}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#c33678}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#47f9f5}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#bd0152}.hljs-emphasis{color:#bd0152;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#dedae2}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 79 | case .horizon: 80 | /* 81 | Theme: Horizon Light 82 | Author: Michaël Ball (http://github.com/michael-ball/) 83 | License: ~ MIT (or more permissive) [via base16-schemes-source] 84 | Maintainer: @highlightjs/core-team 85 | Version: 2021.09.0 86 | */ 87 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#403c3d}.hljs ::selection,.hljs::selection{color:#403c3d}.hljs-comment{color:#bdb3b1}.hljs-tag{color:#948c8a}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#403c3d}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#e95678}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#f9cec3}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#fadad1}.hljs-strong{font-weight:700;color:#fadad1}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#29d398}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#59e1e3}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#26bbd9}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#ee64ac}.hljs-emphasis{color:#ee64ac;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#f9cbbe}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 88 | case .humanoid: 89 | /* 90 | Theme: Humanoid light 91 | Author: Thomas (tasmo) Friese 92 | License: ~ MIT (or more permissive) [via base16-schemes-source] 93 | Maintainer: @highlightjs/core-team 94 | Version: 2021.09.0 95 | */ 96 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#232629}.hljs ::selection,.hljs::selection{color:#232629}.hljs-comment{color:#c0c0bd}.hljs-tag{color:#60615d}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#232629}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#b0151a}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#ff3d00}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#ffb627}.hljs-strong{font-weight:700;color:#ffb627}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#388e3c}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#008e8e}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#0082c9}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#700f98}.hljs-emphasis{color:#700f98;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#b27701}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 97 | case .ia: 98 | /* 99 | Theme: iA Light 100 | Author: iA Inc. (modified by aramisgithub) 101 | License: ~ MIT (or more permissive) [via base16-schemes-source] 102 | Maintainer: @highlightjs/core-team 103 | Version: 2021.09.0 104 | */ 105 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#181818}.hljs ::selection,.hljs::selection{color:#181818}.hljs-comment{color:#898989}.hljs-tag{color:#767676}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#181818}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#9c5a02}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#c43e18}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#c48218}.hljs-strong{font-weight:700;color:#c48218}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#38781c}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#2d6bb1}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#48bac2}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#a94598}.hljs-emphasis{color:#a94598;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#8b6c37}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 106 | case .isblEditor: 107 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#000}.hljs-subst{color:#000}.hljs-comment{color:#555;font-style:italic}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{color:#000;font-weight:700}.hljs-string{color:navy}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-template-tag,.hljs-type{color:#000}.hljs-link,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#5e1700}.hljs-built_in,.hljs-literal{color:navy;font-weight:700}.hljs-addition,.hljs-bullet,.hljs-code{color:#397300}.hljs-class{color:#6f1c00;font-weight:700}.hljs-section,.hljs-title{color:#fb2c00}.hljs-title>.hljs-built_in{color:teal;font-weight:400}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}" 108 | case .kimbie: 109 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#84613d}.hljs-comment,.hljs-quote{color:#a57a4c}.hljs-meta,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#dc3958}.hljs-built_in,.hljs-deletion,.hljs-link,.hljs-literal,.hljs-number,.hljs-params,.hljs-type{color:#f79a32}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#889b4a}.hljs-function,.hljs-keyword,.hljs-selector-tag{color:#98676a}.hljs-attribute,.hljs-section,.hljs-title{color:#f06431}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}" 110 | case .nnfx: 111 | /* 112 | Theme: nnfx light 113 | Description: a theme inspired by Netscape Navigator/Firefox 114 | Author: (c) 2020-2021 Jim Mason 115 | Maintainer: @RocketMan 116 | License: https://creativecommons.org/licenses/by-sa/4.0 CC BY-SA 4.0 117 | Updated: 2021-05-17 118 | 119 | @version 1.1.0 120 | */ 121 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#000}.language-xml .hljs-meta,.language-xml .hljs-meta-string{font-weight:700;font-style:italic;color:#48b}.hljs-comment,.hljs-quote{font-style:italic;color:#070}.hljs-built_in,.hljs-keyword,.hljs-name{color:#808}.hljs-attr,.hljs-name{font-weight:700}.hljs-string{font-weight:400}.hljs-code,.hljs-link,.hljs-meta .hljs-string,.hljs-number,.hljs-regexp,.hljs-string{color:#00f}.hljs-bullet,.hljs-symbol,.hljs-template-variable,.hljs-title,.hljs-variable{color:#f40}.hljs-class .hljs-title,.hljs-title.class_,.hljs-type{font-weight:700;color:#639}.hljs-attr,.hljs-function .hljs-title,.hljs-subst,.hljs-tag,.hljs-title.function_{color:#000}.hljs-formula{font-style:italic}.hljs-meta{color:#269}.hljs-section,.hljs-selector-class,.hljs-selector-id,.hljs-selector-pseudo,.hljs-selector-tag{font-weight:700;color:#48b}.hljs-selector-pseudo{font-style:italic}.hljs-doctag,.hljs-strong{font-weight:700}.hljs-emphasis{font-style:italic}" 122 | case .pandaSyntax: 123 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#2a2c2d}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}.hljs-comment,.hljs-quote{color:#676b79;font-style:italic}.hljs-params{color:#676b79}.hljs-attr,.hljs-punctuation{color:#2a2c2d}.hljs-char.escape_,.hljs-meta,.hljs-name,.hljs-operator,.hljs-selector-tag{color:#c56200}.hljs-deletion,.hljs-keyword{color:#d92792}.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-variable.language_{color:#cc5e91}.hljs-code,.hljs-formula,.hljs-property,.hljs-section,.hljs-subst,.hljs-title.function_{color:#3787c7}.hljs-addition,.hljs-bullet,.hljs-meta .hljs-string,.hljs-selector-class,.hljs-string,.hljs-symbol,.hljs-title.class_,.hljs-title.class_.inherited__{color:#0d7d6c}.hljs-attribute,.hljs-built_in,.hljs-doctag,.hljs-link,.hljs-literal,.hljs-meta .hljs-keyword,.hljs-number,.hljs-selector-id,.hljs-tag,.hljs-template-tag,.hljs-template-variable,.hljs-title,.hljs-type,.hljs-variable{color:#7641bb}" 124 | case .papercolor: 125 | /* 126 | Theme: PaperColor Light 127 | Author: Jon Leopard (http://github.com/jonleopard) based on PaperColor Theme (https://github.com/NLKNguyen/papercolor-theme) 128 | License: ~ MIT (or more permissive) [via base16-schemes-source] 129 | Maintainer: @highlightjs/core-team 130 | Version: 2021.09.0 131 | */ 132 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#444}.hljs ::selection,.hljs::selection{color:#444}.hljs-comment{color:#5f8700}.hljs-tag{color:#0087af}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#444}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#bcbcbc}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#d70000}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#d70087}.hljs-strong{font-weight:700;color:#d70087}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#8700af}.hljs-attribute,.hljs-built_in,.hljs-doctag,.hljs-function .hljs-title,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#d75f00}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#005faf}.hljs-emphasis{color:#005faf;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#005f87}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 133 | case .paraiso: 134 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#4f424c}.hljs-comment,.hljs-quote{color:#776e71}.hljs-link,.hljs-meta,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#ef6155}.hljs-built_in,.hljs-deletion,.hljs-literal,.hljs-number,.hljs-params,.hljs-type{color:#f99b15}.hljs-attribute,.hljs-section,.hljs-title{color:#fec418}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#48b685}.hljs-keyword,.hljs-selector-tag{color:#815ba4}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}" 135 | case .qtcreator: 136 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#000}.hljs-emphasis,.hljs-strong{color:#000}.hljs-bullet,.hljs-literal,.hljs-number,.hljs-quote,.hljs-regexp{color:navy}.hljs-code .hljs-selector-class{color:purple}.hljs-emphasis,.hljs-stronge,.hljs-type{font-style:italic}.hljs-function,.hljs-keyword,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-symbol{color:olive}.hljs-subst,.hljs-tag,.hljs-title{color:#000}.hljs-attribute{color:maroon}.hljs-class .hljs-title,.hljs-params,.hljs-title.class_,.hljs-variable{color:#0055af}.hljs-addition,.hljs-built_in,.hljs-comment,.hljs-deletion,.hljs-link,.hljs-meta,.hljs-selector-attr,.hljs-selector-id,.hljs-selector-pseudo,.hljs-string,.hljs-template-tag,.hljs-template-variable,.hljs-type{color:green}" 137 | case .silk: 138 | /* 139 | Theme: Silk Light 140 | Author: Gabriel Fontes (https://github.com/Misterio77) 141 | License: ~ MIT (or more permissive) [via base16-schemes-source] 142 | Maintainer: @highlightjs/core-team 143 | Version: 2021.09.0 144 | */ 145 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#385156}.hljs ::selection,.hljs::selection{color:#385156}.hljs-comment{color:#5c787b}.hljs-tag{color:#4b5b5f}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#385156}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#cf432e}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#d27f46}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#cfad25}.hljs-strong{font-weight:700;color:#cfad25}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#6ca38c}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#329ca2}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#39aac9}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#6e6582}.hljs-emphasis{color:#6e6582;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#865369}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 146 | case .solarFlare: 147 | /* 148 | Theme: Solar Flare Light 149 | Author: Chuck Harmston (https://chuck.harmston.ch) 150 | License: ~ MIT (or more permissive) [via base16-schemes-source] 151 | Maintainer: @highlightjs/core-team 152 | Version: 2021.09.0 153 | */ 154 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#586875}.hljs ::selection,.hljs::selection{color:#586875}.hljs-comment{color:#85939e}.hljs-tag{color:#667581}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#586875}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#ef5253}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#e66b2b}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#e4b51c}.hljs-strong{font-weight:700;color:#e4b51c}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#7cc844}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#52cbb0}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#33b5e1}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#a363d5}.hljs-emphasis{color:#a363d5;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#d73c9a}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 155 | case .solarized: 156 | /* 157 | Theme: Solarized Light 158 | Author: Ethan Schoonover (modified by aramisgithub) 159 | License: ~ MIT (or more permissive) [via base16-schemes-source] 160 | Maintainer: @highlightjs/core-team 161 | Version: 2021.09.0 162 | */ 163 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#586e75}.hljs ::selection,.hljs::selection{color:#586e75}.hljs-comment{color:#839496}.hljs-tag{color:#657b83}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#586e75}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#dc322f}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#cb4b16}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#b58900}.hljs-strong{font-weight:700;color:#b58900}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#859900}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#2aa198}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#268bd2}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#6c71c4}.hljs-emphasis{color:#6c71c4;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#d33682}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 164 | case .stackoverflow: 165 | /* 166 | Theme: StackOverflow Light 167 | Description: Light theme as used on stackoverflow.com 168 | Author: stackoverflow.com 169 | Maintainer: @Hirse 170 | Website: https://github.com/StackExchange/Stacks 171 | License: MIT 172 | Updated: 2021-05-15 173 | 174 | Updated for @stackoverflow/stacks v0.64.0 175 | Code Blocks: /blob/v0.64.0/lib/css/components/_stacks-code-blocks.less 176 | Colors: /blob/v0.64.0/lib/css/exports/_stacks-constants-colors.less 177 | */ 178 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#2f3337}.hljs-subst{color:#2f3337}.hljs-comment{color:#656e77}.hljs-attr,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-section,.hljs-selector-tag{color:#015692}.hljs-attribute{color:#803378}.hljs-name,.hljs-number,.hljs-quote,.hljs-selector-id,.hljs-template-tag,.hljs-type{color:#b75501}.hljs-selector-class{color:#015692}.hljs-link,.hljs-regexp,.hljs-selector-attr,.hljs-string,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#54790d}.hljs-meta,.hljs-selector-pseudo{color:#015692}.hljs-built_in,.hljs-literal,.hljs-title{color:#b75501}.hljs-bullet,.hljs-code{color:#535a60}.hljs-meta .hljs-string{color:#54790d}.hljs-deletion{color:#c02d2e}.hljs-addition{color:#2f6f44}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}" 179 | case .standard: 180 | /* 181 | Theme: Default Light 182 | Author: Chris Kempson (http://chriskempson.com) 183 | License: ~ MIT (or more permissive) [via base16-schemes-source] 184 | Maintainer: @highlightjs/core-team 185 | Version: 2021.09.0 186 | */ 187 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#383838}.hljs ::selection,.hljs::selection{color:#383838}.hljs-comment{color:#b8b8b8}.hljs-tag{color:#585858}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#383838}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#ab4642}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#dc9656}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#f7ca88}.hljs-strong{font-weight:700;color:#f7ca88}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#a1b56c}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#86c1b9}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#7cafc2}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#ba8baf}.hljs-emphasis{color:#ba8baf;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#a16946}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 188 | case .summerfruit: 189 | /* 190 | Theme: Summerfruit Light 191 | Author: Christopher Corley (http://christop.club/) 192 | License: ~ MIT (or more permissive) [via base16-schemes-source] 193 | Maintainer: @highlightjs/core-team 194 | Version: 2021.09.0 195 | */ 196 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#101010}.hljs ::selection,.hljs::selection{color:#101010}.hljs-comment{color:#b0b0b0}.hljs-tag{color:#000}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#101010}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#ff0086}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#fd8900}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#aba800}.hljs-strong{font-weight:700;color:#aba800}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#00c918}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#1faaaa}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#3777e6}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#ad00a1}.hljs-emphasis{color:#ad00a1;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#c63}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 197 | case .synthMidnightTerminal: 198 | /* 199 | Theme: Synth Midnight Terminal Light 200 | Author: Michaël Ball (http://github.com/michael-ball/) 201 | License: ~ MIT (or more permissive) [via base16-schemes-source] 202 | Maintainer: @highlightjs/core-team 203 | Version: 2021.09.0 204 | */ 205 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#28292a}.hljs ::selection,.hljs::selection{color:#28292a}.hljs-comment{color:#a3a5a6}.hljs-tag{color:#474849}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#28292a}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#b53b50}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#ea770d}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#c9d364}.hljs-strong{font-weight:700;color:#c9d364}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#06ea61}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#42fff9}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#03aeff}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#ea5ce2}.hljs-emphasis{color:#ea5ce2;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#cd6320}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 206 | case .tokyoNight: 207 | /* 208 | Theme: Tokyo-night-light 209 | origin: https://github.com/enkia/tokyo-night-vscode-theme 210 | Description: Original highlight.js style 211 | Author: (c) Henri Vandersleyen 212 | License: see project LICENSE 213 | Touched: 2022 214 | */ 215 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs-comment,.hljs-meta{color:#9699a3}.hljs-deletion,.hljs-doctag,.hljs-regexp,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-selector-pseudo,.hljs-tag,.hljs-template-tag,.hljs-variable.language_{color:#8c4351}.hljs-link,.hljs-literal,.hljs-number,.hljs-params,.hljs-template-variable,.hljs-type,.hljs-variable{color:#965027}.hljs-attribute,.hljs-built_in{color:#8f5e15}.hljs-keyword,.hljs-property,.hljs-subst,.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#0f4b6e}.hljs-selector-tag{color:#33635c}.hljs-addition,.hljs-bullet,.hljs-quote,.hljs-string,.hljs-symbol{color:#485e30}.hljs-code,.hljs-formula,.hljs-section{color:#34548a}.hljs-attr,.hljs-char.escape_,.hljs-keyword,.hljs-name,.hljs-operator{color:#5a4a78}.hljs-punctuation{color:#343b58}.hljs{color:#565a6e}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}" 216 | case .unikitty: 217 | /* 218 | Theme: Unikitty Light 219 | Author: Josh W Lewis (@joshwlewis) 220 | License: ~ MIT (or more permissive) [via base16-schemes-source] 221 | Maintainer: @highlightjs/core-team 222 | Version: 2021.09.0 223 | */ 224 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#6c696e}.hljs ::selection,.hljs::selection{color:#6c696e}.hljs-comment{color:#a7a5a8}.hljs-tag{color:#89878b}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#6c696e}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#d8137f}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#d65407}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#dc8a0e}.hljs-strong{font-weight:700;color:#dc8a0e}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#17ad98}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#149bda}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#775dff}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#aa17e6}.hljs-emphasis{color:#aa17e6;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#e013d0}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 225 | case .xcode: 226 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#000}.xml .hljs-meta{color:silver}.hljs-comment,.hljs-quote{color:#007400}.hljs-attribute,.hljs-keyword,.hljs-literal,.hljs-name,.hljs-selector-tag,.hljs-tag{color:#aa0d91}.hljs-template-variable,.hljs-variable{color:#3f6e74}.hljs-code,.hljs-meta .hljs-string,.hljs-string{color:#c41a16}.hljs-link,.hljs-regexp{color:#0e0eff}.hljs-bullet,.hljs-number,.hljs-symbol,.hljs-title{color:#1c00cf}.hljs-meta,.hljs-section{color:#643820}.hljs-built_in,.hljs-class .hljs-title,.hljs-params,.hljs-title.class_,.hljs-type{color:#5c2699}.hljs-attr{color:#836c28}.hljs-subst{color:#000}.hljs-formula{font-style:italic}.hljs-selector-class,.hljs-selector-id{color:#9b703f}.hljs-doctag,.hljs-strong{font-weight:700}.hljs-emphasis{font-style:italic}" 227 | } 228 | } 229 | 230 | static func dark(_ theme: HighlightTheme) -> String { 231 | switch theme { 232 | case .a11y: 233 | /* 234 | Theme: a11y-dark 235 | Author: @ericwbailey 236 | Maintainer: @ericwbailey 237 | 238 | Based on the Tomorrow Night Eighties theme: https://github.com/isagalaev/highlight.js/blob/master/src/styles/tomorrow-night-eighties.css 239 | */ 240 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#f8f8f2}.hljs-comment,.hljs-quote{color:#d4d0ab}.hljs-deletion,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#ffa07a}.hljs-built_in,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-type{color:#f5ab35}.hljs-attribute{color:gold}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#abe338}.hljs-section,.hljs-title{color:#00e0e0}.hljs-keyword,.hljs-selector-tag{color:#dcc6e0}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}@media screen and (-ms-high-contrast:active){.hljs-addition,.hljs-attribute,.hljs-built_in,.hljs-bullet,.hljs-comment,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-quote,.hljs-string,.hljs-symbol,.hljs-type{color:highlight}.hljs-keyword,.hljs-selector-tag{font-weight:700}}" 241 | case .atomOne: 242 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#abb2bf}.hljs-comment,.hljs-quote{color:#5c6370;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#c678dd}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#98c379}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#d19a66}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#61aeee}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#e6c07b}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}" 243 | case .classic: 244 | /* 245 | Theme: Classic Dark 246 | Author: Jason Heeris (http://heeris.id.au) 247 | License: ~ MIT (or more permissive) [via base16-schemes-source] 248 | Maintainer: @highlightjs/core-team 249 | Version: 2021.09.0 250 | */ 251 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#d0d0d0}.hljs ::selection,.hljs::selection{color:#d0d0d0}.hljs-comment{color:#505050}.hljs-tag{color:#b0b0b0}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#d0d0d0}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#ac4142}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#d28445}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#f4bf75}.hljs-strong{font-weight:700;color:#f4bf75}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#90a959}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#75b5aa}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#6a9fb5}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#aa759f}.hljs-emphasis{color:#aa759f;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#8f5536}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 252 | case .edge: 253 | /* 254 | Theme: Edge Dark 255 | Author: cjayross (https://github.com/cjayross) 256 | License: ~ MIT (or more permissive) [via base16-schemes-source] 257 | Maintainer: @highlightjs/core-team 258 | Version: 2021.09.0 259 | */ 260 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#b7bec9}.hljs ::selection,.hljs::selection{color:#b7bec9}.hljs-comment{color:#3e4249}.hljs-tag{color:#73b3e7}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#b7bec9}.hljs-operator{opacity:.7}.hljs-attr,.hljs-bullet,.hljs-deletion,.hljs-link,.hljs-literal,.hljs-name,.hljs-number,.hljs-selector-tag,.hljs-symbol,.hljs-template-variable,.hljs-variable,.hljs-variable.constant_{color:#e77171}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#dbb774}.hljs-strong{font-weight:700;color:#dbb774}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#a1bf78}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#5ebaa5}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#73b3e7}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#d390e7}.hljs-emphasis{color:#d390e7;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#5ebaa5}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 261 | case .github: 262 | /* 263 | Theme: GitHub Dark 264 | Description: Dark theme as seen on github.com 265 | Author: github.com 266 | Maintainer: @Hirse 267 | Updated: 2021-05-15 268 | 269 | Outdated base version: https://github.com/primer/github-syntax-dark 270 | Current colors taken from GitHub's CSS 271 | */ 272 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#c9d1d9}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4}.hljs-deletion{color:#ffdcd7}" 273 | case .google: 274 | /* 275 | Theme: Google Dark 276 | Author: Seth Wright (http://sethawright.com) 277 | License: ~ MIT (or more permissive) [via base16-schemes-source] 278 | Maintainer: @highlightjs/core-team 279 | Version: 2021.09.0 280 | */ 281 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#c5c8c6}.hljs ::selection,.hljs::selection{color:#c5c8c6}.hljs-comment{color:#969896}.hljs-tag{color:#b4b7b4}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#c5c8c6}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#cc342b}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#f96a38}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#fba922}.hljs-strong{font-weight:700;color:#fba922}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#198844}.hljs-attribute,.hljs-built_in,.hljs-doctag,.hljs-function .hljs-title,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#3971ed}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#a36ac7}.hljs-emphasis{color:#a36ac7;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#3971ed}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 282 | case .gradient: 283 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#e7e4eb}.hljs-subtr{color:#e7e4eb}.hljs-comment,.hljs-doctag,.hljs-meta,.hljs-quote{color:#af8dd9}.hljs-attr,.hljs-regexp,.hljs-selector-id,.hljs-selector-tag,.hljs-tag,.hljs-template-tag{color:#aefbff}.hljs-bullet,.hljs-params,.hljs-selector-class{color:#f19fff}.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-section,.hljs-symbol,.hljs-type{color:#17fc95}.hljs-addition,.hljs-link,.hljs-number{color:#c5fe00}.hljs-string{color:#38c0ff}.hljs-addition,.hljs-attribute{color:#e7ff9f}.hljs-template-variable,.hljs-variable{color:#e447ff}.hljs-built_in,.hljs-class,.hljs-formula,.hljs-function,.hljs-name,.hljs-title{color:#ffc800}.hljs-deletion,.hljs-literal,.hljs-selector-pseudo{color:#ff9e44}.hljs-emphasis,.hljs-quote{font-style:italic}.hljs-keyword,.hljs-params,.hljs-section,.hljs-selector-class,.hljs-selector-id,.hljs-selector-tag,.hljs-strong,.hljs-template-tag{font-weight:700}" 284 | case .grayscale: 285 | /* 286 | Theme: Grayscale Dark 287 | Author: Alexandre Gavioli (https://github.com/Alexx2/) 288 | License: ~ MIT (or more permissive) [via base16-schemes-source] 289 | Maintainer: @highlightjs/core-team 290 | Version: 2021.09.0 291 | */ 292 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#b9b9b9}.hljs ::selection,.hljs::selection{color:#b9b9b9}.hljs-comment{color:#525252}.hljs-tag{color:#ababab}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#b9b9b9}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#7c7c7c}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#999}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#a0a0a0}.hljs-strong{font-weight:700;color:#a0a0a0}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#8e8e8e}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#868686}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#686868}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#747474}.hljs-emphasis{color:#747474;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#5e5e5e}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 293 | case .harmonic16: 294 | /* 295 | Theme: Harmonic16 Dark 296 | Author: Jannik Siebert (https://github.com/janniks) 297 | License: ~ MIT (or more permissive) [via base16-schemes-source] 298 | Maintainer: @highlightjs/core-team 299 | Version: 2021.09.0 300 | */ 301 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#cbd6e2}.hljs ::selection,.hljs::selection{color:#cbd6e2}.hljs-comment{color:#627e99}.hljs-tag{color:#aabcce}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#cbd6e2}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#bf8b56}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#bfbf56}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#8bbf56}.hljs-strong{font-weight:700;color:#8bbf56}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#56bf8b}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#568bbf}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#8b56bf}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#bf568b}.hljs-emphasis{color:#bf568b;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#bf5656}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 302 | case .heetch: 303 | /* 304 | Theme: Heetch Dark 305 | Author: Geoffrey Teale (tealeg@gmail.com) 306 | License: ~ MIT (or more permissive) [via base16-schemes-source] 307 | Maintainer: @highlightjs/core-team 308 | Version: 2021.09.0 309 | */ 310 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#bdb6c5}.hljs ::selection,.hljs::selection{color:#bdb6c5}.hljs-comment{color:#7b6d8b}.hljs-tag{color:#9c92a8}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#bdb6c5}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#27d9d5}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#5ba2b6}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#8f6c97}.hljs-strong{font-weight:700;color:#8f6c97}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#c33678}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#f80059}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#bd0152}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#82034c}.hljs-emphasis{color:#82034c;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#470546}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 311 | case .horizon: 312 | /* 313 | Theme: Horizon Dark 314 | Author: Michaël Ball (http://github.com/michael-ball/) 315 | License: ~ MIT (or more permissive) [via base16-schemes-source] 316 | Maintainer: @highlightjs/core-team 317 | Version: 2021.09.0 318 | */ 319 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#cbced0}.hljs ::selection,.hljs::selection{color:#cbced0}.hljs-comment{color:#6f6f70}.hljs-tag{color:#9da0a2}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#cbced0}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#e93c58}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#e58d7d}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#efb993}.hljs-strong{font-weight:700;color:#efb993}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#efaf8e}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#24a8b4}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#df5273}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#b072d1}.hljs-emphasis{color:#b072d1;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#e4a382}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 320 | case .humanoid: 321 | /* 322 | Theme: Humanoid dark 323 | Author: Thomas (tasmo) Friese 324 | License: ~ MIT (or more permissive) [via base16-schemes-source] 325 | Maintainer: @highlightjs/core-team 326 | Version: 2021.09.0 327 | */ 328 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#f8f8f2}.hljs ::selection,.hljs::selection{color:#f8f8f2}.hljs-comment{color:#60615d}.hljs-tag{color:#c0c0bd}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#f8f8f2}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#f11235}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#ff9505}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#ffb627}.hljs-strong{font-weight:700;color:#ffb627}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#02d849}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#0dd9d6}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#00a6fb}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#f15ee3}.hljs-emphasis{color:#f15ee3;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#b27701}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 329 | case .ia: 330 | /* 331 | Theme: iA Dark 332 | Author: iA Inc. (modified by aramisgithub) 333 | License: ~ MIT (or more permissive) [via base16-schemes-source] 334 | Maintainer: @highlightjs/core-team 335 | Version: 2021.09.0 336 | */ 337 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#ccc}.hljs ::selection,.hljs::selection{color:#ccc}.hljs-comment{color:#767676}.hljs-tag{color:#b8b8b8}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#ccc}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#d88568}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#d86868}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#b99353}.hljs-strong{font-weight:700;color:#b99353}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#83a471}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#7c9cae}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#8eccdd}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#b98eb2}.hljs-emphasis{color:#b98eb2;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#8b6c37}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 338 | case .isblEditor: 339 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs,.hljs-subst{color:#f0f0f0}.hljs-comment{color:#b5b5b5;font-style:italic}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{color:#f0f0f0;font-weight:700}.hljs-string{color:#97bf0d}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-template-tag,.hljs-type{color:#f0f0f0}.hljs-link,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#e2c696}.hljs-built_in,.hljs-literal{color:#97bf0d;font-weight:700}.hljs-addition,.hljs-bullet,.hljs-code{color:#397300}.hljs-class{color:#ce9d4d;font-weight:700}.hljs-section,.hljs-title{color:#df471e}.hljs-title>.hljs-built_in{color:#81bce9;font-weight:400}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}" 340 | case .kimbie: 341 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#d3af86}.hljs-comment,.hljs-quote{color:#d6baad}.hljs-meta,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#dc3958}.hljs-built_in,.hljs-deletion,.hljs-link,.hljs-literal,.hljs-number,.hljs-params,.hljs-type{color:#f79a32}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#889b4a}.hljs-function,.hljs-keyword,.hljs-selector-tag{color:#98676a}.hljs-attribute,.hljs-section,.hljs-title{color:#f06431}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}" 342 | case .nnfx: 343 | /* 344 | Theme: nnfx dark 345 | Description: a theme inspired by Netscape Navigator/Firefox 346 | Author: (c) 2020-2021 Jim Mason 347 | Maintainer: @RocketMan 348 | License: https://creativecommons.org/licenses/by-sa/4.0 CC BY-SA 4.0 349 | Updated: 2021-05-17 350 | 351 | @version 1.1.0 352 | */ 353 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#fff}.language-xml .hljs-meta,.language-xml .hljs-meta-string{font-weight:700;font-style:italic;color:#69f}.hljs-comment,.hljs-quote{font-style:italic;color:#9c6}.hljs-built_in,.hljs-keyword,.hljs-name{color:#a7a}.hljs-attr,.hljs-name{font-weight:700}.hljs-string{font-weight:400}.hljs-code,.hljs-link,.hljs-meta .hljs-string,.hljs-number,.hljs-regexp,.hljs-string{color:#bce}.hljs-bullet,.hljs-symbol,.hljs-template-variable,.hljs-title,.hljs-variable{color:#d40}.hljs-class .hljs-title,.hljs-title.class_,.hljs-type{font-weight:700;color:#96c}.hljs-attr,.hljs-function .hljs-title,.hljs-subst,.hljs-tag,.hljs-title.function_{color:#fff}.hljs-formula{font-style:italic}.hljs-meta{color:#69f}.hljs-section,.hljs-selector-class,.hljs-selector-id,.hljs-selector-pseudo,.hljs-selector-tag{font-weight:700;color:#69f}.hljs-selector-pseudo{font-style:italic}.hljs-doctag,.hljs-strong{font-weight:700}.hljs-emphasis{font-style:italic}" 354 | case .pandaSyntax: 355 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#e6e6e6}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}.hljs-comment,.hljs-quote{color:#bbb;font-style:italic}.hljs-params{color:#bbb}.hljs-attr,.hljs-punctuation{color:#e6e6e6}.hljs-meta,.hljs-name,.hljs-selector-tag{color:#ff4b82}.hljs-char.escape_,.hljs-operator{color:#b084eb}.hljs-deletion,.hljs-keyword{color:#ff75b5}.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-variable.language_{color:#ff9ac1}.hljs-code,.hljs-formula,.hljs-property,.hljs-section,.hljs-subst,.hljs-title.function_{color:#45a9f9}.hljs-addition,.hljs-bullet,.hljs-meta .hljs-string,.hljs-selector-class,.hljs-string,.hljs-symbol,.hljs-title.class_,.hljs-title.class_.inherited__{color:#19f9d8}.hljs-attribute,.hljs-built_in,.hljs-doctag,.hljs-link,.hljs-literal,.hljs-meta .hljs-keyword,.hljs-number,.hljs-punctuation,.hljs-selector-id,.hljs-tag,.hljs-template-tag,.hljs-template-variable,.hljs-title,.hljs-type,.hljs-variable{color:#ffb86c}" 356 | case .papercolor: 357 | /* 358 | Theme: PaperColor Dark 359 | Author: Jon Leopard (http://github.com/jonleopard) based on PaperColor Theme (https://github.com/NLKNguyen/papercolor-theme) 360 | License: ~ MIT (or more permissive) [via base16-schemes-source] 361 | Maintainer: @highlightjs/core-team 362 | Version: 2021.09.0 363 | */ 364 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:grey}.hljs ::selection,.hljs::selection{color:grey}.hljs-comment{color:#d7af5f}.hljs-tag{color:#5fafd7}.hljs-operator,.hljs-punctuation,.hljs-subst{color:grey}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#585858}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#5faf5f}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#afd700}.hljs-strong{font-weight:700;color:#afd700}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#af87d7}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#ffaf00}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#ff5faf}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#00afaf}.hljs-emphasis{color:#00afaf;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#5f8787}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 365 | case .paraiso: 366 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#a39e9b}.hljs-comment,.hljs-quote{color:#8d8687}.hljs-link,.hljs-meta,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#ef6155}.hljs-built_in,.hljs-deletion,.hljs-literal,.hljs-number,.hljs-params,.hljs-type{color:#f99b15}.hljs-attribute,.hljs-section,.hljs-title{color:#fec418}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#48b685}.hljs-keyword,.hljs-selector-tag{color:#815ba4}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}" 367 | case .qtcreator: 368 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#aaa}.hljs-emphasis,.hljs-strong{color:#a8a8a2}.hljs-bullet,.hljs-literal,.hljs-number,.hljs-quote,.hljs-regexp{color:#f5f}.hljs-code .hljs-selector-class{color:#aaf}.hljs-emphasis,.hljs-stronge,.hljs-type{font-style:italic}.hljs-function,.hljs-keyword,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-symbol{color:#ff5}.hljs-subst,.hljs-tag,.hljs-title{color:#aaa}.hljs-attribute{color:#f55}.hljs-class .hljs-title,.hljs-params,.hljs-title.class_,.hljs-variable{color:#88f}.hljs-addition,.hljs-built_in,.hljs-link,.hljs-selector-attr,.hljs-selector-id,.hljs-selector-pseudo,.hljs-string,.hljs-template-tag,.hljs-template-variable,.hljs-type{color:#f5f}.hljs-comment,.hljs-deletion,.hljs-meta{color:#5ff}" 369 | case .silk: 370 | /* 371 | Theme: Silk Dark 372 | Author: Gabriel Fontes (https://github.com/Misterio77) 373 | License: ~ MIT (or more permissive) [via base16-schemes-source] 374 | Maintainer: @highlightjs/core-team 375 | Version: 2021.09.0 376 | */ 377 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#c7dbdd}.hljs ::selection,.hljs::selection{color:#c7dbdd}.hljs-comment{color:#587073}.hljs-tag{color:#9dc8cd}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#c7dbdd}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#fb6953}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#fcab74}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#fce380}.hljs-strong{font-weight:700;color:#fce380}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#73d8ad}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#3fb2b9}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#46bddd}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#756b8a}.hljs-emphasis{color:#756b8a;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#9b647b}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 378 | case .solarFlare: 379 | /* 380 | Theme: Solar Flare 381 | Author: Chuck Harmston (https://chuck.harmston.ch) 382 | License: ~ MIT (or more permissive) [via base16-schemes-source] 383 | Maintainer: @highlightjs/core-team 384 | Version: 2021.09.0 385 | */ 386 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#a6afb8}.hljs ::selection,.hljs::selection{color:#a6afb8}.hljs-comment{color:#667581}.hljs-tag{color:#85939e}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#a6afb8}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#ef5253}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#e66b2b}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#e4b51c}.hljs-strong{font-weight:700;color:#e4b51c}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#7cc844}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#52cbb0}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#33b5e1}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#a363d5}.hljs-emphasis{color:#a363d5;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#d73c9a}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 387 | case .solarized: 388 | /* 389 | Theme: Solarized Dark 390 | Author: Ethan Schoonover (modified by aramisgithub) 391 | License: ~ MIT (or more permissive) [via base16-schemes-source] 392 | Maintainer: @highlightjs/core-team 393 | Version: 2021.09.0 394 | */ 395 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#93a1a1}.hljs ::selection,.hljs::selection{color:#93a1a1}.hljs-comment{color:#657b83}.hljs-tag{color:#839496}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#93a1a1}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#dc322f}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#cb4b16}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#b58900}.hljs-strong{font-weight:700;color:#b58900}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#859900}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#2aa198}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#268bd2}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#6c71c4}.hljs-emphasis{color:#6c71c4;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#d33682}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 396 | case .stackoverflow: 397 | /* 398 | Theme: StackOverflow Dark 399 | Description: Dark theme as used on stackoverflow.com 400 | Author: stackoverflow.com 401 | Maintainer: @Hirse 402 | Website: https://github.com/StackExchange/Stacks 403 | License: MIT 404 | Updated: 2021-05-15 405 | 406 | Updated for @stackoverflow/stacks v0.64.0 407 | Code Blocks: /blob/v0.64.0/lib/css/components/_stacks-code-blocks.less 408 | Colors: /blob/v0.64.0/lib/css/exports/_stacks-constants-colors.less 409 | */ 410 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#fff}.hljs-subst{color:#fff}.hljs-comment{color:#999}.hljs-attr,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-section,.hljs-selector-tag{color:#88aece}.hljs-attribute{color:#c59bc1}.hljs-name,.hljs-number,.hljs-quote,.hljs-selector-id,.hljs-template-tag,.hljs-type{color:#f08d49}.hljs-selector-class{color:#88aece}.hljs-link,.hljs-regexp,.hljs-selector-attr,.hljs-string,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#b5bd68}.hljs-meta,.hljs-selector-pseudo{color:#88aece}.hljs-built_in,.hljs-literal,.hljs-title{color:#f08d49}.hljs-bullet,.hljs-code{color:#ccc}.hljs-meta .hljs-string{color:#b5bd68}.hljs-deletion{color:#de7176}.hljs-addition{color:#76c490}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}" 411 | case .standard: 412 | /* 413 | Theme: Default Dark 414 | Author: Chris Kempson (http://chriskempson.com) 415 | License: ~ MIT (or more permissive) [via base16-schemes-source] 416 | Maintainer: @highlightjs/core-team 417 | Version: 2021.09.0 418 | */ 419 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#d8d8d8}.hljs ::selection,.hljs::selection{color:#d8d8d8}.hljs-comment{color:#585858}.hljs-tag{color:#b8b8b8}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#d8d8d8}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#ab4642}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#dc9656}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#f7ca88}.hljs-strong{font-weight:700;color:#f7ca88}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#a1b56c}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#86c1b9}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#7cafc2}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#ba8baf}.hljs-emphasis{color:#ba8baf;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#a16946}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 420 | case .summerfruit: 421 | /* 422 | Theme: Summerfruit Dark 423 | Author: Christopher Corley (http://christop.club/) 424 | License: ~ MIT (or more permissive) [via base16-schemes-source] 425 | Maintainer: @highlightjs/core-team 426 | Version: 2021.09.0 427 | */ 428 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#d0d0d0}.hljs ::selection,.hljs::selection{color:#d0d0d0}.hljs-comment{color:#505050}.hljs-tag{color:#b0b0b0}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#d0d0d0}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#ff0086}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#fd8900}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#aba800}.hljs-strong{font-weight:700;color:#aba800}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#00c918}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#1faaaa}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#3777e6}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#ad00a1}.hljs-emphasis{color:#ad00a1;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#c63}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 429 | case .synthMidnightTerminal: 430 | /* 431 | Theme: Synth Midnight Terminal Dark 432 | Author: Michaël Ball (http://github.com/michael-ball/) 433 | License: ~ MIT (or more permissive) [via base16-schemes-source] 434 | Maintainer: @highlightjs/core-team 435 | Version: 2021.09.0 436 | */ 437 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#c1c3c4}.hljs ::selection,.hljs::selection{color:#c1c3c4}.hljs-comment{color:#474849}.hljs-tag{color:#a3a5a6}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#c1c3c4}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#b53b50}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#ea770d}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#c9d364}.hljs-strong{font-weight:700;color:#c9d364}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#06ea61}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#42fff9}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#03aeff}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#ea5ce2}.hljs-emphasis{color:#ea5ce2;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#cd6320}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 438 | case .tokyoNight: 439 | /* 440 | Theme: Tokyo-night-Dark 441 | origin: https://github.com/enkia/tokyo-night-vscode-theme 442 | Description: Original highlight.js style 443 | Author: (c) Henri Vandersleyen 444 | License: see project LICENSE 445 | Touched: 2022 446 | */ 447 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs-comment,.hljs-meta{color:#565f89}.hljs-deletion,.hljs-doctag,.hljs-regexp,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-selector-pseudo,.hljs-tag,.hljs-template-tag,.hljs-variable.language_{color:#f7768e}.hljs-link,.hljs-literal,.hljs-number,.hljs-params,.hljs-template-variable,.hljs-type,.hljs-variable{color:#ff9e64}.hljs-attribute,.hljs-built_in{color:#e0af68}.hljs-keyword,.hljs-property,.hljs-subst,.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#7dcfff}.hljs-selector-tag{color:#73daca}.hljs-addition,.hljs-bullet,.hljs-quote,.hljs-string,.hljs-symbol{color:#9ece6a}.hljs-code,.hljs-formula,.hljs-section{color:#7aa2f7}.hljs-attr,.hljs-char.escape_,.hljs-keyword,.hljs-name,.hljs-operator{color:#bb9af7}.hljs-punctuation{color:#c0caf5}.hljs{color:#9aa5ce}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}" 448 | case .unikitty: 449 | /* 450 | Theme: Unikitty Dark 451 | Author: Josh W Lewis (@joshwlewis) 452 | License: ~ MIT (or more permissive) [via base16-schemes-source] 453 | Maintainer: @highlightjs/core-team 454 | Version: 2021.09.0 455 | */ 456 | return "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#bcbabe}.hljs ::selection,.hljs::selection{color:#bcbabe}.hljs-comment{color:#838085}.hljs-tag{color:#9f9da2}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#bcbabe}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#d8137f}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#d65407}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#dc8a0e}.hljs-strong{font-weight:700;color:#dc8a0e}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#17ad98}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#149bda}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#796af5}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#bb60ea}.hljs-emphasis{color:#bb60ea;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#c720ca}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}" 457 | case .xcode: 458 | return ".hljs{display:block;overflow-x:auto;padding:0.5em;color:white}.xml .hljs-meta{color:#6C7986}.hljs-comment,.hljs-quote{color:#6C7986}.hljs-tag,.hljs-attribute,.hljs-keyword,.hljs-selector-tag,.hljs-literal,.hljs-name{color:#FC5FA3}.hljs-variable,.hljs-template-variable{color:#FC5FA3}.hljs-code,.hljs-string,.hljs-meta-string{color:#FC6A5D}.hljs-regexp,.hljs-link{color:#5482FF}.hljs-title,.hljs-symbol,.hljs-bullet,.hljs-number{color:#41A1C0}.hljs-section,.hljs-meta{color:#FC5FA3}.hljs-class .hljs-title,.hljs-type,.hljs-built_in,.hljs-builtin-name,.hljs-params{color:#D0A8FF}.hljs-attr{color:#BF8555}.hljs-subst{color:#FFF}.hljs-formula{font-style:italic}.hljs-selector-id,.hljs-selector-class{color:#9b703f}.hljs-doctag,.hljs-strong{font-weight:bold}.hljs-emphasis{font-style:italic}" 459 | } 460 | } 461 | } 462 | 463 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/Highlight/HighlightColors.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | public struct HighlightColors: Hashable, Sendable { 4 | public let css: String 5 | public let background: String 6 | 7 | public static func dark(_ theme: HighlightTheme) -> HighlightColors { 8 | HighlightColors( 9 | css: HighlightCSS.dark(theme), 10 | background: HighlightBackground.dark(theme) 11 | ) 12 | } 13 | 14 | public static func light(_ theme: HighlightTheme) -> HighlightColors { 15 | HighlightColors( 16 | css: HighlightCSS.light(theme), 17 | background: HighlightBackground.light(theme) 18 | ) 19 | } 20 | 21 | public static func custom(css: String, background: String = "") -> HighlightColors { 22 | HighlightColors(css: css, background: background) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/Highlight/HighlightEntry.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | extension EnvironmentValues { 4 | @Entry var highlight: Highlight = Highlight() 5 | } 6 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/Highlight/HighlightLanguage.swift: -------------------------------------------------------------------------------- 1 | public enum HighlightLanguage: String, Sendable { 2 | var alias: String { 3 | switch self { 4 | case .cPlusPlus: return "cpp" 5 | case .latex: return "tex" 6 | case .phpTemplate: return "phptemp" 7 | case .protocolBuffers: return "protobuf" 8 | case .pythonRepl: return "python-repl" 9 | case .visualBasic: return "vbnet" 10 | case .webAssembly: return "webass" 11 | default: 12 | return rawValue.lowercased() 13 | } 14 | } 15 | 16 | case appleScript 17 | case arduino 18 | case awk 19 | case bash 20 | case basic 21 | case c 22 | case cPlusPlus 23 | case cSharp 24 | case clojure 25 | case css 26 | case dart 27 | case delphi 28 | case diff 29 | case django 30 | case dockerfile 31 | case elixir 32 | case elm 33 | case erlang 34 | case gherkin 35 | case go 36 | case gradle 37 | case graphQL 38 | case haskell 39 | case html 40 | case java 41 | case javaScript 42 | case json 43 | case julia 44 | case kotlin 45 | case latex 46 | case less 47 | case lisp 48 | case lua 49 | case makefile 50 | case markdown 51 | case mathematica 52 | case matlab 53 | case nix 54 | case objectiveC 55 | case perl 56 | case php 57 | case phpTemplate 58 | case plaintext 59 | case postgreSQL 60 | case protocolBuffers 61 | case python 62 | case pythonRepl 63 | case r 64 | case ruby 65 | case rust 66 | case scala 67 | case scss 68 | case shell 69 | case sql 70 | case swift 71 | case toml 72 | case typeScript 73 | case visualBasic 74 | case webAssembly 75 | case yaml 76 | } 77 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/Highlight/HighlightMode.swift: -------------------------------------------------------------------------------- 1 | public enum HighlightMode: Hashable, Sendable { 2 | /// Detect the language automatically 3 | case automatic 4 | 5 | /// Use a specific language alias string 6 | case languageAlias(String) 7 | 8 | /// Use a specific language alias string and continue past illegal matches 9 | case languageAliasIgnoreIllegal(String) 10 | 11 | /// Use a specific language 12 | case language(HighlightLanguage) 13 | 14 | /// Use a specific language and continue past illegal matches 15 | case languageIgnoreIllegal(HighlightLanguage) 16 | } 17 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/Highlight/HighlightResult.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | /// The result of a call to Highlight 4 | public struct HighlightResult: Equatable, Sendable { 5 | /// The syntax highlighted attributed text 6 | public let attributedText: AttributedString 7 | 8 | /// The syntax highlight failed 9 | public let isUndefined: Bool 10 | 11 | /// Illegal matches were found 12 | public let hasIllegal: Bool 13 | 14 | /// The language identifier 15 | public let language: String 16 | 17 | /// The language relevance score 18 | public let relevance: Int 19 | 20 | /// The language name with a question mark if relevance is low. e.g. "Python?", "Swift" or "C++" 21 | public let languageName: String 22 | 23 | /// The highlight style background color 24 | public let backgroundColor: Color 25 | 26 | init(attributedText: AttributedString, 27 | highlightJSResult: HLJSResult, 28 | backgroundColorHex: String) { 29 | self.attributedText = attributedText 30 | self.hasIllegal = highlightJSResult.illegal 31 | if highlightJSResult.language == "undefined" { 32 | self.language = "unknown" 33 | } else { 34 | self.language = highlightJSResult.language 35 | } 36 | self.relevance = Int(highlightJSResult.relevance) 37 | self.isUndefined = highlightJSResult.value == "undefined" 38 | self.languageName = HighlightResult.languageName(highlightJSResult) 39 | self.backgroundColor = HighlightResult.backgroundColor(backgroundColorHex) 40 | } 41 | 42 | private static func languageName(_ result: HLJSResult) -> String { 43 | let name: String 44 | switch result.language { 45 | case "undefined": 46 | name = "Unknown" 47 | return name 48 | case "xml": name = "HTML" 49 | case "cpp": name = "C++" 50 | case "csharp": name = "C#" 51 | case "graphql": name = "GraphQL" 52 | case "pgsql": name = "PostgreSQL" 53 | case "javascript": name = "JavaScript" 54 | case "typescript": name = "TypeScript" 55 | case "objectivec": name = "Objective-C" 56 | case "vbnet": name = "Visual Basic .NET" 57 | case "php-template": name = "PHP Template" 58 | case "css", "sql", "json", "php", "scss", "toml", "yaml", "wasm": 59 | name = result.language.uppercased() 60 | default: 61 | name = result.language.capitalized 62 | } 63 | return name + (result.relevance <= 5 ? "?" : "") 64 | } 65 | 66 | private static func backgroundColor(_ hex: String) -> Color { 67 | var int: UInt64 = 0 68 | let hexString = hex.trimmingCharacters(in: .alphanumerics.inverted) 69 | Scanner(string: hexString).scanHexInt64(&int) 70 | let a, r, g, b: UInt64 71 | switch hexString.count { 72 | case 3: (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) 73 | case 6: (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) 74 | case 8: (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) 75 | default:(a, r, g, b) = (1, 1, 1, 0) 76 | } 77 | func rgba(_ value: UInt64) -> Double { 78 | Double(value) / 255 79 | } 80 | return Color(.sRGB, red: rgba(r), green: rgba(g), blue: rgba(b), opacity: rgba(a)) 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/Highlight/HighlightTheme.swift: -------------------------------------------------------------------------------- 1 | public enum HighlightTheme: String, CaseIterable, Identifiable, Equatable { 2 | case a11y = "a11y" 3 | case atomOne = "Atom One" 4 | case classic = "Classic" 5 | case edge = "Edge" 6 | case github = "GitHub" 7 | case google = "Google" 8 | case gradient = "Gradient" 9 | case grayscale = "Grayscale" 10 | case harmonic16 = "Harmonic16" 11 | case heetch = "Heetch" 12 | case horizon = "Horizon" 13 | case humanoid = "Humanoid" 14 | case ia = "iA" 15 | case isblEditor = "ISBL Editor" 16 | case kimbie = "Kimbie" 17 | case nnfx = "NNFX" 18 | case pandaSyntax = "Panda Syntax" 19 | case papercolor = "Papercolor" 20 | case paraiso = "Paraiso" 21 | case qtcreator = "QT Creator" 22 | case silk = "Silk" 23 | case solarFlare = "Solar Flare" 24 | case solarized = "Solarized" 25 | case stackoverflow = "StackOverflow" 26 | case standard = "Standard" 27 | case summerfruit = "Summerfruit" 28 | case synthMidnightTerminal = "Synth Midnight Terminal" 29 | case tokyoNight = "Tokyo Night" 30 | case unikitty = "Unikitty" 31 | case xcode = "Xcode" 32 | 33 | public var id: String { 34 | rawValue 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Sources/HighlightSwift/HighlightJS/LICENSE.md: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2006, Ivan Sagalaev. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Tests/HighlightSwiftTests/HighlightSwiftTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import HighlightSwift 3 | 4 | final class HighlightSwiftTests: XCTestCase { 5 | let highlight = Highlight() 6 | 7 | let swiftCode: String = """ 8 | import SwiftUI 9 | 10 | struct ContentView: View { 11 | var body: some View { 12 | NavigationView { 13 | List { 14 | Text("Item \\(item)") 15 | } 16 | .navigationTitle("Items") 17 | } 18 | } 19 | } 20 | 21 | struct DetailView: View { 22 | var body: some View { 23 | Text("Detail View") 24 | .font(.largeTitle) 25 | .padding() 26 | } 27 | } 28 | 29 | struct ContentView_Previews: PreviewProvider { 30 | static var previews: some View { 31 | ContentView() 32 | } 33 | } 34 | """ 35 | 36 | func testSimple() async throws { 37 | let attributedText = try await highlight.attributedText(swiftCode) 38 | XCTAssertEqual(attributedText.characters.count, 477) 39 | } 40 | 41 | func testSimpleUnsupported() async throws { 42 | let attributedText = try await highlight.attributedText(swiftCode, language: "fortran") 43 | XCTAssertEqual(attributedText.characters.count, 477) 44 | } 45 | 46 | func testCustomColors() async throws { 47 | let customCSS: String = """ 48 | .hljs { display: block; overflow-x: auto; padding: 0.5em; } 49 | .hljs, 50 | .hljs-subst { color: black; } 51 | .hljs-string, 52 | .hljs-section, 53 | .hljs-selector-class, 54 | .hljs-template-variable, 55 | .hljs-deletion { color: #800; } 56 | """ 57 | let result = try await highlight.request(swiftCode, colors: .custom(css: customCSS)) 58 | XCTAssertFalse(result.isUndefined) 59 | XCTAssertEqual(result.relevance, 15) 60 | XCTAssertEqual(result.language, "swift") 61 | XCTAssertEqual(result.languageName, "Swift") 62 | XCTAssertEqual(result.attributedText.characters.count, 477) 63 | } 64 | 65 | func testAutomaticLanguage() async throws { 66 | let result = try await highlight.request(swiftCode) 67 | XCTAssertFalse(result.isUndefined) 68 | XCTAssertEqual(result.relevance, 15) 69 | XCTAssertEqual(result.language, "swift") 70 | XCTAssertEqual(result.languageName, "Swift") 71 | XCTAssertEqual(result.attributedText.characters.count, 477) 72 | } 73 | 74 | func testCorrectLanguage() async throws { 75 | let result = try await highlight.request(swiftCode, mode: .language(.swift)) 76 | XCTAssertFalse(result.isUndefined) 77 | XCTAssertEqual(result.relevance, 15) 78 | XCTAssertEqual(result.language, "swift") 79 | XCTAssertEqual(result.languageName, "Swift") 80 | XCTAssertEqual(result.attributedText.characters.count, 477) 81 | } 82 | 83 | func testCorrectLanguageAlias() async throws { 84 | let result = try await highlight.request(swiftCode, mode: .languageAlias("swift")) 85 | XCTAssertFalse(result.isUndefined) 86 | XCTAssertEqual(result.relevance, 15) 87 | XCTAssertEqual(result.language, "swift") 88 | XCTAssertEqual(result.languageName, "Swift") 89 | XCTAssertEqual(result.attributedText.characters.count, 477) 90 | } 91 | 92 | func testIncorrectLanguage() async throws { 93 | let result = try await highlight.request(swiftCode, mode: .language(.python)) 94 | XCTAssertFalse(result.isUndefined) 95 | XCTAssertEqual(result.relevance, 4) 96 | XCTAssertEqual(result.language, "python") 97 | XCTAssertEqual(result.languageName, "Python?") 98 | XCTAssertEqual(result.attributedText.characters.count, 477) 99 | } 100 | 101 | func testIncorrectLanguageAlias() async throws { 102 | let result = try await highlight.request(swiftCode, mode: .languageAlias("python")) 103 | XCTAssertFalse(result.isUndefined) 104 | XCTAssertEqual(result.relevance, 4) 105 | XCTAssertEqual(result.language, "python") 106 | XCTAssertEqual(result.languageName, "Python?") 107 | XCTAssertEqual(result.attributedText.characters.count, 477) 108 | } 109 | 110 | func testUnsupportedLanguage() async throws { 111 | let result = try await highlight.request(swiftCode, mode: .languageAlias("babel")) 112 | XCTAssertTrue(result.isUndefined) 113 | XCTAssertEqual(result.relevance, 0) 114 | XCTAssertEqual(result.language, "unknown") 115 | XCTAssertEqual(result.languageName, "Unknown") 116 | XCTAssertEqual(result.attributedText.characters.count, 477) 117 | } 118 | } 119 | --------------------------------------------------------------------------------