From: Marco Baringer Date: Wed, 5 Oct 2005 09:09:42 +0000 (+0000) Subject: Need to escape #\' in javascript strings X-Git-Tag: parenscript-20070720~107 X-Git-Url: https://git.hcoop.net/clinton/parenscript.git/commitdiff_plain/8e8162b6bd3c5bd319e5f021aa4c797bdf219b4e Need to escape #\' in javascript strings --- diff --git a/js.lisp b/js.lisp index e12be54..2fb039c 100644 --- a/js.lisp +++ b/js.lisp @@ -383,7 +383,15 @@ this macro." (defmethod js-to-strings ((string string-literal) start-pos) (declare (ignore start-pos)) - (list (format nil "'~A'" (value string)))) + (list (with-output-to-string (escaped) + (loop + initially (write-char #\' escaped) + for char across (value string) + if (char= #\' char) + do (write-string "\\'" escaped) + else + do (write-char char escaped) + finally (write-char #\' escaped))))) ;;; number literals