@@ -546,48 +546,46 @@ export function printLiquidDocExample(
546
546
const node = path . getValue ( ) ;
547
547
const parts : Doc [ ] = [ '@example' ] ;
548
548
549
- if ( node . exampleContent ?. value ) {
550
- const content = node . exampleContent . value ;
551
- if ( content ) {
552
- // Count leading newlines before content (\n\nmy content)
553
- const leadingNewlines = content . match ( / ^ \n * / ) ?. [ 0 ] ?. length ?? 0 ;
554
- const trimmedContent = content . trim ( ) ;
555
-
556
- // Push inline content to new line
549
+ const content = node . exampleContent . value ;
550
+ if ( content ) {
551
+ // Count leading newlines before content (\n\nmy content)
552
+ const leadingNewlines = content . match ( / ^ \n * / ) ?. [ 0 ] ?. length ?? 0 ;
553
+ const trimmedContent = content . trim ( ) ;
554
+
555
+ // Push inline content to new line
556
+ parts . push ( hardline ) ;
557
+
558
+ // If there were two or more leading newlines, push another new line
559
+ if ( leadingNewlines > 1 ) {
557
560
parts . push ( hardline ) ;
561
+ }
558
562
559
- // If there were two or more leading newlines, push another new line
560
- if ( leadingNewlines > 1 ) {
561
- parts . push ( hardline ) ;
562
- }
563
+ // If content doesn't have newlines in it, make sure it's on a new line (not inline)
564
+ if ( ! trimmedContent . includes ( '\n' ) ) {
565
+ parts . push ( trimmedContent ) ;
566
+ return parts ;
567
+ }
563
568
564
- // If content doesn't have newlines in it, make sure it's on a new line (not inline)
565
- if ( ! trimmedContent . includes ( '\n' ) ) {
566
- parts . push ( trimmedContent ) ;
567
- return parts ;
568
- }
569
+ // For multi-line content
570
+ const lines = trimmedContent . split ( '\n' ) ;
571
+ const processedLines : string [ ] = [ ] ;
572
+ let emptyLineCount = 0 ;
573
+
574
+ for ( let i = 0 ; i < lines . length ; i ++ ) {
575
+ const line = lines [ i ] . trim ( ) ;
569
576
570
- // For multi-line content
571
- const lines = trimmedContent . split ( '\n' ) ;
572
- const processedLines : string [ ] = [ ] ;
573
- let emptyLineCount = 0 ;
574
-
575
- for ( let i = 0 ; i < lines . length ; i ++ ) {
576
- const line = lines [ i ] . trim ( ) ;
577
-
578
- if ( line === '' ) {
579
- emptyLineCount ++ ;
580
- if ( emptyLineCount <= 2 ) {
581
- processedLines . push ( '' ) ;
582
- }
583
- } else {
584
- emptyLineCount = 0 ;
585
- processedLines . push ( line ) ;
577
+ if ( line === '' ) {
578
+ emptyLineCount ++ ;
579
+ if ( emptyLineCount <= 2 ) {
580
+ processedLines . push ( '' ) ;
586
581
}
582
+ } else {
583
+ emptyLineCount = 0 ;
584
+ processedLines . push ( line ) ;
587
585
}
588
-
589
- parts . push ( join ( hardline , processedLines ) ) ;
590
586
}
587
+
588
+ parts . push ( join ( hardline , processedLines ) ) ;
591
589
}
592
590
593
591
return parts ;
0 commit comments