Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Fix issue #171 #202

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/printer/printer-liquid-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ function printNode(
};

if (isRawMarkupIdentationSensitive()) {
return node.value;
// trim surrounding new lines
return node.value.trim();
}

const lines = bodyLines(node.value);
Expand Down
26 changes: 26 additions & 0 deletions test/issue-171/fixed.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
It should not add new lines
<script>
({{ a }});
``;
</script>

It should not fail on missing new line after opening script tag.
<script>
({{ a }});
``;
</script>

It should not fail on missing new line before closing script tag.
<script>
({{ a }});
``;
</script>

It should consume extra surrounding spaces.
<script>
({{ a }});
``;
</script>

It should not fail on blank input.
<script></script>
23 changes: 23 additions & 0 deletions test/issue-171/index.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
It should not add new lines
<script>
({{ a }});
``;
</script>

It should not fail on missing new line after opening script tag.
<script>({{ a }});
``;</script>

It should not fail on missing new line before closing script tag.
<script>
({{ a }});
``;</script>

It should consume extra surrounding spaces.
<script>
({{ a }});
``;
</script>

It should not fail on blank input.
<script></script>
6 changes: 6 additions & 0 deletions test/issue-171/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { assertFormattedEqualsFixed } from '../test-helpers';
import * as path from 'path';

describe(`Unit: ${path.basename(__dirname)}`, () => {
assertFormattedEqualsFixed(__dirname);
});