trivago / prettier-plugin-twig-melody

Code formatting plugin for Prettier which can handle Twig/Melody templates
Apache License 2.0
155 stars 35 forks source link

Doesn't respect `"htmlWhitespceSensitivity": "strict"` #64

Open OldStarchy opened 4 years ago

OldStarchy commented 4 years ago

The below example shows the same content formatted in "html" mode and "twig" mode. The first line contains no whitespace within the div, the second does. In twig mode, whitespace is added to the first line, however both outputs should be equal.

.prettierrc ```bash ./node_modules/.bin/prettier --write --config .prettierrc test.* ``` ```json { "trailingComma": "all", "semi": true, "htmlWhitespaceSensitivity": "strict", "tabWidth": 4, "useTabs": true, "singleQuote": true, "endOfLine": "lf", "overrides": [ { "files": [ "*.yml", "*.yaml", "package.json" ], "options": { "tabWidth": 2, "useTabs": false } }, { "files": [ "*.md" ], "options": { "tabWidth": 4, "useTabs": false } } ], "plugins": [ "prettier-plugin-twig-melody" ] } ```

input: test.html and test.twig

<div data-foo="bar" data-foo="bar" data-foo="bar" data-foo="bar" data-foo="bar" data-foo="bar" data-foo="bar">baz</div>
<div data-foo="bar" data-foo="bar" data-foo="bar" data-foo="bar" data-foo="bar" data-foo="bar" data-foo="bar"> baz </div>

output: test.html

<div
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    >baz</div
>
<div
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
>
    baz
</div>

output: test.twig

<div data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar">
    baz
</div>
<div data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar"
    data-foo="bar">
    baz
</div>
OldStarchy commented 4 years ago

I've also just noticed that the first attribute isn't placed on its own line correctly, and the trailing > should also be on its own line.

therealgilles commented 3 years ago

Same problem here. This causes issues with underlines. Would be nice to get a fix.