Skip to content
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

Add max line length option #203

Closed
HugoHeneault opened this issue Jul 7, 2014 · 8 comments
Closed

Add max line length option #203

HugoHeneault opened this issue Jul 7, 2014 · 8 comments

Comments

@HugoHeneault
Copy link

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
Copy link
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
Copy link
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
Copy link
Author

Wow. Seems great @duncanbeevers !

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

@duncanbeevers
Copy link
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
Copy link
Owner

kangax commented Jul 10, 2014

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

@duncanbeevers
Copy link
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
Copy link
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 as completed Jul 22, 2014
@revelt
Copy link

revelt commented Nov 6, 2018

For posterity, let me clarify a bit the issue regarding "some servers". The SMTP spec RFC 821, defined back in 1982 (source) says:

The maximum total length of a text line including the is 1000 characters (but not counting the leading dot duplicated for transparency).

As far as raw email source vs. line length is concerned, there are other factors in play, such as encoding (which can vary), for example quoted-printable is often used and it will encode limiting line length to 76 and so on. But as far as this 1000 character limiter is concerned, I'm pretty sure it's coming from this RFC 821 spec interpretation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants