Skip to content

Conversation

@ferologics
Copy link
Contributor

@ferologics ferologics commented Jan 29, 2026

Fix two bugs in blockquote rendering:

  1. ANSI codes split incorrectly on newlines - when text tokens contain newlines, styling was applied to the entire string including the newline. Any caller splitting by \n would break the ANSI codes, causing inconsistent coloring (e.g., first line pink, second line grey).

  2. Wrapped blockquote lines lost the │ border - long blockquote lines that wrapped to multiple lines only had the border on the first line.

Solution

Refactored renderInlineTokens to use a style context instead of a boolean flag:

interface InlineStyleContext {
  applyText: (text: string) => string;
  stylePrefix: string;
}
  • Default context uses applyDefaultStyle() for normal text
  • Blockquotes pass a quote style context with theme.quote(theme.italic(text))
  • Inline formatting resets (bold, code, etc.) properly re-apply the base style via stylePrefix
  • Text is split by newlines before styling to ensure ANSI codes don't span line breaks

Also added handling for paragraph tokens inside renderInlineTokens - these appear in blockquotes and need to propagate the style context to their nested inline tokens.

Tests

Added regression tests for:

  • Lazy continuation blockquotes (>Foo\nbar)
  • Explicit multiline blockquotes (>Foo\n>bar)
  • Long blockquote line wrapping with border on each line
  • Inline formatting inside blockquotes (> Quote with **bold** and \code``)

Session: https://buildwithpi.ai/session/#95f37a58d17decb975c4d57085737421

Fix two bugs in blockquote rendering:

1. ANSI codes split incorrectly on newlines - when text tokens contain
   newlines, applyDefaultStyle() wrapped the entire string including the
   newline in ANSI codes. Any caller splitting by \n would break the codes.
   Fixed by splitting text by newlines before styling in renderInlineTokens().

2. Wrapped blockquote lines lost the │ border - long blockquote lines
   that wrapped to multiple lines only had the border on the first line.
   Fixed by wrapping within the blockquote case and adding border to each line.
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