Skip to content

Commit

Permalink
Add support for comments
Browse files Browse the repository at this point in the history
Closes GH-9.
  • Loading branch information
wooorm committed Jun 21, 2020
1 parent 27f47c9 commit 5f2eac2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function format(options) {
while (++index < length) {
child = children[index]

if (child.type === 'text') {
if (child.type === 'text' || child.type === 'comment') {
if (child.value.indexOf('\n') !== -1) {
newline = true
}
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/comments/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!doctype html>
<title>Comments</title>
<foo> <!-- comment --> </foo>
<div><!-- comment
comment --></div>
<p><span>span</span><!-- comment
comment --><em>em</em></p>
17 changes: 17 additions & 0 deletions test/fixtures/comments/output.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html>
<head>
<title>Comments</title>
</head>
<body>
<foo><!-- comment --></foo>
<div>
<!-- comment
comment -->
</div>
<p>
<span>span</span><!-- comment
comment --><em>em</em>
</p>
</body>
</html>

0 comments on commit 5f2eac2

Please sign in to comment.