feat: make block spacing configurable via MarkdownRenderConfig - #90
Merged
Jun Yan (junyan72) merged 3 commits intoJun 20, 2026
Merged
Conversation
Add a `blockSpacing` property (default 30) that controls the vertical gap between adjacent blocks in the rendered Markdown output. This follows the same pattern as every other config property — stored in MarkdownRenderConfig, exposed through a `withBlockSpacing(value:)` builder, and consumed by BlockView via the `\.markdownConfig` environment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a blockSpacing configuration surface to MarkdownRenderConfig so callers can control the vertical spacing between adjacent block-level renderables, instead of relying on a hardcoded VStack(... spacing: 30) in the UI layer.
Changes:
- Introduces
blockSpacing: CGFloatonMarkdownRenderConfigwith a default of30to preserve existing behavior. - Adds a
withBlockSpacing(value:)builder (and updateswithTextContextMenu(value:)to forward the new property). - Updates
BlockViewto read spacing from@Environment(\.markdownConfig).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Sources/MarkdownText/UI/BlockView.swift | Replaces hardcoded VStack spacing with config.blockSpacing from the environment. |
| Sources/MarkdownText/Models/MarkdownRenderConfig+Builders.swift | Adds withBlockSpacing and updates withTextContextMenu to forward blockSpacing (and citationConfig). |
| Sources/MarkdownText/Models/MarkdownRenderConfig.swift | Adds the new blockSpacing property, default constant, and initializer wiring. |
Cheng Gui (szguicheng)
marked this pull request as draft
June 19, 2026 15:22
4 tasks
Jun Yan (junyan72)
marked this pull request as ready for review
June 19, 2026 21:34
Contributor
|
Copilot resolve merge conflict, add snapshot test case to cover the configurability |
Contributor
Author
|
@microsoft-github-policy-service agree |
Adds a snapshot test that renders multi-block markdown with blockSpacing set to 10, verifying the config property is plumbed through correctly to the rendered output. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Jun Yan (junyan72)
approved these changes
Jun 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
blockSpacingproperty toMarkdownRenderConfigso callers can control the vertical gap between adjacent Markdown blocks (paragraphs, headings, code blocks, lists, etc.). The default value is30, preserving the existing hardcoded behavior.Closes #87.
Problem
All block-level spacing was hardcoded in
BlockView.swift:MarkdownRenderConfigprovides a clean configuration surface for fonts and colors, but had no spacing properties. Apps that need different visual density — a chat bubble versus a full-width article view — had no way to adjust spacing without forking.Changes
Three files, 31 insertions / 3 deletions:
MarkdownRenderConfig.swift— newblockSpacing: CGFloatproperty (default30), wired intoinitMarkdownRenderConfig+Builders.swift— newwithBlockSpacing(value:)builder, and updatedwithTextContextMenu(value:)to forward the new propertyBlockView.swift— readsblockSpacingfrom@Environment(\.markdownConfig)instead of the hardcoded literalUsage
Test plan
make test— ✅)30= prior hardcoded value)withBlockSpacing(value:)Notes
lineSpacingare left for follow-up work if there is demand.MarkdownRenderConfigproperty.🤖 Generated with Claude Code