File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed 
Sources/Markdown/Walker/Walkers 
Tests/MarkdownTests/Visitors Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -805,7 +805,7 @@ public struct MarkupFormatter: MarkupWalker {
805805        // Image elements' source URLs can't be split. If wrapping the alt text
806806        // of an image still put us over the line, prefer to print it on the
807807        // next line to give as much opportunity to keep the alt text contents on one line.
808-         if  image. indexInParent >  0  && ( isOverPreferredLineLimit || state. lineNumber  >  savedState. lineNumber )  { 
808+         if  image. indexInParent >  0  && ( isOverPreferredLineLimit || state. effectiveLineNumber  >  savedState. effectiveLineNumber )  { 
809809            restoreState ( to:  savedState) 
810810            queueNewline ( ) 
811811            printImage ( ) 
@@ -842,7 +842,7 @@ public struct MarkupFormatter: MarkupWalker {
842842            // Link elements' destination URLs can't be split. If wrapping the link text
843843            // of a link still put us over the line, prefer to print it on the
844844            // next line to give as much opportunity to keep the link text contents on one line.
845-             if  link. indexInParent >  0  && ( isOverPreferredLineLimit || state. lineNumber  >  savedState. lineNumber )  { 
845+             if  link. indexInParent >  0  && ( isOverPreferredLineLimit || state. effectiveLineNumber  >  savedState. effectiveLineNumber )  { 
846846                restoreState ( to:  savedState) 
847847                queueNewline ( ) 
848848                printRegularLink ( ) 
Original file line number Diff line number Diff line change @@ -708,6 +708,42 @@ class MarkupFormatterSimpleRoundTripTests: XCTestCase {
708708        checkCharacterEquivalence ( for:  source) 
709709    } 
710710
711+     func  testRoundTripHardBreakWithImage( )  { 
712+         let  source  =  """ 
713+         This is some text. \( "    " ) 
714+          
715+          """ 
716+         checkRoundTrip ( for:  source) 
717+         checkCharacterEquivalence ( for:  source) 
718+     } 
719+ 
720+     func  testRoundTripSoftBreakWithImage( )  { 
721+         let  source  =  """ 
722+         This is some text. 
723+          
724+          """ 
725+         checkRoundTrip ( for:  source) 
726+         checkCharacterEquivalence ( for:  source) 
727+     } 
728+ 
729+     func  testRoundTripHardBreakWithLink( )  { 
730+         let  source  =  """ 
731+         This is some text. \( "    " ) 
732+         [This is a link.](https://swift.org) 
733+          """ 
734+         checkRoundTrip ( for:  source) 
735+         checkCharacterEquivalence ( for:  source) 
736+     } 
737+ 
738+     func  testRoundTripSoftBreakWithLink( )  { 
739+         let  source  =  """ 
740+         This is some text. 
741+         [This is a link.](https://swift.org) 
742+          """ 
743+         checkRoundTrip ( for:  source) 
744+         checkCharacterEquivalence ( for:  source) 
745+     } 
746+ 
711747    /// Why not?
712748    func  testRoundTripReadMe( )  throws  { 
713749        let  readMeURL  =  URL ( fileURLWithPath:  #file) 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments