PHPStorm wrapping is breaking svg d attributes

I have a svg file inserted within a blade.php file. If I make some edits to that svg file (I am using blade to insert a fill color for each path), PHPStorm inserts breaks in the d attribute at places where it actually breaks the attribute and causes an error in the Chrome console. E.g.,

'

Error: <path> attribute d: Expected number, "…194\n    .0,28.7 L198.8,27.4 L199…".

 

The d attribute in question goes to a new line right at the decimal in "L194.0", as in 

L194

.0

This happens in several paths within this file. I've tried turning wrapping in and off, and fiddled with the rather large array of options for indenting and wrapping. But I can't fix this behavior. What can I do to to control this code and not have PHPStorm not to break these lines up at the decimal? Using PHP 2018/2.

12 comments
Comment actions Permalink

Hi there,

Need a code sample to try it locally + your Code Style (if you could export and share it).

But generally speaking it should be at "Settings/Preferences | Editor | Code Style | HTML | Other" or perhaps "Settings/Preferences | Editor | Code Style | XML | Other"

Maybe it's "Keep line breaks in text" option? Need to see and try myself to give any better suggestion.

0
Comment actions Permalink

Thanks for your initial suggestions. I’m trying them out now. I’m afraid that I find the wrapping and line break settings a bit overwhelming. I didn’t try the html style because it didn’t seem to apply in this situation….

I shared the files in a direct email reply to you, but I don't think it went through. How do you share files on this board?

0
Comment actions Permalink

>How do you share files on this board?

Share them via Google Drive/OneDrive or alike and post a link here. That's the only way with this forum software.

0
Comment actions Permalink

OK .. what I see:

1) I got your blade.php file, copied it contents into plain .php inside <body> into default HTML skeleton file. Then got rid of all blade tags .. so it's plain HTML basically just in .php file. This is so I can preview the result in Chrome without using Blade.

2) The file shows the same error ... which I can fix (remove unnecessary line break) .. and after that browser displays it just fine (no more errors in Chrome console).

3) This tells me that you gave me already "broken" file (lines 80-81).

 

Now .. I have not made any changes in your Code Style scheme ... and it reformatted the code without breaking the "d" attribute for me -- IDE did not add the extra line break or space inside the attribute value. Id added new lines here and there .. but no "d" attribute breaking happened in either html.php and your fixed blade.php.

I can copy content from reformatted blade.php back into html.php, and after removing Blade directives it will still display just fine (no errors in Chrome console).

 

So I'm not sure at all what is happened to this file that led to adding extra line break in a wrong place. On my PC (PhpStorm 2018.1.6) reformatting the file does not seem to break "d" attribute even with your provided Code Style.

Maybe you have "Wrap on typing" enabled at some point .. and that added it somehow ... but I have never had it enabled so cannot suggest anything (how exactly it works/when it add line breaks etc).

Maybe it's some another plugin that you have and I don't... and it somehow interfere... (not sure on how likely it will be the case though)

No better ideas from me right now.

0
Comment actions Permalink

Thanks Andriy. It's possible that I had "wrap on typing" turned on. but as you suggested, it's still not clear why PHPStorm would break the line in the middle of an path definition command? The problem seemed to begin after I edited the blade statement within those paths. There are so many wrapping options that I'm not always sure what the best settings are! In any case, I've got that turned off now, and will see how it behaves. Thanks!

0
Comment actions Permalink

Hi Andriy, I had to make a couple of edits this morning, and the same problem occurred. With the examples I gave you, try changing all fill attributes to "#000000" and all stroke widths to "0.7".

For me, the file broke at Door County; there's a break at the end of what is now the second to last line: 340.5 is 340 [line break] .5 (hopefully this will show up correctly here):

<path stroke="#000000" stroke-width="0.7" id="wisc-15" d="M636.6,255.7 L636.7,247.0 L638.7,247.1 L640.2,249.0 L646.2,247.8 L647.5,252.1 L646.6,259.3 L634.8,258.7 Z M554.5,363.8 L557.4,358.9 L556.4,356.6 L563.4,342.8 L567.9,337.8 L573.6,336.1 L573.0,338.7 L578.7,332.8 L581.3,334.4 L585.8,330.9 L594.7,340.9 L599.5,343.0 L599.5,346.4 L594.7,362.8 L566.5,363.6 Z M594.3,336.9 L591.4,331.2 L590.4,325.2 L594.1,313.1 L600.2,304.9 L602.5,304.2 L604.5,292.8 L607.6,285.9 L612.8,286.9 L617.9,282.3 L620.5,271.8 L623.0,271.0 L624.6,265.3 L627.4,267.4 L634.2,267.2 L633.3,277.6 L629.1,275.0 L627.0,282.7 L628.5,289.3 L622.6,288.5 L628.0,294.5 L625.1,296.7 L624.2,302.1 L620.4,301.7 L614.1,314.6 L612.9,319.5 L615.6,322.2 L611.2,325.6 L609.6,331.3 L602.9,340.3 L598.4,340
.5 Z">
<desc>
<fips>55029</fips>
<name>Door</name>
<hc-middle-x>0.56</hc-middle-x>
<hc-middle-y>0.57</hc-middle-y>
<hc-key>us-wi-029</hc-key>
<hc-a2>DO</hc-a2>
</desc>
</path>

It's an easy edit to fix manually, but it's not very convenient to have to manually edit this file to fix line breaks that the IDE is doing on its own every time I make changes to the file. I have wrap on typing turned off, although "use soft wraps" is turned on for this file.

0
Comment actions Permalink

>With the examples I gave you, try changing all fill attributes to "#000000"

I do not see any "fill" attribute. Only $fill Blade variable references. Or maybe you meant changing this -- stroke="#6E6E6E" ?

 

>and all stroke widths to "0.7".

How do you do that? Manually going to each "path" node and change "0.4" to be "0.7" (that's for stroke widths)? Or perhaps some find/replace or multiple carets?

 

Previously I've used 2018.1.6. I've just installed 2018.2 and will try that after getting clarification on the above (so we are both doing the same)..

0
Comment actions Permalink

Yes, sorry, I meant to write stroke, not fill. I did a multiple caret change for the first, and a find/replace for the second after realizing that a multiple caret replace would make unintended changes elsewhere (the string 0.4 exists in too many other spots).

0
Comment actions Permalink

Here are my steps:

1) I got the original wi-map.blade.php

2) Opened it and fixed that initial "broken" place

3) Selected #6E6E6E and using Alt+J created multiple carets. Typed #000000 and saved the file -- still no breaks.

4) Used Ctrl+R (Replace on page) -- Find "0.4" (including quotes) and replace by "0.7". Still no breaks.

5) I've also used Reformat Code (in Blade file) after final replace -- no breaks.

When I say "no breaks": I took whole Blade file content and inserted in into a plain HTML file inside the <body> tag and then got rid of any Blade output instructions (simple regex: "\{\{.*\}\}") and tested the outcome in Chrome browser.

 

So right now I have no clue what might be causing this behaviour for you as on my computer it does not break any "d" attribute during the above operations. Possibly it's some plugin that you have but I do not ... or some missing step etc.

PhpStorm 2018.2
Build #PS-182.3684.42, built on July 26, 2018
JRE: 1.8.0_152-release-1248-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

0
Comment actions Permalink

Ok, thanks for trying. I have a few plugins installed -- Laravel, VueJS, NodeJS,JS Support, Sass,Less. I suppose it's possible that one of these is the cause, and maybe we'll never find out. I don't think you are missing any steps, so it may have something to do with my setup. For what it's worth, the unwanted breaks always seem to occur at a decimal point. Maybe that's a clue....

0
Comment actions Permalink

Try contacting Support Team -- use "Submit a request" link at the top of this page.

1

Please sign in to leave a comment.