Add max line length option #203

Closed
HugoHeneault opened this Issue Jul 7, 2014 · 7 comments

Projects

None yet

3 participants

@HugoHeneault

Hello,

I use html-minifier for emails, and some mail servers automatically add a new line after 1000 caracters. This behaviour breaks html structure.

For example :

``` `

g="10"


It could be great if we can add an option to limit the line size without breaking the html. 
Do you think this is possible ?

Thanks.
@duncanbeevers
Collaborator

@In4matik I knocked out a super-basic version of this functionality here.

It's a bit kludgy though I have some ideas about how to improve it, but it should basically accomplish what you're after.

I tested it against the source of this page with a maxLineLength setting of 900, and collapseWhitespace true, and this was the result.

@kangax
Owner
kangax commented Jul 10, 2014

@duncanbeevers Looks pretty good! I'm only concerned about performance implications. Could you run node ./benchmark.js locally, and compare average time (reported at the end)?

@HugoHeneault

Wow. Seems great @duncanbeevers !

I haven't time to test it, but I will ! Thanks.

@duncanbeevers
Collaborator

@kangax
Benchmark output here run with gh-pages as-is, then with limit-line-length but not limiting lines, and finally with a maxLineLength of 500.

Speed looks pretty stable, variance seems insignificant.

@kangax
Owner
kangax commented Jul 10, 2014

Ok, let's get it in. Can you send a PR? Thanks.

@duncanbeevers
Collaborator

Sure. I was thinking of poking at this some more to get better-compressed results.

For example, right now it maximally-compresses

<a class="hey">link link</a>

to this

<a
 class="hey">
link link
</a>

I think the best we can hope for is this:

<a
class
=
"hey"
>
link
link
</a
>

But that's a fish to fry another day!

@duncanbeevers
Collaborator

I think this issue can be closed. If we want to pursue more aggressive splitting, I suggest we address that with another more-focused PR.

@kangax kangax closed this Jul 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment