       while (match = HEREDOC_INDENT.exec doc)
         attempt = match[1]
         indent = attempt if indent is null or 0 < attempt.length < indent.length
-    doc = doc.replace /\n#{ indent }/g, '\n' if indent
+    doc = doc.replace /// \n #{indent} ///g, '\n' if indent
     return doc if herecomment
     {quote} = options
     doc = doc.replace /^\n/, ''
     doc = doc.replace /\\([\s\S])/g, (m, c) -> if c in ['\n', quote] then c else m
-    doc = doc.replace /#{quote}/g, '\\$&'
+    doc = doc.replace /// #{quote} ///g, '\\$&'
     doc = @escapeLines doc, yes if quote is "'"
     doc
 


  # Matches regular expression literals. Lexing regular expressions is difficult
  # to distinguish from division, so we borrow some basic heuristics from
  # JavaScript and Ruby, borrow slash balancing from `@balancedString`, and
  # borrow interpolation from `@interpolateString`.
  regexToken: ->
    return false if @chunk.charAt(0) isnt '/'
    return @heregexToken match if match = HEREGEX.exec @chunk
    return false unless first = REGEX_START.exec @chunk
    return false if first[1] is ' ' and @tag() not in ['CALL_START', '=']
    return false if include NOT_REGEX, @tag()
    return false unless regex = @balancedString @chunk, [['/', '/']]
    return false unless end = @chunk[regex.length..].match REGEX_END
    flags = end[0]
    if ~regex.indexOf '#{'
      str = regex.slice 1, -1
      @tokens.push ['IDENTIFIER', 'RegExp'], ['CALL_START', '(']
      @interpolateString "\"#{str}\"", regex: yes
      @tokens.push [',', ','], ['STRING', "\"#{flags}\""] if flags
      @tokens.push ['CALL_END', ')']
    else
      @token 'REGEX', regex + flags
    @i += regex.length + flags.length
    true

  # Matches experimental, multiline and extended regular expression literals.

  # interpolations within strings, ad infinitum.
  balancedString: (str, delimited, options) ->
    options or= {}
    levels = []
    i = 0
    slen = str.length
