-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Preserve some newlines & tabs w/o --pretty #1300
Comments
@dabutvin Just FYI, there was some pushback to adopting ImgBot w/o this RFE. |
I think we could add something like attrSep to js2svg config. Is this what you meant? module.exports = {
js2svg: {
attrSep: '\n'
}
}; <svg
xmlns="http://www.w3.org/2000/svg"
aria-label="Guidelines"
viewBox="0 0 512 512"><rect
width="512"
height="512"
rx="15%"
fill="#222"/><circle
fill="#f43"
r="256"
cx="256"
cy="256"/><circle
fill="#fd0"
r="217.5"
cx="256"
cy="256"/><circle
fill="#5d6"
r="192"
cx="256"
cy="256"/></svg> |
That's not altogether bad, but here's what I mean (assuming original is https://github.com/edent/SuperTinyIcons/blob/master/images/guidelines/guideline.svg), which includes my option 4 above @ max 80 chars/line: <svg xmlns="http://www.w3.org/2000/svg"
aria-label="Guidelines" role="img"
viewBox="0 0 512 512"><rect
width="512" height="512"
rx="15%"
fill="#222"/><circle fill="#f43" r="256" cx="256" cy="256"/><circle fill="#fd0"
r="217.5" cx="256" cy="256"/><circle fill="#5d6" r="192" cx="256"
cy="256"/></svg> Better than yours for a compact diff, no? |
I wouldn't like to add such complexity in svg generator. Adding newlines to attributes may also be error prone. So better avoid new area of bugs. |
Ok, leaving off |
I don't get the rest
|
Sorry, I botched my example above. I updated it to be correct. So, now, each line (separated by LF) corresponds more exactly with previous version (so changes seen better) but is optimal filesize (given what you pasted was already optimized), so diffs/visual inspection can show better what changed. |
Here's a better IRL example: https://github.com/edent/SuperTinyIcons/pull/516/files If using SVGO in default mode, the contents of adobe.svg would be mashed together in 1 line, & would be hard to differentiate what had changed. But, keeping whitespace (& attribute ordering, which already has an option) as close as possible to original, while keeping optimal filesize, allows the diff to be easily understood. More examples @ https://github.com/edent/SuperTinyIcons/pull/517/files & https://github.com/edent/SuperTinyIcons/pull/518/files |
I suppose this could be implemented as a mode of |
N.B.: The closest issue I found for this is #230. If there's an existing option or open issue, I'd happily close this.
There needs to be a way to convert required, non-eliminable whitespace sequences made solely of
CR LF
[other whitespace]) to justLF
Tab
[non-{CR
,LF
} whitespace]) to justTab
CR
,LF
,Tab
] whitespace) toSpace
(similar to current)space
s toLF
to break up over-long (configurable) 1-liners efficientlyThis will keep filesize the same as the current transform, while allowing to more easily compare by eye (or Github Δ comparison 😉) or edited by hand via any modern (i.e., basically anything newer than Windows Notepad 🙄) text editor. The sole downside I can think of that it might worsen SVGZ sizes for those who use that, but maybe an option to retain the current behavior would solve that.
--pretty
has the problem that it generally increases filesize from minimal.What do y'all think? I believe this would require to adjust https://github.com/svg/svgo/tree/master/plugins%2FcleanupAttrs.js to the above.
The text was updated successfully, but these errors were encountered: