From 1b66b1c119d01b07ebbe77012fb673ebff901518 Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Wed, 24 Jun 2026 11:02:03 +0200 Subject: [PATCH] fix: use split('\n') instead of splitlines() in blockquote renderer The blockquote renderer used str.splitlines() to split rendered text into lines, but splitlines() treats Unicode line separators (form feed \x0c, vertical tab \x0b, file/group/record separators, NEL \x85, line/paragraph separator) as line breaks. CommonMark only recognizes \n, \r\n, and \r as line endings. Other renderers (paragraph, list_item) correctly use split('\n'). When blockquote content contained Unicode whitespace like form feed, the renderer would split on it and prepend spurious '> ' markers, creating semantically different output on the first format pass. The second pass then normalized this, breaking idempotence. --- src/mdformat/renderer/_context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mdformat/renderer/_context.py b/src/mdformat/renderer/_context.py index 238dd07d..c8f37f2b 100644 --- a/src/mdformat/renderer/_context.py +++ b/src/mdformat/renderer/_context.py @@ -326,7 +326,7 @@ def blockquote(node: RenderTreeNode, context: RenderContext) -> str: marker = "> " with context.indented(len(marker)): text = make_render_children(separator="\n\n")(node, context) - lines = text.splitlines() + lines = text.split("\n") if not lines: return ">" quoted_lines = (f"{marker}{line}" if line else ">" for line in lines)