-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect splitting of attribute value when line is too long #61
Comments
Can you workaround it (for quick-resolving) by moving it into a shorter function that will be called? What would be your expected output? Also are you sure that |
Sure thing. I never intended to use it like this, just noticed it during quick and dirty testing.
…On Jan 14, 2020, 18:48, at 18:48, Shinigami ***@***.***> wrote:
Can you workaround it (for quick-resolving) by moving it into a shorter
function that will be called?
What would be your expected output?
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#61 (comment)
|
Yep, that's also a thing. |
I made some tests on https://pughtml.com Input- const getRepository = () => ({ slug: 'slug' })
- const Nav = { currentProject: () => ({ repo: () => ({ buildNoContext: () => 'no-context' }) }) }
- const hasError = true
div
table
tbody
tr
td
a(x=1, :href=`Nav.currentProject().repo(getRepository(pipeline).slug).buildNoContext()`)
td
a(x=2, :href='Nav.currentProject().repo(getRepository(pipeline).slug).buildNoContext()')
td
a(x=3, :href=Nav.currentProject().repo(getRepository(pipeline).slug).buildNoContext())
td
a(x=4, :href=`Nav.currentProject()
.repo(getRepository(pipeline).slug)
.buildNoContext()`)
//- td
//- // Syntax Error: Unterminated string constant - line 21:25
//- a(x=5, :href='Nav.currentProject()
//- .repo(getRepository(pipeline).slug)
//- .buildNoContext()')
td
a(x=6, :href=Nav.currentProject()
.repo(getRepository(pipeline).slug)
.buildNoContext())
tr
td
span(x=7, :class='{ "text-danger": hasError }')
td
span(x=8, :class=`{ "text-danger": hasError }`)
td
span(x=9, :class={ "text-danger": hasError })
td
// Syntactically incorrect HTML
span(x=10, class='{ "text-danger": hasError }')
td
// Syntactically incorrect HTML
span(x=11, class=`{ "text-danger": hasError }`)
td
span(x=12, class={ "text-danger": hasError })
Output<div>
<table>
<tbody>
<tr>
<td><a x="1" :href="Nav.currentProject().repo(getRepository(pipeline).slug).buildNoContext()"></a></td>
<td><a x="2" :href="Nav.currentProject().repo(getRepository(pipeline).slug).buildNoContext()"></a></td>
<td><a x="3" :href="no-context"></a></td>
<td><a x="4" :href="Nav.currentProject()
.repo(getRepository(pipeline).slug)
.buildNoContext()"></a></td>
<td><a x="6" :href="no-context"></a></td>
</tr>
<tr>
<td><span x="7" :class="{ "text-danger": hasError }"></span></td>
<td><span x="8" :class="{ "text-danger": hasError }"></span></td>
<td><span x="9" :class="{"text-danger":true}"></span></td>
<td>
<!-- Syntactically incorrect HTML--><span class="{ "text-danger": hasError }" x="10"></span></td>
<td>
<!-- Syntactically incorrect HTML--><span class="{ "text-danger": hasError }" x="11"></span></td>
<td><span class="text-danger" x="12"></span></td>
</tr>
</tbody>
</table>
</div> To sum up
For your case: What are you expecting? Test-Case 2 or 4? |
Across the project there are only to variants (and they are correctly formatted by plugin):
So, to recap: I expect formatting as described in Test Case 2. BTW Test 3 looks weird. Never seen anything like that before. |
Could you post me your prettier configuration? The backtick quoted dict value formatting is definitely something that I could address in the near future in it's own issue |
|
Ok, I workaround an internal use of the prettier library itself Nevermind, I will release a 1.1.4 for now so that you can work again There is another (known) "problem" that a tag with only one long argument is wrapped in it's own line // so
a(:href='Nav.currentProject().repo(getRepository(pipeline).slug).buildNoContext()')
// will currently become
a(
:href='Nav.currentProject().repo(getRepository(pipeline).slug).buildNoContext()'
) That's because it's more than 80/ |
Released v1.1.4 |
Just tested it. Works fine. Thank you for such a quick fix!
Well, I personally don't classify it as a problem. Writing such long lines is a bad practice anyway. |
Before formatting:
After formatting:
This is incorrect syntax: no newlines accepted in single quotes.
The text was updated successfully, but these errors were encountered: