@@ -123,7 +123,7 @@ fn isVoid(elem: *parser.Element) !bool {
123123fn writeEscapedTextNode (writer : anytype , value : []const u8 ) ! void {
124124 var v = value ;
125125 while (v .len > 0 ) {
126- const index = std .mem .indexOfAnyPos (u8 , v , 0 , &.{'&' , '<' , '>' }) orelse {
126+ const index = std .mem .indexOfAnyPos (u8 , v , 0 , &.{ '&' , '<' , '>' }) orelse {
127127 return writer .writeAll (v );
128128 };
129129 try writer .writeAll (v [0.. index ]);
@@ -133,14 +133,14 @@ fn writeEscapedTextNode(writer: anytype, value: []const u8) !void {
133133 '>' = > try writer .writeAll (">" ),
134134 else = > unreachable ,
135135 }
136- v = v [index + 1 .. ];
136+ v = v [index + 1 .. ];
137137 }
138138}
139139
140140fn writeEscapedAttributeValue (writer : anytype , value : []const u8 ) ! void {
141141 var v = value ;
142142 while (v .len > 0 ) {
143- const index = std .mem .indexOfAnyPos (u8 , v , 0 , &.{'&' , '<' , '>' , '"' }) orelse {
143+ const index = std .mem .indexOfAnyPos (u8 , v , 0 , &.{ '&' , '<' , '>' , '"' }) orelse {
144144 return writer .writeAll (v );
145145 };
146146 try writer .writeAll (v [0.. index ]);
@@ -151,40 +151,26 @@ fn writeEscapedAttributeValue(writer: anytype, value: []const u8) !void {
151151 '"' = > try writer .writeAll (""" ),
152152 else = > unreachable ,
153153 }
154- v = v [index + 1 .. ];
154+ v = v [index + 1 .. ];
155155 }
156156}
157157
158158const testing = std .testing ;
159159test "dump.writeHTML" {
160- try testWriteHTML (
161- "<div id=\" content\" >Over 9000!</div>" ,
162- "<div id=\" content\" >Over 9000!</div>"
163- );
164-
165- try testWriteHTML (
166- "<root><!-- a comment --></root>" ,
167- "<root><!-- a comment --></root>"
168- );
169-
170- try testWriteHTML (
171- "<p>< > &</p>" ,
172- "<p>< > &</p>"
173- );
174-
175- try testWriteHTML (
176- "<p id=\" "><&"''\" >wat?</p>" ,
177- "<p id='\" ><&"'''>wat?</p>"
178- );
160+ try testWriteHTML ("<div id=\" content\" >Over 9000!</div>" , "<div id=\" content\" >Over 9000!</div>" );
161+
162+ try testWriteHTML ("<root><!-- a comment --></root>" , "<root><!-- a comment --></root>" );
163+
164+ try testWriteHTML ("<p>< > &</p>" , "<p>< > &</p>" );
165+
166+ try testWriteHTML ("<p id=\" "><&"''\" >wat?</p>" , "<p id='\" ><&"'''>wat?</p>" );
179167
180168 try testWriteFullHTML (
181169 \\<!DOCTYPE html>
182170 \\<html><head><title>It's over what?</title><meta name="a" value="b">
183171 \\</head><body>9000</body></html>
184172 \\
185- ,
186- "<html><title>It's over what?</title><meta name=a value=\" b\" >\n <body>9000"
187- );
173+ , "<html><title>It's over what?</title><meta name=a value=\" b\" >\n <body>9000" );
188174}
189175
190176fn testWriteHTML (comptime expected : []const u8 , src : []const u8 ) ! void {
0 commit comments