grunt-usemin icon indicating copy to clipboard operation
grunt-usemin copied to clipboard

Insufficient linefeed detection

Open mlegenhausen opened this issue 13 years ago • 8 comments

The current approach to detect the linefeed via a regex leads to problems when you have files where the line endings are mixed up (of cause that shouldn't be the case, but can happen). This leads to problems when replacing the code blocks, where they are not getted replaced and finding that bug was really hard.

In the current version the linefeed is only used for rejoining the extracted code blocks. There should be no need for the rejoining when simply reusing the extracted codeblock for replacing.

mlegenhausen avatar Mar 27 '13 15:03 mlegenhausen

Agreed. To be reviewed for v2.0

sleeper avatar Mar 27 '13 15:03 sleeper

Is this the same as or related to #44?

iamdustan avatar Aug 07 '13 02:08 iamdustan

I suggest also adding a test cases to usemin:

  • HTML is all on one long line
  • HTML that been minified (but is still structurally correct)
  • HTML with extra whitespace in various odd places
  • HTML with various silly kinds of newlines.

kylecordes avatar Oct 26 '13 18:10 kylecordes

:thumbsup: @kylecordes use cases. The first one is my default use case (jade and auto-minification)

iamdustan avatar Oct 26 '13 19:10 iamdustan

Jade and minification is how we prepare production content also. Workaround:

  1. Make Jade emit pretty printed HTML, which fits usemin's idea of how HTML should look very nicely.
  2. usemin.
  3. Minify the HTML afterward.

kylecordes avatar Oct 26 '13 20:10 kylecordes

Any updates on this?

frapontillo avatar Oct 07 '14 16:10 frapontillo

At the risk of being "that guy", I would like to point whoever might work on this in the direction of the following classic Stack Overflow page. It answers the question of whether a regex is a workable tool to parse HTML.

http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags

short answer: no, regex is not in any way suitable to parse HTML.

kylecordes avatar Oct 07 '14 16:10 kylecordes

Related to #244 (HTML parsing) and #416 (Linefeed detection for replacing blocks)

stephanebachelier avatar Feb 23 '15 23:02 stephanebachelier