r5163: *** empty log message ***
[lml.git] / 2 / base.lisp
diff --git a/2/base.lisp b/2/base.lisp
new file mode 100644 (file)
index 0000000..944df66
--- /dev/null
@@ -0,0 +1,71 @@
+;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name:          base.lisp
+;;;; Purpose:       Lisp Markup Language functions
+;;;; Programmer:    Kevin M. Rosenberg
+;;;; Date Started:  Aug 2002
+;;;;
+;;;; $Id: base.lisp,v 1.1 2003/06/20 04:12:29 kevin Exp $
+;;;;
+;;;; This file, part of LML, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;;
+;;;; 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*))))
+
+(defun lml-princ (s)
+  (princ s *html-stream*))
+
+(defun lml-print (s)
+  (format *html-stream* "~A~%" s))
+
+(defun lml-write-char (char)
+  (write-char char *html-stream*))
+
+(defun lml-write-string (str)
+  (write-string str *html-stream*))
+
+(defun lml-print-date (date)
+  (lml-write-string (date-string date)))
+
+(defmacro xhtml-prologue ()
+  `(progn
+     (lml-write-string (xml-prologue-string))
+     (lml-write-char #\newline)
+     (lml-write-string (xhtml-prologue-string))
+     (lml-write-char #\newline)))
+
+(defmacro print-page (title &body body)
+  `(html
+    (:head
+     (:title (:princ ,title)))
+    (:body ,@body)))
+
+(defmacro page (out-file &body body)
+  `(with-open-file (*html-stream*
+                   (lml-file-name ,out-file :output)
+                   :direction :output
+                   :if-exists :supersede)
+     (xhtml-prologue)
+     (html
+      ((:html :xmlns "http://www.w3.org/1999/xhtml")
+       ,@body))))
+
+