From 147c69005179f117adfe4491a13d36294d925e8d Mon Sep 17 00:00:00 2001 From: DhruvTilva Date: Fri, 26 Jun 2026 00:04:41 +0530 Subject: [PATCH] fix: prevent spurious leading spaces in nested codeBlock interior lines When a codeBlock is nested inside an indented structure like a bulletListItem, the \_render_block\ function prepends the block's indentation \prefix\ to every line. However, for codeBlock elements, only the fence markers (the opening and closing \\\) should carry the block indentation. Interior code lines must not have the prefix prepended, because markdown parsers treat leading spaces inside a code fence as part of the code content. This fix removes the prefix from interior code lines to prevent code snippets stored in notes from gaining spurious whitespace. --- surfsense_backend/app/utils/blocknote_to_markdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfsense_backend/app/utils/blocknote_to_markdown.py b/surfsense_backend/app/utils/blocknote_to_markdown.py index 3731b4b3c..8c172c7bd 100644 --- a/surfsense_backend/app/utils/blocknote_to_markdown.py +++ b/surfsense_backend/app/utils/blocknote_to_markdown.py @@ -133,7 +133,7 @@ def _render_block( code_text = _render_inline_content(content) if content else "" lines.append(f"{prefix}```{language}") for code_line in code_text.split("\n"): - lines.append(f"{prefix}{code_line}") + lines.append(code_line) lines.append(f"{prefix}```") elif block_type == "table":