HubSpot/prettier-plugin-hubl

Line breaks in string values are gradually erased

evelynn-causemic opened this issue · 0 comments

Description

String values contained with HubL blocks gradually have any newlines removed, due to a conflict between opinionated style rules and whitespace formatting rules.

The formatter converts newline escape sequences (\n) contained within strings to line breaks when run. However, it also collapses line breaks within strings when run — this leads to all line breaks within strings being removed after the formatter is run twice.

Expected behavior

The informational content of a string should not be altered by the formatter.

To Reproduce

Use a line break or newline escape sequence within quoted text inside of a HubL block.

Original Source Code:

{% set test_value="First line\nSecond line" %}

Formatted Source Code (first run):

{% set test_value="First line
Second line" %}

Formatted Source Code (second run):

{% set test_value="First lineSecond line" %}

Checklist

  • I have checked the known issues to make sure this isn’t already a known issue.