r5370: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 21 Jul 2003 16:20:47 +0000 (16:20 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 21 Jul 2003 16:20:47 +0000 (16:20 +0000)
doc/readme.lml
htmlgen.lisp

index 5be2b43cdc70e03c7409c5028be408bdfa57ede2..1c9fa4348d21799935b8f0bc3ae142682d61ecbb 100644 (file)
@@ -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
index 6a3650d69c84ca434533bcf6ab7c08ae179ed88a..ade02768dcec83f390dd072151da943b6fa236d7 100644 (file)
@@ -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
 
 (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