summaryrefslogtreecommitdiff
path: root/Hutch/Views/Tickets
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-08-07 02:52:03 -0500
committerGitHub <[email protected]>2026-08-07 02:52:03 -0500
commit044c33f7f43db1f38d6c44dd8f483298d9efcc06 (patch)
tree649488b2e5d3d901db8c792c0dc215c835fa9d38 /Hutch/Views/Tickets
parent0a3e55c15cfb9ce1bd3df0c7b352760bc2ee33c3 (diff)
parentb410fd16b76146f4116538c5b82330818dd47da9 (diff)
downloadhutch-044c33f7f43db1f38d6c44dd8f483298d9efcc06.tar.gz
hutch-044c33f7f43db1f38d6c44dd8f483298d9efcc06.tar.bz2
hutch-044c33f7f43db1f38d6c44dd8f483298d9efcc06.zip
Merge pull request #30 from krazywarez/syntax-highlighting
Add multi-language syntax highlighting (#16)
Diffstat (limited to 'Hutch/Views/Tickets')
-rw-r--r--Hutch/Views/Tickets/TicketDetailView.swift12
1 files changed, 10 insertions, 2 deletions
diff --git a/Hutch/Views/Tickets/TicketDetailView.swift b/Hutch/Views/Tickets/TicketDetailView.swift
index 6339776..1ace6b6 100644
--- a/Hutch/Views/Tickets/TicketDetailView.swift
+++ b/Hutch/Views/Tickets/TicketDetailView.swift
@@ -553,14 +553,22 @@ private struct MarkdownContentView: View {
.frame(minHeight: 80)
}
}
- .task(id: markdown) {
+ .task(id: MarkdownRenderKey(markdown: markdown, isDark: colorScheme == .dark)) {
+ let theme = SyntaxHighlightTheme(colorScheme: colorScheme)
let html = await Task.detached(priority: .userInitiated) {
- markdownToHTML(markdown)
+ markdownToHTML(markdown, codeTheme: theme)
}.value
guard !Task.isCancelled else { return }
renderedHTML = html
}
}
+
+ /// Re-renders when the markdown or the color scheme changes; highlighted
+ /// code colors are baked into the HTML, so both must key the render.
+ private struct MarkdownRenderKey: Equatable {
+ let markdown: String
+ let isDark: Bool
+ }
}
// MARK: - Event Row