X-Git-Url: http://git.kpe.io/?p=lml2.git;a=blobdiff_plain;f=htmlgen.lisp;h=97287b2a4062a1da57c4128cdc02d52e1e6b1f09;hp=ade02768dcec83f390dd072151da943b6fa236d7;hb=710507af21b320d11151423b73b73f1d3fdfebee;hpb=6ec49bfd3b5c1d91421258e9452ce38f99f49681 diff --git a/htmlgen.lisp b/htmlgen.lisp index ade0276..97287b2 100644 --- a/htmlgen.lisp +++ b/htmlgen.lisp @@ -1,6 +1,6 @@ ;; -*- mode: common-lisp; package: lml2 -*- ;; -;; $Id: htmlgen.lisp,v 1.17 2003/07/21 16:20:47 kevin Exp $ +;; $Id$ ;; ;; copyright (c) 1986-2000 Franz Inc, Berkeley, CA ;; copyright (c) 2003 Kevin Rosenberg @@ -44,15 +44,11 @@ ) (defmacro html (&rest forms &environment env) - ;; just emit html to the current stream - ;;(process-html-forms forms env) - (post-process-html-forms - (process-html-forms forms env)) - ) + (process-html-forms forms env))) (defun post-process-html-forms (input-forms) - "KMR: Walk through forms and combining write-strings" + "KMR: Walk through forms and combine write-strings" (let (res strs last-stream) (flet ((flush-strings () (when strs @@ -68,22 +64,21 @@ ((atom form) (flush-strings) (push form res)) + ((and (eq (car form) 'cl:write-string) + (stringp (cadr form))) + (if strs + (if (eq last-stream (third form)) + (setq strs (concatenate 'string strs (second form))) + (progn + (flush-strings) + (setq strs (second form)) + (setq last-stream (third form)))) + (progn + (setq strs (second form)) + (setq last-stream (third form))))) (t - (cond - ((eq (car form) 'cl:write-string) - (if strs - (if (eq last-stream (third form)) - (setq strs (concatenate 'string strs (second form))) - (progn - (flush-strings) - (setq strs (second form)) - (setq last-stream (third form)))) - (progn - (setq strs (second form)) - (setq last-stream (third form))))) - (t - (flush-strings) - (push form res))))))))) + (flush-strings) + (push (post-process-html-forms form) res))))))) (defmacro html-out-stream-check (stream) @@ -818,19 +813,21 @@ ;; must use syntax (declare (ignore ent args argsp)) `(progn + #+ignore (write-string "" *html-stream*)))) (named-function html-comment-print-function (lambda (ent cmd args form subst unknown stream) (declare (ignore ent cmd args subst unknown)) - (format stream "" + (format stream "" (cadr form))))) (def-special-html :nbsp @@ -889,9 +886,11 @@ (named-function html-write-string-function (lambda (ent args argsp body) (declare (ignore ent args argsp)) - `(progn ,@(mapcar #'(lambda (bod) - `(write-string ,bod *html-stream*)) - body)))) + (if (= (length body) 1) + `(write-string ,(car body) *html-stream*) + `(progn ,@(mapcar #'(lambda (bod) + `(write-string ,bod *html-stream*)) + body))))) (named-function html-write-string-print-function (lambda (ent cmd args form subst unknown stream) @@ -917,26 +916,5 @@ (write-char (cadr form) stream) (error ":write-char must be given an argument"))))) -;; fast formatter -(def-special-html :fformat - (named-function html-write-char-function - (lambda (ent args argsp body) - (declare (ignore ent args argsp)) - `(progn ,@(mapcar #'(lambda (bod) - `(progn - (format *html-stream* " ~(~A~)=\"" (car ,bod)) - (apply #'format *html-stream* (cdr ,bod)) - (write-char #\" *html-stream*))) - body)))) - - (named-function html-write-char-print-function - (lambda (ent cmd args form subst unknown stream) - (declare (ignore args ent unknown subst)) - (assert (eql 2 (length form))) - (if (eq cmd :full) - (progn - (format stream " ~(~A~)=\"" (car form)) - (apply #'format stream (cdr form)) - (write-char #\" stream)) - (error ":fformat must be given an argument"))))) +