| // Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file | |
| // for details. All rights reserved. Use of this source code is governed by a | |
| // BSD-style license that can be found in the LICENSE file. | |
| import 'package:analyzer_utilities/html_parser.dart' as html_parser; | |
| import 'package:test/test.dart'; | |
| void main() { | |
| test('removes empty HTML comments', () { | |
| var document = html_parser.parse( | |
| '<div><!---->hello</div>', | |
| Uri.parse('test.html'), | |
| ); | |
| expect(document.outerHtml, '<!DOCTYPE html><div>hello</div>\n'); | |
| }); | |
| test('removes comments containing greater-than signs', () { | |
| var document = html_parser.parse( | |
| '<div><!-- a > b -->hello</div>', | |
| Uri.parse('test.html'), | |
| ); | |
| expect(document.outerHtml, '<!DOCTYPE html><div>hello</div>\n'); | |
| }); | |
| test('removes multiline comments', () { | |
| var document = html_parser.parse( | |
| '<div><!--\nmultiline\ncomment\n-->hello</div>', | |
| Uri.parse('test.html'), | |
| ); | |
| expect(document.outerHtml, '<!DOCTYPE html><div>hello</div>\n'); | |
| }); | |
| } |