dave-kennedy / clean-html

HTML cleaner and beautifier for Node
The Unlicense
47 stars 10 forks source link

Remove pre/post whitespace within style attributes #24

Open canadaduane opened 1 year ago

canadaduane commented 1 year ago

Currently, clean-html transforms styles with whitespace into a clean wrapped set of lines, e.g.

<div style="
        font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto;
        height: 100dvh;
        display: flex;
        flex-direction: column; 
        align-items: center;
        justify-content: center;
        color: #435d7b;
        background-color: #d0b641;
        gap: 20px;
      ">...</div>

to:

<div style=" font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto; height: 100dvh; display:
        flex; flex-direction: column; align-items: center; justify-content: center; color: #435d7b; background-color:
        #d0b641; gap: 20px; ">
...
</div>

However, it leaves a space before the first style and after the last style. Would it be possible to strip these, i.e.:

<div style="font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto; height: 100dvh; display:
        flex; flex-direction: column; align-items: center; justify-content: center; color: #435d7b; background-color:
        #d0b641; gap: 20px;">
...
</div>
dave-kennedy commented 1 year ago

Should be doable! Just need to dust off the cobwebs first. Pull requests are always welcome :)