summary refs log tree commit diff
path: root/src/guile/skribilo/package/letter.scm
diff options
context:
space:
mode:
Diffstat (limited to 'src/guile/skribilo/package/letter.scm')
-rw-r--r--src/guile/skribilo/package/letter.scm157
1 files changed, 157 insertions, 0 deletions
diff --git a/src/guile/skribilo/package/letter.scm b/src/guile/skribilo/package/letter.scm
new file mode 100644
index 0000000..91d45be
--- /dev/null
+++ b/src/guile/skribilo/package/letter.scm
@@ -0,0 +1,157 @@
+;;; letter.scm  --  Skribe style for letters
+;;;
+;;; Copyright 2003, 2004  Manuel Serrano
+;;;
+;;;
+;;; This program is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 2 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program; if not, write to the Free Software
+;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+;;; USA.
+
+(define-skribe-module (skribilo package letter))
+
+;*---------------------------------------------------------------------*/
+;*    document                                                         */
+;*---------------------------------------------------------------------*/
+(define %letter-document document)
+
+(define-markup (document #!rest opt 
+		  #!key (ident #f) (class "letter") 
+		  where date author
+		  &skribe-eval-location)
+   (let* ((ubody (the-body opt))
+	  (body (list (new markup
+			 (markup '&letter-where)
+			 (loc &skribe-eval-location)
+			 (options `((:where ,where)
+				    (:date ,date)
+				    (:author ,author))))
+		      ubody)))
+      (apply %letter-document
+	     :author #f :title #f 
+	     (append (apply append 
+			    (the-options opt :where :date :author :title))
+		     body))))
+
+;*---------------------------------------------------------------------*/
+;*    LaTeX configuration                                              */
+;*---------------------------------------------------------------------*/
+(let ((le (find-engine 'latex)))
+   (engine-custom-set! le 'documentclass "\\documentclass[12pt]{letter}\n")
+   (engine-custom-set! le 'maketitle #f)
+   ;; &letter-where
+   (markup-writer '&letter-where le
+      :before "\\begin{raggedright}\n"
+      :action (lambda (n e)
+		 (let* ((w (markup-option n :where))
+			(d (markup-option n :date))
+			(a (markup-option n :author))
+			(hd (if (and w d)
+				(list w ", " d)
+				(or w d)))
+			(ne (copy-engine 'author e)))
+		    ;; author
+		    (markup-writer 'author ne
+		       :options '(:name :title :affiliation :email :url :address :phone :photo :align :header)
+		       :action (lambda (n e)
+				  (let ((name (markup-option n :name))
+					(title (markup-option n :title))
+					(affiliation (markup-option n :affiliation))
+					(email (markup-option n :email))
+					(url (markup-option n :url))
+					(address (markup-option n :address))
+					(phone (markup-option n :phone)))
+				     (define (row n)
+					(output n e)
+					(when hd
+					   (display "\\hfill ")
+					   (output hd e)
+					   (set! hd #f))
+					(display "\\\\\n"))
+				     ;; name
+				     (if name (row name))
+				     ;; title
+				     (if title (row title))
+				     ;; affiliation
+				     (if affiliation (row affiliation))
+				     ;; address
+				     (if (pair? address)
+					 (for-each row address))
+				     ;; telephone
+				     (if phone (row phone))
+				     ;; email
+				     (if email (row email))
+				     ;; url
+				     (if url (row url)))))
+		    ;; emit the author
+		    (if a 
+			(output a ne)
+			(output hd e))))
+      :after "\\end{raggedright}\n\\vspace{1cm}\n\n"))
+		 
+;*---------------------------------------------------------------------*/
+;*    HTML configuration                                               */
+;*---------------------------------------------------------------------*/
+(let ((he (find-engine 'html)))
+   ;; &letter-where
+   (markup-writer '&letter-where he
+      :before "<table width=\"100%\">\n"
+      :action (lambda (n e)
+		 (let* ((w (markup-option n :where))
+			(d (markup-option n :date))
+			(a (markup-option n :author))
+			(hd (if (and w d)
+				(list w ", " d)
+				(or w d)))
+			(ne (copy-engine 'author e)))
+		    ;; author
+		    (markup-writer 'author ne
+		       :options '(:name :title :affiliation :email :url :address :phone :photo :align :header)
+		       :action (lambda (n e)
+				  (let ((name (markup-option n :name))
+					(title (markup-option n :title))
+					(affiliation (markup-option n :affiliation))
+					(email (markup-option n :email))
+					(url (markup-option n :url))
+					(address (markup-option n :address))
+					(phone (markup-option n :phone)))
+				     (define (row n)
+					(display "<tr><td align='left'>")
+					(output n e)
+					(when hd
+					   (display "</td><td align='right'>")
+					   (output hd e)
+					   (set! hd #f))
+					(display "</td></tr>\n"))
+				     ;; name
+				     (if name (row name))
+				     ;; title
+				     (if title (row title))
+				     ;; affiliation
+				     (if affiliation (row affiliation))
+				     ;; address
+				     (if (pair? address)
+					 (for-each row address))
+				     ;; telephone
+				     (if phone (row phone))
+				     ;; email
+				     (if email (row email))
+				     ;; url
+				     (if url (row url)))))
+		    ;; emit the author
+		    (if a 
+			(output a ne)
+			(output hd e))))
+      :after "</table>\n<hr>\n\n"))
+		 
+