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.
This commit is contained in:
DhruvTilva 2026-06-26 00:04:41 +05:30
parent ee241e0ff2
commit 147c690051

View file

@ -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":