Skip to content

Commit

Permalink
Add support for empty indent
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 19, 2024
1 parent eb8bb24 commit 91da066
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export function format(tree, options) {
indent:
typeof settings.indent === 'number'
? ' '.repeat(settings.indent)
: settings.indent || ' '
: typeof settings.indent === 'string'
? settings.indent
: ' '
}

minifyWhitespace(tree, {newlines: true})
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/indent-empty-string/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!doctype html><p>Foo
<strong>bar</strong></p>
3 changes: 3 additions & 0 deletions test/fixtures/indent-empty-string/options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"indent": ""
}
10 changes: 10 additions & 0 deletions test/fixtures/indent-empty-string/output.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head></head>
<body>
<p>
Foo
<strong>bar</strong>
</p>
</body>
</html>
2 changes: 2 additions & 0 deletions test/fixtures/indent-zero/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!doctype html><p>Foo
<strong>bar</strong></p>
3 changes: 3 additions & 0 deletions test/fixtures/indent-zero/options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"indent": 0
}
10 changes: 10 additions & 0 deletions test/fixtures/indent-zero/output.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head></head>
<body>
<p>
Foo
<strong>bar</strong>
</p>
</body>
</html>

0 comments on commit 91da066

Please sign in to comment.