Enhance configuration support#143
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Thanks for your contribution! I am busy on other projects and my personal stuffs so there might need to be extra delays on this project |
|
Did some performance improvements and solved #135 |
Allows consumers to force a specific renderer (e.g. .view) via .environment(\.markdownViewRenderer, .view), which is needed for SwiftUI ImageRenderer compatibility on macOS 26+.
There was a problem hiding this comment.
To avoid data corruption, we should only keep single source-of-truth. But there are two.
I know there is a flag but the reason for switching to an ObservableObject is to be able to share the content across view hierarchy so for MarkdownView, it must use ObservedObject (the object is passed either from parent view or from MarkdownReader
| .makeBody(content: content, configuration: configuration) | ||
| .erasedToAnyView() | ||
| .font(configuration.fonts[.body] ?? Font.body) | ||
| var config = configuration |
There was a problem hiding this comment.
It's better to modify the existing view modifier
| /// produced it. Because this is a reference type stored in `@State`, it | ||
| /// persists across body evaluations without triggering additional renders. | ||
| @MainActor | ||
| private final class RenderCache { |
There was a problem hiding this comment.
The current (in v2 as well) is not efficient. Caches are rarely hit. I will implement a new approach later
|
Thank you for your amazing work! @hra42 |
If you need further help with anything just send me to it :) Will help as much as possible :) |
Hi @LiYanan2004,
I saw that a longer time nothing has happend in the mdv3 branch, but I really needed the changes you already made. I did some more work and I already shipped in Prod today. If you'd like me to, I'd be happy to support with the remaining tasks of version 3. Below is a summary of the changes made by Copilot.
This pull request introduces enhancements to the Markdown rendering system, focusing on improved heading styling, support for checkbox rendering in lists, and minor logic adjustments. The key changes are grouped below:
Heading Styling Improvements
headingStyleGrouptoMarkdownRendererConfiguration, enabling customizable heading styles for Markdown headings. This is now passed through the environment and used inMarkdownViewand heading rendering logic. [1] [2] [3]CmarkTextContentVisitorto apply the appropriate style and font fromheadingStyleGroup, and improved accessibility support.Checkbox Rendering in Lists
CmarkTextContentVisitorto support checkboxes: if a list item has a checkbox, it displays a corresponding icon instead of a marker. [1] [2] [3]Logic Adjustment
MathFirstMarkdownViewRendererto process ranges in reverse, improving math rendering consistency.