Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR centralizes LaTeX rendering by introducing a smart renderer, removes legacy Macaw-based SVG code and dependencies, and renames the table renderer for clarity.
- Swap direct
MathImageusage forGMarkLaTexRender.renderLatexSmart, with fallback on failure. - Eliminate Macaw imports and deprecate SVG POC classes; update package dependencies.
- Rename
GMarkTableRendertoGMarkTableLayoutand update all references.
Reviewed Changes
Copilot reviewed 20 out of 39 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/Visitor/GMarkupVisitor.swift | Use renderLatexSmart with fallback instead of MathImage |
| Sources/Render/RenderCells/GMarkLatexCellPOC.swift | Comment out Macaw-based SVG POC code |
| Sources/Render/RenderCells/GMarkLatexCell.swift | Remove Macaw import and SVG view handling |
| Sources/Render/GMarkdownMultiViewPOC.swift | Change preload to include all chunks |
| Sources/Render/GMarkdownMultiView.swift | Only check latexImage when choosing LaTeX cell |
| Sources/Generator/Table/GMarkTableLayout.swift | Rename class from GMarkTableRender to GMarkTableLayout |
| Sources/Generator/MarkupHandler/TableMarkupHandler.swift | Use GMarkTableLayout in handler |
| Sources/Generator/MarkupHandler/LaTexMarkupHandler.swift | Refactor LaTeX handling to use smart renderer |
| Sources/Generator/LaTex/GMarkSVGRender.swift | Add new low-level SVG rendering implementation |
| Sources/Generator/LaTex/GMarkLaTexToSVGConverter.swift | Rename SVG converter class and adjust options |
| Sources/Generator/LaTex/GMarkLaTexRender.swift | Add GMarkLaTexRender smart LaTeX renderer |
| Sources/Generator/GMarkChunkGenerator.swift | Remove Macaw import |
| Sources/Generator/GMarkChunk.swift | Remove latexNode and Macaw references |
| Package.swift | Drop Macaw package dependency |
| Examples/GMarkdownExample/.../md/markdownLatex | Add LaTeX reference example file |
| Examples/GMarkdownExample/GMarkdownExample/RealTimeRenderController.swift | Include markdownLatex and adjust maxContainerWidth |
| Examples/GMarkdownExample/GMarkdownExample/MarkdownRenderController.swift | Include markdownLatex and adjust maxContainerWidth |
| Examples/GMarkdownExample/GMarkdownExample/Assets.xcassets/AppIcon.appiconset/Contents.json | Overhaul app icon JSON |
| Examples/GMarkdownExample/GMarkdownExample.xcodeproj/Package.resolved | Remove Macaw and SWXMLHash from resolved packages |
| Examples/GMarkdownExample/GMarkdownExample.xcodeproj/project.pbxproj | Register markdownLatex resource in project file |
|
|
||
| return result | ||
| } else { | ||
| print("LaTeX 渲染失败: \(result.error?.localizedDescription ?? "未知错误")") |
There was a problem hiding this comment.
[nitpick] Consider replacing this print statement with a structured logging framework or a debug-only log to avoid polluting console output in production.
| print("LaTeX 渲染失败: \(result.error?.localizedDescription ?? "未知错误")") | |
| os_log("LaTeX 渲染失败: %{public}@", log: .default, type: .error, result.error?.localizedDescription ?? "未知错误") |
| import MPITextKit | ||
| import Macaw | ||
|
|
||
| /* |
There was a problem hiding this comment.
[nitpick] Rather than commenting out large blocks of code, consider removing this POC file or moving it behind a feature flag to reduce code clutter.
| /* | |
| #if ENABLE_GMARK_LATEX_CELL_POC |
|
|
||
| for i in start...end { | ||
| if let chunk = chunks[safe: i], chunk.latexNode != nil { | ||
| if let chunk = chunks[safe: i] { |
There was a problem hiding this comment.
The preload logic now collects all chunks instead of only LaTeX ones, which may lead to unnecessary work; consider filtering by chunk.latexImage != nil again.
| if let chunk = chunks[safe: i] { | |
| if let chunk = chunks[safe: i], chunk.latexImage != nil { |
| DispatchQueue.global(qos: .userInitiated).async { | ||
| let style = MarkdownStyle.defaultStyle() | ||
| var style = MarkdownStyle.defaultStyle() | ||
| style.maxContainerWidth = UIScreen.main.bounds.size.width - 32 |
There was a problem hiding this comment.
[nitpick] This calculation is duplicated in multiple controllers; consider extracting common style configuration into a helper.
| DispatchQueue.global(qos: .userInitiated).async { | ||
| let style = MarkdownStyle.defaultStyle() | ||
| var style = MarkdownStyle.defaultStyle() | ||
| style.maxContainerWidth = UIScreen.main.bounds.size.width - 32 |
There was a problem hiding this comment.
[nitpick] Duplicate width adjustment seen here and in RealTimeRenderController; factor into shared utility to avoid drift.
| style.maxContainerWidth = UIScreen.main.bounds.size.width - 32 | |
| style.maxContainerWidth = calculateMaxContainerWidth(padding: 32) |
| "version" : 1 | ||
| } | ||
| } | ||
| {"images":[{"size":"20x20","idiom":"iphone","filename":"iPhoneNotification_20pt@2x.png","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"iPhoneNotification_20pt@3x.png","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"iPhoneSpootlight5_29pt@2x.png","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"iPhoneSpootlight5_29pt@3x.png","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"iPhoneSpootlight7_40pt@2x.png","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"iPhoneSpootlight7_40pt@3x.png","scale":"3x"},{"size":"60x60","idiom":"iphone","filename":"iPhoneApp_60pt@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"iPhoneApp_60pt@3x.png","scale":"3x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"store_1024pt.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"iPadNotification_20pt.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"iPadNotification_20pt@2x.png","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"iPadSpootlight5_29pt.png","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"iPadSpootlight5_29pt@2x.png","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"iPadSpootlight7_40pt.png","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"iPadSpootlight7_40pt@2x.png","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"iPadApp_76pt.png","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"iPadApp_76pt@2x.png","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"iPadProApp_83.5pt@2x.png","scale":"2x"}],"info":{"version":1,"author":"xcode"}} No newline at end of file |
There was a problem hiding this comment.
The asset name "iPhoneSpootlight5" appears to have a typo; you may want to correct it to "iPhoneSpotlight5".
No description provided.