Takes a valid javascript literal (with the quotes included) and returns a double-quoted
version of that string

@param  {string} literal - origin literal (string with quotes)
@return {string}         - double quote representation of the string
19019
function makeDoubleQuoted( literal ) {
	if ( ! literal || literal.length < 2 ) {
		return undefined;
	}

	// double-quoted string
	if ( literal.charAt( 0 ) === '"' ) {
		return literal.replace( /(\\)/g, '\\$1' );
	}

	// single-quoted string
	if ( literal.charAt( 0 ) === '\'' ) {
		return '"' + literal.substring( 1, literal.length - 1 ).replace( /\\'/g, '\'' ).replace( /(\\|")/g, '\\$1' ) + '"';
	}

	// ES6 string
	if ( literal.charAt( 0 ) === '`' ) {
		return '"' + literal.substring( 1, literal.length - 1 ).replace( /`/g, '\`' ).replace( /(\\|")/g, '\\$1' ) + '"';
	}

	return "";
}
790222
private function quoteLiteral($literal)
    {
        if (is_numeric($literal) && ! is_string($literal)) {
            return (string) $literal;
        } elseif (is_bool($literal)) {
            return $literal ? 'true' : 'false';
        }

        return "'" . str_replace("'", "''", $literal) . "'";
    }
1023075
function makeQuotedStringMatcher ( okQuote ) {
  	return function ( parser ) {
  		var literal = '"';
  		var done = false;
  		var next;

  		while ( !done ) {
  			next = ( parser.matchPattern( stringMiddlePattern ) || parser.matchPattern( escapeSequencePattern ) ||
  				parser.matchString( okQuote ) );
  			if ( next ) {
  				if ( next === ("\"") ) {
  					literal += "\\\"";
  				} else if ( next === ("\\'") ) {
  					literal += "'";
  				} else {
  					literal += next;
  				}
  			} else {
  				next = parser.matchPattern( lineContinuationPattern );
  				if ( next ) {
  					// convert \(newline-like) into a \u escape, which is allowed in JSON
  					literal += '\\u' + ( '000' + next.charCodeAt(1).toString(16) ).slice( -4 );
  				} else {
  					done = true;
  				}
  			}
  		}

  		literal += '"';

  		// use JSON.parse to interpret escapes
  		return JSON.parse( literal );
  	};
  }
376914
def javascript_escape(s, quote_double_quotes=True):
    
    ustring_re = re.compile(u"([\u0080-\uffff])")

    def fix(match):
        return r"\u%04x" % ord(match.group(1))

    if type(s) == str:
        s = s.decode('utf-8')
    elif type(s) != six.text_type:
        raise TypeError(s)
    s = s.replace('\\', '\\\\')
    s = s.replace('\r', '\\r')
    s = s.replace('\n', '\\n')
    s = s.replace('\t', '\\t')
    s = s.replace("'", "\\'")
    if quote_double_quotes:
        s = s.replace('"', '&quot;')
    return str(ustring_re.sub(fix, s))
190036
def literal(x):
    
    xlen = len(x)
    msg = 'Expected: "{}"'.format(x)
    def match_literal(s, grm=None, pos=0):
        if s[:xlen] == x:
            return PegreResult(s[xlen:], x, (pos, pos+xlen))
        raise PegreError(msg, pos)
    return match_literal
904627
static String stringLiteralWithDoubleQuotes(String value, String indent) {
    StringBuilder result = new StringBuilder(value.length() + 2);
    result.append('"');
    for (int i = 0; i < value.length(); i++) {
      char c = value.charAt(i);
      // trivial case: single quote must not be escaped
      if (c == '\'') {
        result.append("'");
        continue;
      }
      // trivial case: double quotes must be escaped
      if (c == '\"') {
        result.append("\\\"");
        continue;
      }
      // default case: just let character literal do its work
      result.append(characterLiteralWithoutSingleQuotes(c));
      // need to append indent after linefeed?
      if (c == '\n' && i + 1 < value.length()) {
        result.append("\"\n").append(indent).append(indent).append("+ \"");
      }
    }
    result.append('"');
    return result.toString();
  }
765356
static public function escapeLiteral(string $literal): string {
        self::initSerializer();
        $value = self::$serializer->serialiseValue(new Literal($literal));
        return $value;
    }
650957
function qstring(val) {
  var str = String(val)

  // no need to quote tokens
  if (tokenRegExp.test(str)) {
    return str
  }

  if (str.length > 0 && !textRegExp.test(str)) {
    throw new TypeError('invalid parameter value')
  }

  return '"' + str.replace(quoteRegExp, '\\$1') + '"'
}
1222753
function unquote(str) {
		var ch = str.charAt(0);
		if (ch == '"' || ch == "'") {
			str = str.substr(1);
			var last = str.charAt(str.length - 1);
			if (last === ch) {
				str = str.substr(0, str.length - 1);
			}
		}

		return str;
	}
1254885
function() {
        var str = "",
          quote = exprI(index++),
          closed = false,
          ch;

        while (index < length) {
          ch = exprI(index++);
          if (ch === quote) {
            closed = true;
            break;
          } else if (ch === "\\") {
            // Check for all of the common escape codes
            ch = exprI(index++);
            switch (ch) {
              case "n":
                str += "\n";
                break;
              case "r":
                str += "\r";
                break;
              case "t":
                str += "\t";
                break;
              case "b":
                str += "\b";
                break;
              case "f":
                str += "\f";
                break;
              case "v":
                str += "\x0B";
                break;
              default:
                str += "\\" + ch;
            }
          } else {
            str += ch;
          }
        }

        if (!closed) {
          throwError('Unclosed quote after "' + str + '"', index);
        }

        return {
          type: code.LITERAL,
          value: str,
          raw: quote + str + quote
        };
      }
648043
function ( str ) {
            if ( !str ) return '';
    
            var _this = this,
                regAry = $B.object.toArray( _this.HTML_CHARACTERS, 'key' ),
                reg = new RegExp( '(' + regAry.join('|') + '|&#[0-9]{1,5};' + ')', 'g' );
    
            return str.replace( reg, function ( match, capture ) {
                return ( capture in _this.HTML_CHARACTERS ) ? _this.HTML_CHARACTERS[capture] : String.fromCharCode(parseInt(capture.substr(2), 10));
            });
        }
1263168
def literalize_string(content, is_unicode=False):
    
    '''

    quote_mark = "'"
    if "'" in content:
        quote_mark = '"'
        if '"' in content:
            quote_mark = "'"
            content = content.replace(r"'", r"\'")

    if '\n' in content:
        quote_mark *= 3

    return 'u'[not is_unicode:]+quote_mark+content+quote_mark
725674
function getQuoted (string) {
  if (!string.match(/"/g)) {
    return '"' + string + '"'
  }
  stringify = requireOnce('json-stringify-safe')
  return stringify(String(string))
}
46823
def _encode_var(cls, var):
        

        if isinstance(var, str):
            if any(_ in var for _ in cls.requires_quotes):
                # NOTE: quoted strings should just use '"' according to the spec
                return '"' + var.replace('"', '\\"') + '"'
            return var
        else:
            return str(var)
413620
function wrap (str, quote) {
    if (this.typecheck) t.typecheck('wrap', [str, quote]);
    if (!quote||quote=="'") return "'"+str+"'";
    if (quote == '"') return '"'+str+'"';
    return quote+str+quote;
}
1279245
def string_literal(string)
      Literal.new(Sass::Script::Value::String.new(string, :string))
    end
407989
def extract_literal_or_array_of_literals(s)
      literals = []
      braces_stack = []
      acc = []
      consume_literal = proc do
        acc_str = acc.join
        if acc_str =~ literal_re
          literals << strip_literal(acc_str)
          acc = []
        else
          return nil
        end
      end
      s.each_char.with_index do |c, i|
        if c == '['
          return nil unless braces_stack.empty?
          braces_stack.push(i)
        elsif c == ']'
          break
        elsif c == ','
          consume_literal.call
          break if braces_stack.empty?
        elsif c =~ VALID_KEY_CHARS || /['":]/ =~ c
          acc << c
        elsif c != ' '
          return nil
        end
      end
      consume_literal.call unless acc.empty?
      literals
    end