@@ -71,7 +71,17 @@ void PushCurrentText() {
7171 string tagType = attributes [ 0 ] . ToLowerInvariant ( ) ;
7272
7373 currentText . Clear ( ) ;
74+
7475 bool isSelfClosing = IsSelfClosing ( tagType , attributes ) ;
76+
77+ // remove self-closing slash if attached to tagType
78+ tagType = tagType . TrimEnd ( '/' ) ;
79+
80+ // remove self-closing slash at end of attributes, if present
81+ if ( attributes . Length > 0 ) {
82+ attributes [ ^ 1 ] = attributes [ ^ 1 ] . TrimEnd ( '/' ) ;
83+ }
84+
7585 if ( closingTag ) {
7686 if ( isSelfClosing ) {
7787 // ignore closing tags of void elements since they don't
@@ -92,7 +102,11 @@ void PushCurrentText() {
92102 tags . Push ( tagType ) ;
93103 }
94104
95- appendTo . PushTag ( new MarkupNode ( tagType , null , ParseAttributes ( attributes ) ) , selfClosing : isSelfClosing ) ;
105+ if ( tagType == "br" ) {
106+ appendTo . PushNewline ( ) ;
107+ } else {
108+ appendTo . PushTag ( new MarkupNode ( tagType , null , ParseAttributes ( attributes ) ) , selfClosing : isSelfClosing ) ;
109+ }
96110 }
97111
98112 break ;
@@ -166,7 +180,7 @@ void PushCurrentText() {
166180 * </summary>
167181 */
168182 private static bool IsSelfClosing ( string tagType , string [ ] attributes ) {
169- if ( attributes [ ^ 1 ] == "/" ) {
183+ if ( tagType . EndsWith ( "/" ) || attributes [ ^ 1 ] . EndsWith ( "/" ) ) {
170184 return true ;
171185 }
172186
@@ -197,7 +211,8 @@ private static Dictionary<string, MarkupParameter> ParseAttributes(string[] attr
197211
198212 for ( int i = 1 ; i < attributes . Length ; i ++ ) { // First one should be the tag type, skip it
199213 string attribute = attributes [ i ] ;
200- if ( attribute == "/" )
214+
215+ if ( attribute == "" ) // tag ended with a detached self-closing slash
201216 continue ;
202217
203218 int equalsIndex = attribute . IndexOf ( '=' ) ;
0 commit comments