summaryrefslogtreecommitdiff
path: root/Hutch/Views/Repositories/SyntaxHighlighter.swift
Commit message (Collapse)AuthorAgeFilesLines
* Adopt Swift 6 language modeChristian Cleberg25 hours1-1/+1
| | | | | | | | | | | | | | | | | | | | Flip SWIFT_VERSION to 6.0 (keeping SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor) and resolve every resulting diagnostic. Mechanical, no behaviour change: - Models: pure value types in Models/ and utility extensions (Date, DateFormatter, SRHTWebURL) marked nonisolated so the nonisolated networking layer can use them. - App Intents: stored 'static var' (title/description/openAppWhenRun/ typeDisplayRepresentation/defaultQuery/caseDisplayRepresentations) -> 'static let'; drop the invalid @retroactive on the in-module LookupType: AppEnum. - Sendable dicts: 'nil as String? as Any' -> 'nil as String? as any Sendable'. - UserDefaults: retroactive @unchecked Sendable (documented thread-safe). - WidgetKit completion handlers rebound nonisolated(unsafe) to cross into Task {}; TipStoreViewModel task handle is @ObservationIgnored nonisolated(unsafe) for its nonisolated deinit. - Tests run on @MainActor; a few constant fixtures marked nonisolated for use in @Sendable stub closures. Builds and the full suite are clean in Swift 6 mode. Roadmap updated.
* Fix Swift 6-mode isolation and attribute warningsChristian Cleberg25 hours1-2/+2
| | | | | | | | | | | | Under SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor these are warnings in Swift 5 mode and errors in Swift 6 mode: - Drop @retroactive from 'extension LookupType: AppEnum'; LookupType is declared in this module, so the attribute never applied. - Mark SyntaxHighlightTheme and SyntaxHighlighter nonisolated. They were inferred @MainActor but are built and used from the nonisolated markdown renderers in Task.detached; nonisolated makes the off-main confinement correct (Highlightr's JSContext was being driven off the main actor).
* Add multi-language syntax highlighting (#16)Christian Cleberg40 hours1-0/+222
Splash (Swift-only, since removed) left code rendering unhighlighted everywhere. Add Highlightr (highlight.js) behind a small SyntaxHighlighter service and use it on both surfaces: - Native file viewer: highlight NSAttributedString by language inferred from the filename, picking a light/dark theme from the trait style and re-highlighting on style changes. Falls back to plain text for unknown languages or very large files. - Markdown/org code blocks in the WKWebView (READMEs, tickets, comments): the web view disables JavaScript, so highlight server-side into inline color-styled spans. The color scheme is now part of the render/cache key since colors are baked into the HTML. Covered by unit tests for language mapping and highlighted output.