yeoman / grunt-usemin

[UNMAINTAINED] Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views)
BSD 2-Clause "Simplified" License
1.22k stars 339 forks source link

Insufficient linefeed detection #88

Open mlegenhausen opened 11 years ago

mlegenhausen commented 11 years ago

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.

sleeper commented 11 years ago

Agreed. To be reviewed for v2.0

iamdustan commented 11 years ago

Is this the same as or related to #44?

kylecordes commented 11 years ago

I suggest also adding a test cases to usemin:

iamdustan commented 11 years ago

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

kylecordes commented 11 years ago

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.
frapontillo commented 10 years ago

Any updates on this?

kylecordes commented 10 years ago

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.

stephanebachelier commented 9 years ago

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