jashkenas/coffee-script — pull request #3214 by marchaefner (2013-10-22 16:24:26+00:00)
Title: Escaped whitespace and slashes in Heregexes

Escaped whitespace and slashes in Heregexes

* Resolves #3059: Don't remove escaped whitespace.
* Fixes #2238: Prevent escaping slashes that are already escaped.
* Fix detection of end of heregex with escaped slashes.

Escaped whitespaces and slashes in Heregexes

It's a bit ugly but it implements #3059 and fixes #2238.
(Google and MSDN say this should work with all relevant JS engines.)

This PR also fixes the `HEREGEX` regex, so this is a thing now:

threeSlashes = /// \/// ///

#### Notes

* Linebreaks are excluded from the escapable characters to avoid any confusion. (A backslash at the end of a line usually denotes a continuation on the next line but would mean the exact opposite here.)

* Whitespace escaping introduces a potential pitfall:

/// this\ #is not a comment ///

It would be possible to treat this as a comment but that would be somewhat inconsistent and break other constructs (e.g. `/// ^[\ #].* ///`).