(document.write
(ps-html ((:a :href "#"
:onclick (ps-inline (transport))) "link")))
-=> document.write('<A HREF=\"#\" ONCLICK=\"' + ('javascript:' + 'transport()') + '\">link</A>')
+=> document.write('<A HREF=\"#\" ONCLICK=\"' + ('javascript:' + 'transport' + '(' + ')') + '\">link</A>')
;;; Forms may be used in attribute lists to conditionally generate
;;; the next attribute. In this example the textarea is sometimes disabled.
-(in-package :parenscript)
+(in-package "PARENSCRIPT")
(defvar *ps-print-pretty* t)
(defvar *indent-num-spaces* 4)
(defmethod parenscript-print (form)
(let ((*indent-level* 0)
(*print-accumulator* ()))
- (if (and (listp form) (eql 'js-block (car form))) ; ignore top-level block
- (loop for (statement . remaining) on (third form) do
- (ps-print statement) (psw ";") (when remaining (psw #\Newline)))
- (ps-print form))
- (reduce (lambda (acc next-token)
- (if (and (stringp next-token)
- (stringp (car (last acc))))
- (append (butlast acc) (list (concatenate 'string (car (last acc)) next-token)))
- (append acc (list next-token))))
- (cons () (reverse *print-accumulator*)))))
+ (if (and (listp form) (eql 'js-block (car form))) ; ignore top-level block
+ (loop for (statement . remaining) on (third form) do
+ (ps-print statement) (psw ";") (when remaining (psw #\Newline)))
+ (ps-print form))
+ (nreverse *print-accumulator*)))
(defun psw (obj)
(push (if (characterp obj) (string obj) obj) *print-accumulator*))
(defun newline-and-indent ()
(if *ps-print-pretty*
- (when (and (stringp (car *print-accumulator*))
- (not (char= #\Newline (char (car *print-accumulator*) (1- (length (car *print-accumulator*))))))
- (psw #\Newline))
- (loop repeat (* *indent-level* *indent-num-spaces*) do (psw #\Space)))
+ (progn (psw #\Newline)
+ (loop repeat (* *indent-level* *indent-num-spaces*) do (psw #\Space)))
(psw #\Space)))
(defparameter *js-lisp-escaped-chars*
:onclick (ps-inline (transport)))
img))
img))
- "document.write(LINKORNOT == 1 ? '<A HREF=\"#\" ONCLICK=\"' + ('javascript:' + 'transport()') + '\">' + img + '</A>' : img)")
+ "document.write(LINKORNOT == 1 ? '<A HREF=\"#\" ONCLICK=\"' + ('javascript:' + 'transport' + '(' + ')') + '\">' + img + '</A>' : img)")
(test-ps-js negate-number-literal ;; ok, this was broken and fixed before, but no one bothered to add the test!
(- 1)
(document.write
(ps-html ((:a :href "#"
:onclick (ps-inline (transport))) "link")))
- "document.write('<A HREF=\"#\" ONCLICK=\"' + ('javascript:' + 'transport()') + '\">link</A>')")
+ "document.write('<A HREF=\"#\" ONCLICK=\"' + ('javascript:' + 'transport' + '(' + ')') + '\">link</A>')")
(test-ps-js the-html-generator-4
(let* ((disabled nil)