@@ -116,7 +116,7 @@ pub enum Item {
116
116
/// A code block.
117
117
///
118
118
/// You can enable the `highlighter` feature for syntax highlighting.
119
- CodeBlock ( Text ) ,
119
+ CodeBlock ( Vec < Text > ) ,
120
120
/// A list.
121
121
List {
122
122
/// The first number of the list, if it is ordered.
@@ -377,6 +377,7 @@ fn parse_with<'a>(
377
377
}
378
378
379
379
let mut spans = Vec :: new ( ) ;
380
+ let mut code = Vec :: new ( ) ;
380
381
let mut strong = false ;
381
382
let mut emphasis = false ;
382
383
let mut strikethrough = false ;
@@ -587,7 +588,7 @@ fn parse_with<'a>(
587
588
produce (
588
589
state. borrow_mut ( ) ,
589
590
& mut lists,
590
- Item :: CodeBlock ( Text :: new ( spans . drain ( ..) . collect ( ) ) ) ,
591
+ Item :: CodeBlock ( code . drain ( ..) . collect ( ) ) ,
591
592
source,
592
593
)
593
594
}
@@ -605,9 +606,9 @@ fn parse_with<'a>(
605
606
#[ cfg( feature = "highlighter" ) ]
606
607
if let Some ( highlighter) = & mut highlighter {
607
608
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
+ ) ) ;
611
612
}
612
613
613
614
return None ;
@@ -871,13 +872,14 @@ where
871
872
} ) )
872
873
. spacing ( spacing * 0.75 )
873
874
. into ( ) ,
874
- Item :: CodeBlock ( code ) => container (
875
+ Item :: CodeBlock ( lines ) => container (
875
876
scrollable (
876
- container (
877
- rich_text ( code . spans ( style) )
877
+ container ( column ( lines . iter ( ) . map ( |line| {
878
+ rich_text ( line . spans ( style) )
878
879
. font ( Font :: MONOSPACE )
879
- . size ( code_size) ,
880
- )
880
+ . size ( code_size)
881
+ . into ( )
882
+ } ) ) )
881
883
. padding ( spacing. 0 / 2.0 ) ,
882
884
)
883
885
. direction ( scrollable:: Direction :: Horizontal (
0 commit comments