Fix line breaks for multi-line comments in Markdown cells (Interactive Window) #16725
+86
−4
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.
Fixed an issue where line breaks and indentation were not preserved correctly when using multi-line comments (triple quotes) in Markdown cells in the Interactive Window.
Problem
When writing Markdown cells using Python multi-line strings, the rendered output was losing line breaks and creating excessive spacing:
This would render with double line breaks between all elements, breaking the formatting of lists and code blocks.
Root Cause
The
generateMarkdownFromCodeLines
function was usingappendLineFeed
which adds line feeds to each array element. WhencellFactory.ts
then joined the result with'\n'
, it created double line breaks for empty lines:appendLineFeed(['# H1 Title', '', 'description 1'])
→['# H1 Title\n', '\n', 'description 1']
'\n'
→'# H1 Title\n\n\n\ndescription 1'
(extra line breaks)Solution
Removed the
appendLineFeed
call fromgenerateMarkdownFromCodeLines
. The function now returns a clean array of strings that preserves the original line structure when joined with'\n'
.Testing
cellFactory.ts
uses.join('\n')
for proper markdown renderinginteractiveWindow.ts
uses.join('')
for concatenation without separatorsFixes #9620.