@@ -11,7 +11,7 @@ public static Doc PrintOpeningTag(RawNode rawNode, PrintingContext context)
1111 return Doc . Concat (
1212 PrintOpeningTagStart ( rawNode , context ) ,
1313 Attributes . Print ( rawNode , context ) ,
14- rawNode . IsEmpty ? Doc . Null : PrintOpeningTagEnd ( rawNode )
14+ rawNode . IsEmpty ? Doc . Null : PrintOpeningTagEnd ( rawNode , context )
1515 ) ;
1616 }
1717
@@ -22,23 +22,23 @@ rawNode.PreviousNode is not null
2222 && NeedsToBorrowNextOpeningTagStartMarker ( rawNode . PreviousNode )
2323 ? Doc . Null
2424 : Doc . Concat (
25- PrintOpeningTagPrefix ( rawNode ) ,
25+ PrintOpeningTagPrefix ( rawNode , context ) ,
2626 PrintOpeningTagStartMarker ( rawNode , context )
2727 ) ;
2828 }
2929
30- private static Doc PrintOpeningTagEnd ( RawNode rawNode )
30+ private static Doc PrintOpeningTagEnd ( RawNode rawNode , PrintingContext context )
3131 {
3232 return
3333 rawNode . Nodes . FirstOrDefault ( ) is { } firstNode
34- && NeedsToBorrowParentOpeningTagEndMarker ( firstNode )
34+ && NeedsToBorrowParentOpeningTagEndMarker ( firstNode , context )
3535 ? Doc . Null
3636 : ">" ;
3737 }
3838
39- public static Doc PrintOpeningTagPrefix ( RawNode rawNode )
39+ public static Doc PrintOpeningTagPrefix ( RawNode rawNode , PrintingContext context )
4040 {
41- return NeedsToBorrowParentOpeningTagEndMarker ( rawNode ) ? ">" : "" ;
41+ return NeedsToBorrowParentOpeningTagEndMarker ( rawNode , context ) ? ">" : "" ;
4242 }
4343
4444 public static Doc PrintClosingTag ( RawNode rawNode , PrintingContext context )
@@ -53,7 +53,7 @@ public static Doc PrintClosingTagStart(RawNode rawNode, PrintingContext context)
5353 {
5454 var lastChild = rawNode . Nodes . LastOrDefault ( ) ;
5555
56- return lastChild is not null && PrintParentClosingTagStartWithContent ( lastChild )
56+ return lastChild is not null && PrintParentClosingTagStartWithContent ( lastChild , context )
5757 ? Doc . Null
5858 : PrintClosingTagStartMarker ( rawNode , context ) ;
5959 }
@@ -78,7 +78,7 @@ public static Doc PrintClosingTagEndMarker(RawNode rawNode)
7878
7979 public static Doc PrintClosingTagSuffix ( RawNode rawNode , PrintingContext context )
8080 {
81- return PrintParentClosingTagStartWithContent ( rawNode )
81+ return PrintParentClosingTagStartWithContent ( rawNode , context )
8282 ? PrintClosingTagStartMarker ( rawNode . Parent ! , context )
8383 : NeedsToBorrowNextOpeningTagStartMarker ( rawNode )
8484 ? PrintOpeningTagStartMarker ( rawNode . NextNode ! , context )
@@ -113,7 +113,10 @@ private static bool NeedsToBorrowNextOpeningTagStartMarker(RawNode rawNode)
113113 ;
114114 }
115115
116- private static bool PrintParentClosingTagStartWithContent ( RawNode rawNode )
116+ private static bool PrintParentClosingTagStartWithContent (
117+ RawNode rawNode ,
118+ PrintingContext context
119+ )
117120 {
118121 /*
119122 * <p>
@@ -147,7 +150,8 @@ Life is demanding.
147150 </Element>
148151</Root>
149152 */
150- return rawNode . NextNode is null
153+ return context . Options . XmlWhitespaceSensitivity is XmlWhitespaceSensitivity . Strict
154+ && rawNode . NextNode is null
151155 && rawNode . IsTextLike ( )
152156 && rawNode . GetLastDescendant ( ) is { NodeType : XmlNodeType . Text } textNode
153157 && (
@@ -157,7 +161,10 @@ Life is demanding.
157161 ) ;
158162 }
159163
160- public static bool NeedsToBorrowParentOpeningTagEndMarker ( RawNode rawNode )
164+ public static bool NeedsToBorrowParentOpeningTagEndMarker (
165+ RawNode rawNode ,
166+ PrintingContext context
167+ )
161168 {
162169 /*
163170 * <p
@@ -168,7 +175,8 @@ public static bool NeedsToBorrowParentOpeningTagEndMarker(RawNode rawNode)
168175 * ><a
169176 * ^
170177 */
171- return rawNode . PreviousNode is null
178+ return context . Options . XmlWhitespaceSensitivity is XmlWhitespaceSensitivity . Strict
179+ && rawNode . PreviousNode is null
172180 && rawNode . NodeType is XmlNodeType . Text
173181 && rawNode . Value ! [ 0 ] is not ( '\r ' or '\n ' ) ;
174182 }
0 commit comments