X-Git-Url: http://git.kpe.io/?p=lml2.git;a=blobdiff_plain;f=base.lisp;h=407429f6a244ef863f8defc5f7f1ed0067874f99;hp=517af2cc834fcf336e2db5be3d96930d43d56021;hb=cfdabc1cd9728054e3a0267e4b59d8b1bfa28a81;hpb=7210bdeef3b698f12f3b6ec5a752b9e9c6ab5068 diff --git a/base.lisp b/base.lisp index 517af2c..407429f 100644 --- a/base.lisp +++ b/base.lisp @@ -20,8 +20,8 @@ (defun lml-format (str &rest args) (when (streamp *html-stream*) (if args - (apply #'format *html-stream* str args) - (write-string str *html-stream*)))) + (apply #'format *html-stream* str args) + (write-string str *html-stream*)))) (defun lml-princ (s) (princ s *html-stream*)) @@ -38,20 +38,37 @@ (defun lml-print-date (date) (lml-write-string (date-string date))) -(defun dtd-prologue (&optional (format :xhtml11) &key entities) - (case format +(defun xml-header-stream (stream &key (version "1.0") (standalone :unspecified) + (encoding :unspecified)) + (format stream "" + 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) (encoding :iso-8859-1) &key entities) + (ecase format ((:xhtml :xhtml11 :xhtml10-strict :xhtml10-transitional :xhtml10-frameset :xml) - (lml-write-string +xml-prologue-string+) + (lml-write-string +xml-prologue-begin+) + (ecase encoding + (:iso-8859-1 + (lml-write-string "iso-8859-1")) + (:utf-8 + (lml-write-string "UTF-8"))) + (lml-write-string +xml-prologue-end+) (lml-write-char #\newline) (case format ((:xhtml11 :xhtml) - (lml-write-string +xhtml11-dtd-string+)) + (lml-write-string +xhtml11-dtd-string+)) (:xhtml10-strict - (lml-write-string +xhtml10-strict-dtd-string+)) + (lml-write-string +xhtml10-strict-dtd-string+)) (:xhtml10-transitional - (lml-write-string +xhtml10-transitional-dtd-string+)) + (lml-write-string +xhtml10-transitional-dtd-string+)) (:xhtml10-frameset - (lml-write-string +xhtml10-frameset-dtd-string+))) + (lml-write-string +xhtml10-frameset-dtd-string+))) (when entities (lml-write-char #\space) (lml-write-char #\[) @@ -66,16 +83,16 @@ (defmacro html-file-page ((out-file &key (format :xhtml11)) - &body body) + &body body) `(with-open-file (*html-stream* - (lml-file-name ,out-file :output) - :direction :output - :if-exists :supersede) + (lml-file-name ',out-file :output) + :direction :output + :if-exists :supersede) (dtd-prologue ,format) (html ((:html :xmlns "http://www.w3.org/1999/xhtml") ,@body)))) - + (defmacro alink (url desc) `(html