Source

xemacsweb / release-mail-to-html.el

Full commit
adriana 836c779 





























adriana 22a11a4 
adriana 2f9f635 

adriana 3d21a8f 
adriana 2f9f635 






adriana 22a11a4 









adriana 03b1b09 
adriana 3d21a8f 

adriana 22a11a4 




adriana 2f9f635 



















adriana 22a11a4 
adriana 3d21a8f 
adriana 22a11a4 





adriana 9d4b583 










adriana 2f9f635 
adriana 3d21a8f 




adriana 22a11a4 




adriana 2f9f635 
adrian dba021c 
adriana 22a11a4 
adrian dba021c 


adriana 22a11a4 




adrian 0b9d031 










adriana 2f9f635 
adrian 0b9d031 
adriana 22a11a4 
adrian 0b9d031 
adriana 58006a7 

adriana 22a11a4 





adrian 702983f 


adriana 22a11a4 





adrian 702983f 


adriana 22a11a4 


adriana 2f9f635 


adriana a138df9 
adriana 3d21a8f 
adriana 58006a7 



adriana 2f9f635 



adriana 22a11a4 

adrian 0b9d031 



adriana 3d21a8f 


adrian 0b9d031 





















adriana 22a11a4 



adriana 2f9f635 

adrian 0b9d031 














adriana 22a11a4 
adrian 0b9d031 
adriana 22a11a4 
adriana 2f9f635 
adrian 0b9d031 



adriana 2f9f635 
adrian 0b9d031 
adrian dba021c 
adriana 2f9f635 
adrian 0b9d031 


adriana 2f9f635 

adrian dba021c 


adrian 0b9d031 


adrian dba021c 

adrian 0b9d031 

adrian dba021c 










adrian 0b9d031 
adrian dba021c 





adrian 0b9d031 





















adriana 2f9f635 
adrian 702983f 






















adriana 2f9f635 















adriana 3d21a8f 

adriana 9d4b583 












adriana 3d21a8f 











adriana 2f9f635 




adriana 3d21a8f 


adriana 2f9f635 







adrian 0b9d031 
adriana 3d21a8f 


adriana 2f9f635 



adriana 3d21a8f 


adrian dba021c 
adriana 2f9f635 
adriana 22a11a4 
adriana 3d21a8f 


adriana 2f9f635 
adriana 22a11a4 
mrb c70eafb 
adriana 22a11a4 

adrian dba021c 

adriana 3d21a8f 
adriana 22a11a4 
adriana 3d21a8f 
scop 215fecf 
adrian dba021c 
adriana 3d21a8f 



adrian 0b9d031 
adriana 3d21a8f 
adrian 0b9d031 




adriana 3d21a8f 

adrian 0b9d031 
adrian dba021c 
adriana 3d21a8f 


adrian 0b9d031 
adriana 3d21a8f 
adrian 0b9d031 

















adriana 3d21a8f 
adrian dba021c 

adriana 3d21a8f 


adrian 0b9d031 
adrian dba021c 
adriana 3d21a8f 



adrian 0b9d031 
adriana 3d21a8f 




adrian 0b9d031 
adriana 3d21a8f 



adrian 0b9d031 
adriana 3d21a8f 




adrian 0b9d031 
adriana 3d21a8f 






scop 215fecf 
adrian dba021c 
adriana 3d21a8f 













































adriana 22a11a4 
adriana 3d21a8f 
adriana 22a11a4 





adriana 3d21a8f 
adrian 4e60881 

























adriana 3d21a8f 
adriana 836c779 
adriana 2f9f635 
adriana 3d21a8f 
adriana 2f9f635 




















adriana 3d21a8f 
adriana 2f9f635 








adriana 3d21a8f 
adriana 2f9f635 










adriana 3d21a8f 



adrian 0b9d031 
adriana 3d21a8f 






scop 215fecf 
adriana 3d21a8f 
adrian 0b9d031 
adriana 3d21a8f 

adriana 2f9f635 
adriana 836c779 
  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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
;;; release-mail-to-html.el --- Convert release mail to HTML for XEmacs
;;;
;;; $Id$
;;;
;;; Copyright (C) 2000 Adrian Aichner

;; Author: Adrian Aichner <adrian@xemacs.org>
;; Maintainer: XEmacs Development Team <xemacs-beta@xemacs.org>
;; Date: $Date$
;; Version: $Revision$
;; Keywords: xemacsweb

;; This file is part of XEmacs.

;; XEmacs 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, or (at your option)
;; any later version.

;; XEmacs 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 XEmacs; see the file COPYING.  If not, write to the Free
;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
;; 02111-1307, USA.

;;; Synched up with: Not in FSF.

(condition-case nil
    (progn
      ;; Pull in required modules.
      ;; (require 'regexp-opt)
      (require 'psgml)
      (require 'psgml-parse)            ; for sgml-element-context-string
      (require 'psgml-html))            ; for html-quote-region
  (t
   (error "please install/upgrade PSGML!")))


(provide 'release-mail-to-html)

(defgroup release-mail-to-html nil
  "Generate HTML content file for XEmacs website from release
announcement mails as formatted by XEmacs Release Engineer."
  :load 'release-mail-to-html
  :group nil)

(defcustom release-mail-to-html-preformatted-regexp
  "<pre xml:space=\"preserve\">\\(.*?\\(\n.*?\\)*\\)</pre>"
  "REGEXP matching preformatted HTML in the MAJOR.MINOR.PATCH.content
buffer generated from XEmacs release mail."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defcustom release-mail-headers-to-keep-regexp
  (format "^\\(%s\\)"
          (mapconcat
           'identity
           (list
            "To:"
            "Subject:"
            "From:"
            "Organization:"
            "Date:"
            "Message-ID:"
            "Reply-To:"
            )
           "\\|"))
  "REGEXP matching mail headers to keep from release notice."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defcustom release-mail-to-html-header-regexp
  "^\\(\\(-\\|\\sw\\)+\\)[ \t]*:[ \t]*\\(.*\\(\n[ \t]+.*\\)*\\)\n"
  "REGEXP matching mail headers."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defcustom release-mail-to-html-body-separator-regexp
  "\n\\(--text follows this line--\\)?\n"
  "REGEXP matching separator between mail header and body.  This
enables mail composition buffers to be used in addition to incoming
mail mesasges.  The first sub-expression is to match the part of the
separator to be removed from the release announcement."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defcustom release-mail-to-html-subject-regexp
  "^subject[ \t]*:[ \t]*XEmacs[ \t]+\\([0-9]+\\)\\.\\([0-9]+\\)\\(\\.\\([0-9]+\\)\\|[ \t]+(patch[ \t]+\\([0-9]+\\))\\)[ \t]+\\(\\(\"[^\"]+\"\\)[ \t]+\\)?\\(is\\|has[ \t]+been\\)[ \t]+released"
  "REGEXP matching mail subject header in an XEmacs release mail.
Version elements MAJOR, MINOR, BETA, PATCH, and CODENAME are matched
as substrings 1, 2, 4, 5, and 7 respectively, as applicable.  See
`match-string'."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defcustom release-mail-to-html-summary-header-regexp
  "^.*Brief[ \t]+summary[ \t]+of[ \t]+changes[ \t]+to\\(?:[ \t]+XEmacs\\)?[ \t]+\\([^ \t]+\\)[ \t]+\\(\"[^\"]+\"\\)\n*"
  "REGEXP matching the brief summary header of changes in an XEmacs
release mail, if present.
Substring 1 should contain the XEmacs version after a successful
match, substring 2 the XEmacs codename."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defcustom release-mail-to-html-summary-name-regexp
  "\\=\\([^-].+\\)\n+"
  "REGEXP matching a heading in the brief summary of changes in
an XEmacs release mail, if present at point.
Substring 1 contains the text of the summary heading, if applicable.
See `match-string'."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defcustom release-mail-to-html-summary-item-regexp
  "\\=-- \\(.+\\(\n[ \t]+.*\\)*\\)\n*"
  "REGEXP matching a single change in the brief summary of changes in
an XEmacs release mail, if present at point.
Substring 1 contains the text of a single change item, if applicable.
See `match-string'."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defcustom release-mail-to-html-changelog-record-regexp
  "\\=\n+[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[ \t]+\\(?:.*\\)[ \t]+\\(?:<[^>]+>\\)\\(\n+[ \t]+.*\\)+"
  "REGEXP matching a single ChangeLog record in an XEmacs release
mail, if present at point."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defcustom release-mail-to-html-changelog-regexp
  "\n*-+[ \t]*ChangeLog[ \t]+entries[ \t]+from[ \t]+\\(.*ChangeLog\\)[ \t]*-+"
  "REGEXP matching a ChangeLog records header for a sub-directory in
an XEmacs release mail, if present."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defcustom release-mail-to-html-patch-regexp
  "^From:[ \t]*\\(.*\\)[ \t]*\nSubject:[ \t]*\\(.*\\)[ \t]*\n[^ \t]*URL:[ \t]*\\([^>]+\\)[ \t>]*\n+"
  "REGEXP matching patch records in an XEmacs release mail, if
present.
Patch description elements FROM, SUBJECT, and URL are matched
as substrings 1, 2, and 3 respectively, as applicable.  See
`match-string'."
  :type '(regexp
          :custom-show t
          :documentation-shown t)
  :group 'release-mail-to-html)

(defun release-mail-to-html (&optional buffer)
  "*Create HTML from XEmacs release announcement mail.
BUFFER (defaulting to *Article*) needs to hold a standard release
announcement for a stable or beta release of XEmacs, as mailed to
<xemacs-announce@xemacs.org> or <xemacs-beta@xemacs.org> respectively.
The HTML output is placed in a buffer named uniquely (see
`generate-new-buffer-name'), based on the format
MAJOR.MINOR.PATCH.content, where PATCH may be a BETA number instead.
This is the standard filename used as genpage input to create the
corresponding HTML file.  The actual name used for buffer is returned.

Expected Release Announcement Format:

MAIL-HEADER+
FREE-FORM-TEXT*
SUMMARY-OF-CHANGES*
CHANGELOG-ENTRIES*
LIST-OF-APPLIED-PATCHES*
FREE-FORM-TEXT*

The relevant sections are matches according to these regular expression:

`release-mail-to-html-subject-regexp'
`release-mail-to-html-summary-header-regexp'
`release-mail-to-html-summary-name-regexp'
`release-mail-to-html-summary-item-regexp'
`release-mail-to-html-changelog-regexp'
`release-mail-to-html-changelog-record-regexp'
`release-mail-to-html-patch-regexp'
"
  (interactive
   (list
    (read-buffer "buffer containing release mail: " "*Article*" t)))
  (save-excursion
    (with-temp-buffer
      (insert-buffer buffer)
      (let
          (major-version
           minor-version
           patch-level
           xemacs-version-from-subject
           xemacs-version-from-summary
           code-name-from-subject
           code-name-from-summary
           release-mail-to-html-summary-alist
           release-mail-to-html-changelog-alist
           release-mail-to-html-patch-list
           release-mail-announcement
           release-mail-index
           content-buffer
           (case-fold-search t))
        (goto-char (point-min))
        ;; Extract version information from subject line:
        (when (re-search-forward
               release-mail-to-html-subject-regexp nil t)
          (setq major-version (match-string 1)
                minor-version (match-string 2)
                patch-level (or (match-string 4) (match-string 5))
                code-name-from-subject (match-string 7))
          (and
           major-version minor-version patch-level
           (setq xemacs-version-from-subject
                 (format
                  "%s.%s.%s" major-version minor-version patch-level))))
        ;; Extract version information from brief summary of changes
        ;; heading:
        (when (re-search-forward
               release-mail-to-html-summary-header-regexp nil t)
          (setq xemacs-version-from-summary
                (match-string 1))
          (setq
           code-name-from-summary (match-string 2))
          (delete-region
           (match-beginning 0) (match-end 0))
          (unless
              (string=
               xemacs-version-from-summary
               xemacs-version-from-subject)
            (error
             "release-mail-to-html: %s specifies different XEmacs versions as matched by %S and %S."
             buffer
             'release-mail-to-html-summary-header-regexp
             'release-mail-to-html-subject-regexp))
          (unless (string=
                   code-name-from-summary code-name-from-subject)
            (error
             "release-mail-to-html: %s specifies different XEmacs codenames as matched by %S and %S."
             buffer
             'release-mail-to-html-summary-header-regexp
             'release-mail-to-html-subject-regexp)))
        (unless
            (and xemacs-version-from-summary code-name-from-summary)
          (error
           "release-mail-to-html: %s fails to contain line matching %S."
           buffer
           'release-mail-to-html-summary-header-regexp))
        ;; Extract summary entries from announcement body.
        (let (summary-name
              summary-items)
          (while (re-search-forward
                  release-mail-to-html-summary-name-regexp nil t)
            (setq summary-name (match-string 1))
            (delete-region
             (match-beginning 0) (match-end 0))
            (while (re-search-forward
                    release-mail-to-html-summary-item-regexp nil t)
              (setq summary-items
                    (append summary-items
                            (list (match-string 1))))
              (delete-region
               (match-beginning 0) (match-end 0)))
            (setq release-mail-to-html-summary-alist
                  (append
                   release-mail-to-html-summary-alist
                   (list
                    (cons
                     summary-name summary-items))))
            (setq summary-name nil summary-items nil)))
        ;; Extract changelog entries from announcement body.
        (let (changelog-name
              changelog-records)
          (while (re-search-forward
                  release-mail-to-html-changelog-regexp nil t)
            (setq changelog-name (match-string 1))
            (delete-region
             (match-beginning 0)
             (match-end 0))
            (while (re-search-forward
                    release-mail-to-html-changelog-record-regexp nil t)
              (setq changelog-records
                    (concat changelog-records (match-string 0)))
              (delete-region
               (match-beginning 0)
               (match-end 0)))
            (setq release-mail-to-html-changelog-alist
                  (append
                   release-mail-to-html-changelog-alist
                   (list
                    (cons
                     changelog-name
                     changelog-records))))
            (setq changelog-name nil changelog-records nil)))
        ;; Extract applied patches from announcement body.
        (while (re-search-forward
                release-mail-to-html-patch-regexp nil t)
          (setq release-mail-to-html-patch-list
                (append
                 release-mail-to-html-patch-list
                 (list
                  (list
                   (match-string 1)
                   (match-string 2)
                   (match-string 3)))))
          (delete-region
           (match-beginning 0)
           (match-end 0)))
        ;; Get remaining free-form announcement body.
        (goto-char (point-min))
        (save-excursion
          (replace-regexp "\n+\\'" "")) ; remove empty trailing lines.
        ;; Search forward to end of headers, as defined by
        ;; `release-mail-to-html-body-separator-regexp'.
        ;; Delete (match-string 1), which is the mail composition
        ;; body/head separator.  This allows the XRE to update the
        ;; website before sending the release announcement (time
        ;; travel!).
        (search-forward-regexp
         release-mail-to-html-body-separator-regexp nil t)
        (if
            (match-string 1)
            (delete-region
             (match-beginning 1)
             (match-end 1)))
        ;; Process mail header, if any.
        (if (> (point) (point-min))
            (save-restriction
              (narrow-to-region
               (point-min)
               (- (point) 1))
              (goto-char (point-min))
              (delete-non-matching-lines
               release-mail-headers-to-keep-regexp))
          (warn "release-mail-to-html: %s misses mail headers."
                (buffer-name)))
        (goto-char (point-min))
        (setq release-mail-announcement
              (buffer-substring
               (point-min)
               (point-max)))
        ;; Generate list of index items
        ;; APA: Make sure to keep this order the reverse of the actual
        ;; document sections (because I cons here, adding to the head
        ;; of the list).
        (when release-mail-to-html-patch-list
          (setq
           release-mail-index
           (cons "patches" release-mail-index)))
        (when release-mail-to-html-changelog-alist
          (setq
           release-mail-index
           (cons "changes" release-mail-index)))
        (when release-mail-to-html-summary-alist
          (setq
           release-mail-index
           (cons "summary" release-mail-index)))
        (when release-mail-announcement
          (setq
           release-mail-index
           (cons "announcement" release-mail-index)))
        (setq
         content-buffer
         (generate-new-buffer-name
          (format "%s.content" xemacs-version-from-subject)))
        ;; Generate XML/XHTML/HTML document.
        (with-output-to-temp-buffer
            content-buffer
          (princ
           (format "%%title%%
XEmacs %s %s is Released
%%author%%
automatically generated from release announcement by release-mail-to-html.el
%%main%%
"
                   xemacs-version-from-subject
                   code-name-from-subject))
          (when release-mail-announcement
            (princ
             (format
              "          <h1><a name=\"announcement\">XEmacs</a> %s %s is Released</h1>\n"
              xemacs-version-from-subject code-name-from-subject))
            (princ
             (release-mail-index release-mail-index "announcement"))
            (princ
             (format
              "            <pre xml:space=\"preserve\">\n%s</pre>\n"
              release-mail-announcement)))
          (when
              (and
               xemacs-version-from-subject
               code-name-from-subject
               release-mail-to-html-summary-alist)
            (princ
             (format
              "            <h1><a name=\"summary\">Changes</a> in XEmacs %s %s</h1>\n"
              xemacs-version-from-subject code-name-from-subject))
            (princ
             (release-mail-index release-mail-index "summary"))
            (mapc
             ;; Handle a single summary of release-mail-to-html-summary-alist:
             (function
              (lambda (s)
                (if (not (cdr s))
                    ;; Print summary entry as paragraph, because it
                    ;; has no summary items.
                    (princ (format "            <p>%s</p>\n" (car s)))
                  ;; Print summary name:
                  (princ (format "            <h2>%s</h2>\n" (car s)))
                  ;; Print summary items as unordered list:
                  (princ (format "            <ul>\n"))
                  ;; Handle list of summary items:
                  (mapc
                   ;; Handle single summary item:
                   (function
                    (lambda (sil)
                      (princ (format "              <li>%s</li>\n" sil))))
                   (cdr s))
                  (princ (format "            </ul>\n")))))
             release-mail-to-html-summary-alist))
          (when (and
                 xemacs-version-from-subject
                 code-name-from-subject
                 release-mail-to-html-changelog-alist)
            (princ
             (format
              "            <h1><a name=\"changes\">ChangeLogs</a> for XEmacs %s %s</h1>\n"
              xemacs-version-from-subject code-name-from-subject))
            (princ
             (release-mail-index release-mail-index "changes"))
            (princ
             (format
              "            <ul>\n"))
            (mapc
             (function
              (lambda (l)
                (princ
                 (format
                  "              <li>ChangeLog Entries from <a href=\"#%s\">%s</a></li>\n"
                  (replace-in-string (car l) "/" ":")
                  (car l)))))
             release-mail-to-html-changelog-alist)
            (princ
             "            </ul>\n")
            (mapc
             (function
              (lambda (l)
                (princ
                 (format
                  "            <h2>ChangeLog Entries from <a name=\"%s\">%s</a></h2>\n%s            <pre xml:space=\"preserve\">%s</pre>\n"
                  (replace-in-string (car l) "/" ":")
                  (car l)
                  (release-mail-index release-mail-index "")
                  (cdr l)))))
             release-mail-to-html-changelog-alist))
          (when release-mail-to-html-patch-list
            (princ
             (format "          <h1><a name=\"patches\">Patches</a> in XEmacs %s %s</h1>\n"
                     xemacs-version-from-subject code-name-from-subject))
            (princ
             (release-mail-index release-mail-index "patches"))
            (princ "          <table border=\"0\">\n")
            (princ "            <tr>\n")
            (princ "              <td>\n")
            (princ "                <table width=\"100%\" border=\"1\">\n")
            (princ "                  <tr>\n")
            (princ "                    <th width=\"20%\" rowspan=\"1\" colspan=\"1\">Author</th>\n")
            (princ "                    <th rowspan=\"1\" colspan=\"1\">Subject</th>\n")
            (princ "                  </tr>\n")
            (princ "                  <tr>\n")
            (princ "                    <th rowspan=\"1\" colspan=\"2\">Patch URL</th>\n")
            (princ "                  </tr>\n")
            (princ "                </table>\n")
            (princ "              </td>\n")
            (princ "            </tr>\n")
            (mapc
             (function
              (lambda (c)
                (princ "            <tr>\n")
                (princ "              <td rowspan=\"1\" colspan=\"1\">\n")
                (princ "                <table width=\"100%\" border=\"1\">\n")
                (princ "                  <tr>\n")
                (princ
                 (format "                    <td width=\"20%%\" rowspan=\"1\" colspan=\"1\">%s</td>\n"
                         (release-mail-markup-author
                          (first c))))
                (princ
                 (format "                    <td rowspan=\"1\" colspan=\"1\">%s</td>\n"
                         (release-mail-markup-subject (second c))))
                (princ "                  </tr>\n")
                (princ "                  <tr>\n")
                (princ
                 (format "                    <td rowspan=\"1\" colspan=\"2\">%s</td>\n"
                         (release-mail-markup-url
                          (third c))))
                (princ "                  </tr>\n")
                (princ "                </table>\n")
                (princ "              </td>\n")
                (princ "            </tr>\n")
                ))
             release-mail-to-html-patch-list)
            (princ "          </table>\n"))
          (princ
           (release-mail-index release-mail-index)))
        ;; Quote HTML markup in preformatted sections.
        (with-current-buffer
            content-buffer
          (goto-char (point-min))
          (while (re-search-forward
                  release-mail-to-html-preformatted-regexp
                  nil t)
            (html-quote-region
             (match-beginning 1)
             (match-end 1))))
        ;; Add Local variables for PSGML at end of content file.
        (with-current-buffer
            content-buffer
          (goto-char (point-max))
          (insert
           (format
            "\n<!-- Keep this comment at the end of the file\n%s %s
mode: xml
sgml-omittag:nil
sgml-shorttag:nil
sgml-namecase-general:nil
sgml-general-insert-case:lower
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:(\"../template.html\" \"html\" \"body\" \"table\" \"tr\" \"td\")
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->\n"
            ;; Disguise the local variable bit so that we don't enter
            ;; xml-mode!
            "Local"
            "variables:")))
        content-buffer))))

(defun release-mail-markup-author (author)
  "internal function"
  (let
      ((components
        (mail-extract-address-components author)))
    (with-temp-buffer
      (insert
       (or
        (first components)
        (second components)))
      (html-quote-region
       (point-min)
       (point-max))
      (goto-char (point-min))
      (insert
       (format
        "<a href=\"mailto:%s\">"
        (second components)))
      (goto-char (point-max))
      (insert (format "</a>"))
      (buffer-string))))

(defun release-mail-markup-url (url)
  "internal function"
  (if
      (string-match
       "\\`\\(http\\|ftp\\)://" url)
      (format
       "<a href=\"%s\">%s</a>"
       url url)
    url))

(defun release-mail-markup-subject (subject)
  "internal function"
  (with-temp-buffer
    (insert subject)
    (html-quote-region
     (point-min)
     (point-max))
    (goto-char (point-min))
    (insert "<strong>")
    (goto-char (point-max))
    (insert "</strong>")
    (buffer-string)))

(defun release-mail-index (items &optional we-are-here)
  "internal function"
  (if items
      (concat
       "            <p>goto "
       (mapconcat
        (function
         (lambda (i)
           (if (and
                we-are-here
                (string= i we-are-here))
               (format "%s" i)
             (format "<a href=\"#%s\">%s</a>" i i))))
        items
        ",\n              ")
       "</p>\n")
    ""))

;;; release-mail-to-html.el ends here