diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a305f9..0224e81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,6 +74,22 @@ jobs: echo "warnings: $(grep -cE '^/.*:[0-9]+:[0-9]+: warning:' build/xcodebuild-build.log || true)" exit $status + # MarkdownView builds its LaTeX support, and links SwiftMath, only when + # its `LaTeX` trait is on. Without it the app still builds and every + # formula shows up as raw `$$…$$` source, so check for both here. + - name: Check LaTeX rendering is compiled in + run: | + status=0 + if ! grep -q 'ENABLE_MATH_RENDERING' build/xcodebuild-build.log; then + echo "::error::MarkdownView was built without ENABLE_MATH_RENDERING, so formulas would show as raw LaTeX" + status=1 + fi + if ! ls build/DerivedData/Build/Products/Debug/ClassNote.app/Contents/Resources | grep -q SwiftMath; then + echo "::error::SwiftMath's resources are missing from ClassNote.app" + status=1 + fi + exit $status + - name: Run unit + integration tests run: | set +e diff --git a/Core/Utils/RichMarkdownView.swift b/Core/Utils/RichMarkdownView.swift index a562f58..9280b29 100644 --- a/Core/Utils/RichMarkdownView.swift +++ b/Core/Utils/RichMarkdownView.swift @@ -1,5 +1,5 @@ import SwiftUI -import MarkdownView +import MarkdownRendering /// Every piece of Markdown the app shows (notes, Q&A, study tools, highlight /// explanations, live tutor cards), rendered by the MarkdownView package: diff --git a/Core/Utils/Theme.swift b/Core/Utils/Theme.swift index 4d9e943..ed12f33 100644 --- a/Core/Utils/Theme.swift +++ b/Core/Utils/Theme.swift @@ -204,6 +204,12 @@ extension View { modifier(CardBackground(radius: radius, filled: filled)) } func pill(_ color: Color) -> some View { modifier(PillStyle(color: color)) } + + /// A list of choices inside a page (study tools, highlights, note + /// versions). The sidebar style brings the window sidebar's translucent + /// material with it, which inside a page shows the desktop through a hole + /// in the window; the inset style draws an opaque background. + func paneListStyle() -> some View { listStyle(.inset) } } /// A titled group on a settings-style page. diff --git a/Features/Session/HighlightsView.swift b/Features/Session/HighlightsView.swift index b86150b..4195091 100644 --- a/Features/Session/HighlightsView.swift +++ b/Features/Session/HighlightsView.swift @@ -24,7 +24,7 @@ struct HighlightsView: View { } } } - .listStyle(.sidebar) + .paneListStyle() .frame(width: 240) Divider() HighlightDetail(vm: vm) diff --git a/Features/Session/NotesView.swift b/Features/Session/NotesView.swift index b01e0fa..6569745 100644 --- a/Features/Session/NotesView.swift +++ b/Features/Session/NotesView.swift @@ -185,6 +185,6 @@ struct NotesView: View { } .buttonStyle(.plain) } - .listStyle(.sidebar) + .paneListStyle() } } diff --git a/Features/Session/StudyView.swift b/Features/Session/StudyView.swift index fe1889c..3031c69 100644 --- a/Features/Session/StudyView.swift +++ b/Features/Session/StudyView.swift @@ -441,7 +441,7 @@ struct StudyToolsPane: View { .padding(.vertical, 3) .tag(tool.id) } - .listStyle(.sidebar) + .paneListStyle() .frame(width: 250) Divider() VStack(spacing: 0) { diff --git a/Packages/MarkdownRendering/Package.swift b/Packages/MarkdownRendering/Package.swift new file mode 100644 index 0000000..3544fe9 --- /dev/null +++ b/Packages/MarkdownRendering/Package.swift @@ -0,0 +1,31 @@ +// swift-tools-version: 6.1 + +import PackageDescription + +// MarkdownView compiles its LaTeX support, and links SwiftMath, only when its +// `LaTeX` trait is on. The trait is on by default, but an Xcode project does +// not pass package traits before Xcode 26.4, so the app depended on it +// directly got neither and showed every formula as raw `$$…$$` source. Asking +// for the trait here, in a package manifest, turns it on whatever the Xcode. +let package = Package( + name: "MarkdownRendering", + platforms: [.macOS(.v14)], + products: [ + .library(name: "MarkdownRendering", targets: ["MarkdownRendering"]), + ], + dependencies: [ + .package( + url: "https://github.com/LiYanan2004/MarkdownView", + from: "3.0.0", + traits: ["LaTeX"] + ), + ], + targets: [ + .target( + name: "MarkdownRendering", + dependencies: [ + .product(name: "MarkdownView", package: "MarkdownView"), + ] + ), + ] +) diff --git a/Packages/MarkdownRendering/Sources/MarkdownRendering/MarkdownRendering.swift b/Packages/MarkdownRendering/Sources/MarkdownRendering/MarkdownRendering.swift new file mode 100644 index 0000000..6759d5d --- /dev/null +++ b/Packages/MarkdownRendering/Sources/MarkdownRendering/MarkdownRendering.swift @@ -0,0 +1,3 @@ +// The app imports MarkdownView through this package, which is where its LaTeX +// trait is turned on. See Package.swift. +@_exported import MarkdownView diff --git a/project.yml b/project.yml index fee5eff..862c242 100644 --- a/project.yml +++ b/project.yml @@ -15,8 +15,8 @@ settings: SWIFT_STRICT_CONCURRENCY: complete SWIFT_TREAT_WARNINGS_AS_ERRORS: "NO" ENABLE_USER_SCRIPT_SANDBOXING: NO - MARKETING_VERSION: "0.16.3" - CURRENT_PROJECT_VERSION: "22" + MARKETING_VERSION: "0.16.5" + CURRENT_PROJECT_VERSION: "23" DEAD_CODE_STRIPPING: YES packages: @@ -27,10 +27,10 @@ packages: url: https://github.com/sindresorhus/KeyboardShortcuts from: 2.2.0 # Renders every piece of Markdown in the app: CommonMark/GFM, LaTeX through - # SwiftMath. See RichMarkdownView. - MarkdownView: - url: https://github.com/LiYanan2004/MarkdownView - from: 3.0.0 + # SwiftMath. See RichMarkdownView. MarkdownView comes in through this local + # package, which turns on its LaTeX trait; see its Package.swift. + MarkdownRendering: + path: Packages/MarkdownRendering targets: ClassNote: @@ -90,7 +90,7 @@ targets: dependencies: - package: GRDB - package: KeyboardShortcuts - - package: MarkdownView + - package: MarkdownRendering settings: base: PRODUCT_BUNDLE_IDENTIFIER: com.beluga.classnote