asyncLiz / minify-html-literals

Minify HTML template literal strings
MIT License
68 stars 14 forks source link

Minify multiline svg #25

Closed Raynos closed 3 years ago

Raynos commented 3 years ago

I'm using this module and have an issue with minifying SVG attributes that contain new lines.

The SVG specification says that newlines behave the same as spaces.

I found an upstream issue ( https://github.com/kangax/html-minifier/issues/865 ) about it not being supported yet.

Then I found a solution in a different package ( https://github.com/dominique-mueller/angular-package-builder/issues/146 ) which seems to work pretty well and I applied it here to this project.

coveralls commented 3 years ago

Pull Request Test Coverage Report for Build 85


Files with Coverage Reduction New Missed Lines %
src/strategy.ts 5 65.82%
<!-- Total: 5 -->
Totals Coverage Status
Change from base Build 77: 1.0%
Covered Lines: 96
Relevant Lines: 112

💛 - Coveralls
Raynos commented 3 years ago

@asyncLiz Is there anything you need to merge this patch ?

Raynos commented 3 years ago

this repo is unmaintained.

asyncLiz commented 3 years ago

Hi @Raynos, I'm sorry for the delay in getting to this PR. Due to the pandemic, things have been pretty rough and these side projects have taken a hit and fallen to the side.

Ironically this is actually exactly why I developed the project with a modular strategy object! So that users could override specific steps of the process and add (or fix) their own logic without needing to wait for a patch.

I'll work on a solution for multiline svg minification now that I've had a brief moment to address some of the issues building up on this library.

Raynos commented 3 years ago

This pull request still works. I’ve been using my fork for a while.

asyncLiz commented 3 years ago

One slight problem with this approach is that it doesn't take into account newlines that should be preserved with minified HTML content. For example, newlines within <textarea> and <pre> tags.

I'm working on an alternate solution to remove newlines only within <svg> tags.

asyncLiz commented 3 years ago

Pushed an update to master that resolves this issue. A new release will come shortly!