From b07038cd12f2d174ce5c0f2a5d94f0bbf56cc4d9 Mon Sep 17 00:00:00 2001 From: Gaurav Vijay Jadhav Date: Fri, 18 Sep 2026 23:12:27 +0530 Subject: [PATCH] ANSI writer: fix missing bar on blockquote's first line (#11877) D.prefixed only emits its prefix on a line that starts at column 0. When a BlockQuote is the first block of a list item, the item's marker and the quote's content are joined onto the same line, so the quote's Prefixed doc begins mid-line and its "| " bar is dropped on that first line, while later wrapped lines (which do start at column 0) render it correctly. Force the blockquote onto its own line with D.cr before applying the prefix. D.cr is a no-op when already at the start of a line, so top-level and nested blockquotes are unaffected. Fixes #11804 --- src/Text/Pandoc/Writers/ANSI.hs | 7 ++++++- test/ansi-test.ansi | 7 +++++++ test/ansi-test.txt | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Writers/ANSI.hs b/src/Text/Pandoc/Writers/ANSI.hs index e20713f61..ddcc30c46 100644 --- a/src/Text/Pandoc/Writers/ANSI.hs +++ b/src/Text/Pandoc/Writers/ANSI.hs @@ -190,7 +190,12 @@ blockToANSI opts (CodeBlock attr str) = do blockToANSI opts (BlockQuote blocks) = do contents <- withFewerColumns 2 $ blockListToANSI opts blocks - return ( D.prefixed "│ " contents $$ D.blankline) + -- D.cr ensures we start the blockquote on its own line: without it, + -- a blockquote that begins mid-line (e.g. as the first block of a + -- list item, sharing a line with the item's marker) would have its + -- prefix omitted on the first line, since D.prefixed only prefixes + -- lines that begin at column 0. + return ( D.cr <> D.prefixed "│ " contents $$ D.blankline) blockToANSI opts (Table _ (Caption _ caption) colSpecs (TableHead _ thead) tbody (TableFoot _ tfoot)) = do let captionInlines = blocksToInlines caption diff --git a/test/ansi-test.ansi b/test/ansi-test.ansi index 57147eacc..ae4f9398a 100644 --- a/test/ansi-test.ansi +++ b/test/ansi-test.ansi @@ -34,6 +34,13 @@ Text │ │ │ Nested block quote +Numbered list item beginning with a block quote (regression test for +issue #11804, where the leading bar was dropped on the block quote’s +first line because it shared a line with the list marker): + +1. + │ List item block quote + Multiline table with caption: Centered Left Right Default aligned diff --git a/test/ansi-test.txt b/test/ansi-test.txt index 4e6f9800c..692b445b3 100644 --- a/test/ansi-test.txt +++ b/test/ansi-test.txt @@ -38,6 +38,12 @@ Text > > > Nested block quote +Numbered list item beginning with a block quote (regression test for +issue #11804, where the leading bar was dropped on the block quote's +first line because it shared a line with the list marker): + +1. > List item block quote + Multiline table with caption: : Here's the caption.