How to normalize html before usemin

72 views Asked by At

Some of our devs have mac and some have PC - and there seems to be an issue with usemin when trying to run it - as whitespaces (CRLF and LF) are interchanging and messing it up.

Is there some kind of plugin or regex I can use in my gulpfile to fix them before running usemin?

1

There are 1 answers

0
shA.t On

If you can use regex, you can mention these:

  • \r matches a carriage return (ASCII 13) or CR
  • \n matches a line-feed (newline) character (ASCII 10) or LF

So you can find all CRLF by a simple regex like /\r\n/g and LF by /\n/g and replace them by something like \r\n.

To replace both of those types or also other combinations like CR or LFCR use this regex:

/[\r\n]/g

For more (by adding form feed character):

  • \f matches a form-feed character (ASCII 12)

    /[\f\r\n]/g