r8226: update to new dtd writing functions
[lml2.git] / base.lisp
index 01b3c7666e6b0565b60fd635654a083aef4b9ef3..ecfd2792acf2cae51df83376542d717e0ceb7ebb 100644 (file)
--- a/base.lisp
+++ b/base.lisp
@@ -7,28 +7,21 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Aug 2002
 ;;;;
-;;;; $Id: base.lisp,v 1.6 2003/06/29 16:21:09 kevin Exp $
+;;;; $Id$
 ;;;;
-;;;; This file, part of LML, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;; This file, part of LML2, is Copyright (c) 2000-2003 by Kevin Rosenberg.
+;;;; Rights of modification and redistribution are in the LICENSE file.
 ;;;;
-;;;; LML users are granted the rights to distribute and use this software
-;;;; as governed by the terms of the GNU General Public License v2
-;;;; (http://www.gnu.org/licenses/gpl.html)
 ;;;; *************************************************************************
 
 (in-package #:lml2)
 
 
-(defun reset-indent ()
-  (setq *indent* 0))
-
 (defun lml-format (str &rest args)
   (when (streamp *html-stream*)
-    (when *print-spaces* (indent-spaces *indent* *html-stream*))
     (if args
        (apply #'format *html-stream* str args)
-      (write-string str *html-stream*))
-    (when *print-spaces* (write-char #\newline *html-stream*))))
+       (write-string str *html-stream*))))
 
 (defun lml-princ (s)
   (princ s *html-stream*))
 (defun lml-print-date (date)
   (lml-write-string (date-string date)))
 
-(defun dtd-prologue (&optional (format :xhtml11))
+(defun xml-header-stream (stream &key (version "1.0") (standalone :unspecified)
+                  (encoding :unspecified))
+  (format stream "<?xml version=\"~A\"~A~A ?>"
+         version
+         (if (eq standalone :unspecified)
+             ""
+             (format nil " standalone=\"~A\"" standalone))
+         (if (eq encoding :unspecified)
+             ""
+             (format nil " encoding=\"~A\"" encoding))))
+         
+(defun dtd-prologue (&optional (format :xhtml11) &key entities)
   (case format
     ((:xhtml :xhtml11 :xhtml10-strict :xhtml10-transitional :xhtml10-frameset :xml)
      (lml-write-string +xml-prologue-string+)
-     (lml-write-char #\newline)))
-  (case format
-    ((:xhtml11 :xhtml)
-     (lml-write-string +xhtml11-dtd-string+))
-    (:xhtml10-strict
-     (lml-write-string +xhtml10-strict-dtd-string+))
-    (:xhtml10-transitional
-     (lml-write-string +xhtml10-transitional-dtd-string+))
-    (:xhtml10-frameset
-     (lml-write-string +xhtml10-frameset-dtd-string+))
+     (lml-write-char #\newline)
+     (case format
+       ((:xhtml11 :xhtml)
+       (lml-write-string +xhtml11-dtd-string+))
+       (:xhtml10-strict
+       (lml-write-string +xhtml10-strict-dtd-string+))
+       (:xhtml10-transitional
+       (lml-write-string +xhtml10-transitional-dtd-string+))
+       (:xhtml10-frameset
+       (lml-write-string +xhtml10-frameset-dtd-string+)))
+     (when entities
+       (lml-write-char #\space)
+       (lml-write-char #\[)
+       (lml-write-char #\Newline)
+       (lml-write-string entities)
+       (lml-write-char #\Newline)
+       (lml-write-char #\]))
+     (lml-write-char #\>))
     (:html
      (lml-write-string +html4-dtd-string+)))
   (lml-write-char #\newline))
@@ -74,7 +86,6 @@
      (html
       ((:html :xmlns "http://www.w3.org/1999/xhtml")
        ,@body))))
-
                     
 
 (defmacro alink (url desc)