@@ -116,7 +116,7 @@ pub enum Item {
116116 /// A code block.
117117 ///
118118 /// You can enable the `highlighter` feature for syntax highlighting.
119- CodeBlock ( Text ) ,
119+ CodeBlock ( Vec < Text > ) ,
120120 /// A list.
121121 List {
122122 /// The first number of the list, if it is ordered.
@@ -377,6 +377,7 @@ fn parse_with<'a>(
377377 }
378378
379379 let mut spans = Vec :: new ( ) ;
380+ let mut code = Vec :: new ( ) ;
380381 let mut strong = false ;
381382 let mut emphasis = false ;
382383 let mut strikethrough = false ;
@@ -587,7 +588,7 @@ fn parse_with<'a>(
587588 produce (
588589 state. borrow_mut ( ) ,
589590 & mut lists,
590- Item :: CodeBlock ( Text :: new ( spans . drain ( ..) . collect ( ) ) ) ,
591+ Item :: CodeBlock ( code . drain ( ..) . collect ( ) ) ,
591592 source,
592593 )
593594 }
@@ -605,9 +606,9 @@ fn parse_with<'a>(
605606 #[ cfg( feature = "highlighter" ) ]
606607 if let Some ( highlighter) = & mut highlighter {
607608 for line in text. lines ( ) {
608- spans . extend_from_slice (
609- highlighter. highlight_line ( & format ! ( "{line}\n " ) ) ,
610- ) ;
609+ code . push ( Text :: new (
610+ highlighter. highlight_line ( & format ! ( "{line}" ) ) . to_vec ( ) ,
611+ ) ) ;
611612 }
612613
613614 return None ;
@@ -871,13 +872,14 @@ where
871872 } ) )
872873 . spacing ( spacing * 0.75 )
873874 . into ( ) ,
874- Item :: CodeBlock ( code ) => container (
875+ Item :: CodeBlock ( lines ) => container (
875876 scrollable (
876- container (
877- rich_text ( code . spans ( style) )
877+ container ( column ( lines . iter ( ) . map ( |line| {
878+ rich_text ( line . spans ( style) )
878879 . font ( Font :: MONOSPACE )
879- . size ( code_size) ,
880- )
880+ . size ( code_size)
881+ . into ( )
882+ } ) ) )
881883 . padding ( spacing. 0 / 2.0 ) ,
882884 )
883885 . direction ( scrollable:: Direction :: Horizontal (
0 commit comments