OLD | NEW |
1 /// Support code for the tests in this directory. | 1 /// Support code for the tests in this directory. |
2 library support; | 2 library support; |
3 | 3 |
4 import 'dart:io'; | 4 import 'dart:io'; |
5 import 'dart:collection'; | 5 import 'dart:collection'; |
6 import 'package:path/path.dart' as path; | 6 import 'package:path/path.dart' as path; |
7 import 'package:html5lib/src/treebuilder.dart'; | 7 import 'package:html5lib/src/treebuilder.dart'; |
8 import 'package:html5lib/dom.dart'; | 8 import 'package:html5lib/dom.dart'; |
9 import 'package:html5lib/dom_parsing.dart'; | 9 import 'package:html5lib/dom_parsing.dart'; |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 data.forEach((key, value) { | 83 data.forEach((key, value) { |
84 if (value.endsWith("\n")) { | 84 if (value.endsWith("\n")) { |
85 data[key] = value.substring(0, value.length - 1); | 85 data[key] = value.substring(0, value.length - 1); |
86 } | 86 } |
87 }); | 87 }); |
88 return data; | 88 return data; |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 /// Serialize the [document] into the html5 test data format. | 92 /// Serialize the [document] into the html5 test data format. |
93 testSerializer(Document document) { | 93 testSerializer(document) { |
94 return (new TestSerializer()..visit(document)).toString(); | 94 return (new TestSerializer()..visit(document)).toString(); |
95 } | 95 } |
96 | 96 |
97 /// Serializes the DOM into test format. See [testSerializer]. | 97 /// Serializes the DOM into test format. See [testSerializer]. |
98 class TestSerializer extends TreeVisitor { | 98 class TestSerializer extends TreeVisitor { |
99 final StringBuffer _str; | 99 final StringBuffer _str; |
100 int _indent = 0; | 100 int _indent = 0; |
101 String _spaces = ''; | 101 String _spaces = ''; |
102 | 102 |
103 TestSerializer() : _str = new StringBuffer(); | 103 TestSerializer() : _str = new StringBuffer(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 key = "${attr.prefix} ${attr.name}"; | 156 key = "${attr.prefix} ${attr.name}"; |
157 } | 157 } |
158 _newline(); | 158 _newline(); |
159 _str.write('$key="$v"'); | 159 _str.write('$key="$v"'); |
160 } | 160 } |
161 indent -= 2; | 161 indent -= 2; |
162 } | 162 } |
163 visitChildren(node); | 163 visitChildren(node); |
164 } | 164 } |
165 } | 165 } |
OLD | NEW |