File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Sources/Markdown/Walker/Walkers
Tests/MarkdownTests/Visitors Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -1138,7 +1138,7 @@ public struct MarkupFormatter: MarkupWalker {
11381138 public mutating func visitInlineAttributes( _ attributes: InlineAttributes ) {
11391139 let savedState = state
11401140 func printInlineAttributes( ) {
1141- print ( " [ " , for: attributes)
1141+ print ( " ^ [" , for: attributes)
11421142 descendInto ( attributes)
11431143 print ( " ]( " , for: attributes)
11441144 print ( attributes. attributes, for: attributes)
@@ -1152,7 +1152,7 @@ public struct MarkupFormatter: MarkupWalker {
11521152 // gets into the realm of JSON formatting which might be out of scope of
11531153 // this formatter. Therefore if exceeded, prefer to print it on the next
11541154 // line to give as much opportunity to keep the attributes on one line.
1155- if attributes. indexInParent > 0 && ( isOverPreferredLineLimit || state. lineNumber > savedState. lineNumber ) {
1155+ if attributes. indexInParent > 0 && ( isOverPreferredLineLimit || state. effectiveLineNumber > savedState. effectiveLineNumber ) {
11561156 restoreState ( to: savedState)
11571157 queueNewline ( )
11581158 printInlineAttributes ( )
Original file line number Diff line number Diff line change @@ -744,6 +744,24 @@ class MarkupFormatterSimpleRoundTripTests: XCTestCase {
744744 checkCharacterEquivalence ( for: source)
745745 }
746746
747+ func testRoundTripHardBreakWithInlineAttribute( ) {
748+ let source = """
749+ This is some text. \( " " )
750+ ^[This is some attributed text.](rainbow: 'extreme')
751+ """
752+ checkRoundTrip ( for: source)
753+ checkCharacterEquivalence ( for: source)
754+ }
755+
756+ func testRoundTripSoftBreakWithInlineAttribute( ) {
757+ let source = """
758+ This is some text.
759+ ^[This is some attributed text.](rainbow: 'extreme')
760+ """
761+ checkRoundTrip ( for: source)
762+ checkCharacterEquivalence ( for: source)
763+ }
764+
747765 /// Why not?
748766 func testRoundTripReadMe( ) throws {
749767 let readMeURL = URL ( fileURLWithPath: #file)
You can’t perform that action at this time.
0 commit comments