@@ -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,44 +151,46 @@ 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" {
160160 try testWriteHTML (
161161 "<div id=\" content\" >Over 9000!</div>" ,
162- "<div id=\" content\" >Over 9000!</div>"
162+ "<div id=\" content\" >Over 9000!</div>" ,
163163 );
164164
165165 try testWriteHTML (
166166 "<root><!-- a comment --></root>" ,
167- "<root><!-- a comment --></root>"
167+ "<root><!-- a comment --></root>" ,
168168 );
169169
170170 try testWriteHTML (
171171 "<p>< > &</p>" ,
172- "<p>< > &</p>"
172+ "<p>< > &</p>" ,
173173 );
174174
175175 try testWriteHTML (
176176 "<p id=\" "><&"''\" >wat?</p>" ,
177- "<p id='\" ><&"'''>wat?</p>"
177+ "<p id='\" ><&"'''>wat?</p>" ,
178178 );
179179
180180 try testWriteFullHTML (
181181 \\<!DOCTYPE html>
182182 \\<html><head><title>It's over what?</title><meta name="a" value="b">
183183 \\</head><body>9000</body></html>
184184 \\
185- ,
186- "<html><title>It's over what?</title><meta name=a value=\" b\" >\n <body>9000"
187- );
185+ , "<html><title>It's over what?</title><meta name=a value=\" b\" >\n <body>9000" );
188186}
189187
190- fn testWriteHTML (comptime expected : []const u8 , src : []const u8 ) ! void {
191- return testWriteFullHTML ("<!DOCTYPE html>\n <html><head></head><body>" ++ expected ++ "</body></html>\n " , src );
188+ fn testWriteHTML (comptime expected_body : []const u8 , src : []const u8 ) ! void {
189+ const expected =
190+ "<!DOCTYPE html>\n <html><head></head><body>" ++
191+ expected_body ++
192+ "</body></html>\n " ;
193+ return testWriteFullHTML (expected , src );
192194}
193195
194196fn testWriteFullHTML (comptime expected : []const u8 , src : []const u8 ) ! void {
0 commit comments