Fix Markdown block rendering in Text#875
Open
esconner wants to merge 2 commits intotwostraws:mainfrom
Open
Conversation
Author
|
Hi,
- I can apply the change you suggested. Do you generally prefer if and switch expressions when possible in Ignite?
- While I’m at it: do you prefer implicit returns too? If so I could also change my escapedHTML function in line 40.
- I’ll also run swiftlint to clear up some whitespace issues I caused (sorry).
- did you retract this comment from GitHub? I can’t see it there.
Cheers
Eric
… On 4. Apr 2026, at 16:26, Skwiggs ***@***.***> wrote:
> + let code = escapedHTML(codeBlock.code)
+
if let language = codeBlock.language {
- #"<pre><code class="language-\#(language.lowercased())">\#(codeBlock.code)</code></pre>"#
+ return #"<pre><code class="language-\#(language.lowercased())">\#(code)</code></pre>"#
} else {
- #"<pre><code>\#(codeBlock.code)</code></pre>"#
+ return #"<pre><code>\#(code)</code></pre>"#
⬇️ Suggested change
- let code = escapedHTML(codeBlock.code)
-
- if let language = codeBlock.language {
- #"<pre><code class="language-\#(language.lowercased())">\#(codeBlock.code)</code></pre>"#
- return #"<pre><code class="language-\#(language.lowercased())">\#(code)</code></pre>"#
- } else {
- #"<pre><code>\#(codeBlock.code)</code></pre>"#
- return #"<pre><code>\#(code)</code></pre>"#
+ let code = escapedHTML(codeBlock.code)
+
+return if let language = codeBlock.language {
+ #"<pre><code class="language-\#(language.lowercased())">\#(code)</code></pre>"#
+} else {
+ #"<pre><code>\#(code)</code></pre>"#
|
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.
Fixes #874
This changes
Text(markdown:)andText(markup:parser:)to preserve block Markdown structure instead of doing fragile HTML stringsplitting.
What changed:
TextMarkdown bodiesMarkdownToHTMLso the renderer always produces valid HTMLTests:
Text(markdown:)Text(markup:parser:)MarkdownToHTMLValidation: