X-Git-Url: http://git.kpe.io/?p=lml2.git;a=blobdiff_plain;f=htmlgen.lisp;h=ade02768dcec83f390dd072151da943b6fa236d7;hp=6a3650d69c84ca434533bcf6ab7c08ae179ed88a;hb=6ec49bfd3b5c1d91421258e9452ce38f99f49681;hpb=94bfd48aa3a7f2e358bc873f992796030319acd2 diff --git a/htmlgen.lisp b/htmlgen.lisp index 6a3650d..ade0276 100644 --- a/htmlgen.lisp +++ b/htmlgen.lisp @@ -1,6 +1,6 @@ ;; -*- mode: common-lisp; package: lml2 -*- ;; -;; $Id: htmlgen.lisp,v 1.16 2003/07/15 21:49:36 kevin Exp $ +;; $Id: htmlgen.lisp,v 1.17 2003/07/21 16:20:47 kevin Exp $ ;; ;; copyright (c) 1986-2000 Franz Inc, Berkeley, CA ;; copyright (c) 2003 Kevin Rosenberg @@ -45,7 +45,46 @@ (defmacro html (&rest forms &environment env) ;; just emit html to the current stream - (process-html-forms forms env)) + ;;(process-html-forms forms env) + + (post-process-html-forms + (process-html-forms forms env)) + ) + +(defun post-process-html-forms (input-forms) + "KMR: Walk through forms and combining write-strings" + (let (res strs last-stream) + (flet ((flush-strings () + (when strs + (push `(write-string ,strs ,last-stream) res) + (setq strs nil) + (setq last-stream nil)))) + (do* ((forms input-forms (cdr forms)) + (form (car forms) (car forms))) + ((null forms) + (flush-strings) + (nreverse res)) + (cond + ((atom form) + (flush-strings) + (push form res)) + (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))))))))) + (defmacro html-out-stream-check (stream) ;; ensure that a real stream is passed to this function