From: Kevin M. Rosenberg Date: Mon, 21 Jul 2003 16:20:47 +0000 (+0000) Subject: r5370: *** empty log message *** X-Git-Tag: v1.6.2~36 X-Git-Url: http://git.kpe.io/?p=lml2.git;a=commitdiff_plain;h=6ec49bfd3b5c1d91421258e9452ce38f99f49681 r5370: *** empty log message *** --- diff --git a/doc/readme.lml b/doc/readme.lml index 5be2b43..1c9fa43 100644 --- a/doc/readme.lml +++ b/doc/readme.lml @@ -45,7 +45,8 @@ (:li "Removal of the if* macro from the htmlgen.lisp source code") (:li "Incorporation of LML's standard site macro and other helper functions.") (:li "Addition of special attribute tags (:if :when :optional :format :format") - (:li "Automatic quoting of attribute values for non-string values")) + (:li "Automatic quoting of attribute values for non-string values") + (:li "Post macroexpansion code walker to collape sequential write-string calls")) (:h2 "Installation") (:p 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