Skip to content

Commit 1352cd6

Browse files
committed
fix(markdown): correct blockquote width regression coverage
1 parent 2ab3602 commit 1352cd6

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

crates/forge_markdown_stream/src/lib.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,9 @@ mod tests {
192192
let fixture = "> supercalifragilistic\n> 한글 공백\n";
193193
let actual = fixture_rendered_output(fixture, 10);
194194
let expected = concat!(
195-
"│ super\n",
196-
"│ calif\n",
197-
"│ ragil\n",
198-
"│ istic\n",
195+
"│ supercal\n",
196+
"│ ifragili\n",
197+
"│ stic\n",
199198
"│ 한글\n",
200199
"│ 공백"
201200
);
@@ -209,9 +208,22 @@ mod tests {
209208
let actual = fixture_rendered_output(fixture, 20);
210209
let expected = concat!(
211210
"│ 링크\n",
212-
"│ (https://exampl\n",
213-
"│ e.com/very/long\n",
214-
"│ /path) 설명"
211+
"│ (https://example.c\n",
212+
"│ om/very/long/path)\n",
213+
"│ 설명"
214+
);
215+
216+
assert_eq!(actual, expected);
217+
}
218+
219+
#[test]
220+
fn test_streaming_renderer_wraps_nested_blockquotes_with_correct_prefix_width() {
221+
let fixture = ">> supercalifragilistic\n";
222+
let actual = fixture_rendered_output(fixture, 12);
223+
let expected = concat!(
224+
"│ │ supercal\n",
225+
"│ │ ifragili\n",
226+
"│ │ stic"
215227
);
216228

217229
assert_eq!(actual, expected);

crates/forge_markdown_stream/src/renderer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use streamdown_parser::ParseEvent;
88
use crate::code::CodeHighlighter;
99
use crate::heading::render_heading;
1010
use crate::inline::{render_inline_content, render_inline_elements};
11-
use crate::list::{ListState, render_list_item};
11+
use crate::list::{render_list_item, ListState};
1212
use crate::style::InlineStyler;
1313
use crate::table::render_table;
1414
use crate::theme::Theme;
@@ -255,13 +255,13 @@ impl<W: Write> Renderer<W> {
255255

256256
ParseEvent::BlockquoteLine(text) => {
257257
let margin = self.left_margin();
258-
let width = self.current_width();
258+
let content_width = self.width.saturating_sub(visible_length(&margin));
259259
// Parse inline formatting (bold, italic, etc.) in blockquote content
260260
let rendered_content = render_inline_content(text, &self.theme);
261261
let wrapped = wrap_text_preserving_spaces(
262262
&rendered_content,
263-
width.saturating_sub(visible_length(&margin)),
264-
width.saturating_sub(visible_length(&margin)),
263+
content_width,
264+
content_width,
265265
&margin,
266266
&margin,
267267
);

0 commit comments

Comments
 (0)