Skip to content

fix: strip trailing whitespace in code blocks#606

Merged
NagariaHussain merged 1 commit intofrappe:developfrom
NagariaHussain:fix/code-block-trailing-whitespace
Apr 22, 2026
Merged

fix: strip trailing whitespace in code blocks#606
NagariaHussain merged 1 commit intofrappe:developfrom
NagariaHussain:fix/code-block-trailing-whitespace

Conversation

@NagariaHussain
Copy link
Copy Markdown
Collaborator

@NagariaHussain NagariaHussain commented Apr 22, 2026

image

Trailing spaces, tabs, or blank lines inside a fenced code block rendered
as phantom empty rows beneath the code because <pre> preserves whitespace
verbatim. Trim them in the markdown renderer (server-side) and in the
post-render JS enhancer (handles already-stored content without a
migration).
@NagariaHussain NagariaHussain merged commit bde8d03 into frappe:develop Apr 22, 2026
5 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This change modifies code block rendering across both frontend and backend layers. The JavaScript enhancement adds preprocessing to replace trailing whitespace in the final text node of code blocks with a newline. Simultaneously, the Python markdown renderer adds a block_code method override that strips trailing whitespace from code content and appends a newline before rendering. A corresponding test case validates that code blocks with trailing spaces on the closing fence are properly normalized.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: strip trailing whitespace in code blocks' is concise, clear, and directly summarizes the main change—removing trailing whitespace from code blocks across both backend and frontend logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant