aboutsummaryrefslogtreecommitdiff
path: root/skr/letter.skr
blob: 17a005895662a619f59aaeae4683bfaeecc24029 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
;*=====================================================================*/
;*    serrano/prgm/project/skribe/skr/letter.skr                       */
;*    -------------------------------------------------------------    */
;*    Author      :  Manuel Serrano                                    */
;*    Creation    :  Fri Oct  3 12:22:13 2003                          */
;*    Last change :  Thu Sep 23 20:00:42 2004 (serrano)                */
;*    Copyright   :  2003-04 Manuel Serrano                            */
;*    -------------------------------------------------------------    */
;*    Skribe style for letters                                         */
;*=====================================================================*/

;*---------------------------------------------------------------------*/
;*    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"))