~ubuntu-branches/ubuntu/oneiric/muse-el/oneiric

« back to all changes in this revision

Viewing changes to lisp/muse-docbook.el

  • Committer: Bazaar Package Importer
  • Author(s): Michael W. Olson (GNU address)
  • Date: 2008-01-09 15:51:46 UTC
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080109155146-vkc4ohnzv96spdpm
Tags: upstream-3.11
ImportĀ upstreamĀ versionĀ 3.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
;; Emacs Muse is free software; you can redistribute it and/or modify
8
8
;; it under the terms of the GNU General Public License as published
9
 
;; by the Free Software Foundation; either version 2, or (at your
 
9
;; by the Free Software Foundation; either version 3, or (at your
10
10
;; option) any later version.
11
11
 
12
12
;; Emacs Muse is distributed in the hope that it will be useful, but
52
52
  "<?xml version=\"1.0\" encoding=\"<lisp>
53
53
  (muse-docbook-encoding)</lisp>\"?>
54
54
<!DOCTYPE article PUBLIC \"-//OASIS//DTD DocBook V4.2//EN\"
55
 
                  \"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\">
 
55
                  \"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\"<lisp>(muse-docbook-entities)</lisp>>
56
56
<article>
57
57
  <articleinfo>
58
58
    <title><lisp>(muse-publishing-directive \"title\")</lisp></title>
68
68
 
69
69
(defcustom muse-docbook-footer "
70
70
  <!-- Page published by Emacs Muse ends here -->
71
 
</article>\n"
 
71
<lisp>(muse-docbook-bibliography)</lisp></article>\n"
72
72
  "Footer used for publishing DocBook XML files.
73
73
This may be text or a filename."
74
74
  :type 'string
156
156
    (end-center      . "\n</para>")
157
157
    (begin-quote     . "<blockquote>\n")
158
158
    (end-quote       . "\n</blockquote>")
 
159
    (begin-cite      . "<citation role=\"%s\">")
 
160
    (begin-cite-author . "<citation role=\"%s\">A:")
 
161
    (begin-cite-year . "<citation role=\"%s\">Y:")
 
162
    (end-cite        . "</citation>")
159
163
    (begin-quote-item . "<para>")
160
164
    (end-quote-item  . "</para>")
161
165
    (begin-uli       . "<itemizedlist mark=\"bullet\">\n")
217
221
                      "<\\(/?\\)\\(para\\|footnote\\|literallayout\\)[ >]"
218
222
                      nil t)
219
223
                     (cond ((string= (match-string 2) "literallayout")
220
 
                            (throw 'bail-out t))
 
224
                            (and (not (string= (match-string 1) "/"))
 
225
                                 (throw 'bail-out t)))
221
226
                           ((string= (match-string 2) "para")
222
227
                            (and
223
228
                             (not (string= (match-string 1) "/"))
276
281
                            nil t)
277
282
    (replace-match (upcase (match-string 1)) t t nil 1)))
278
283
 
 
284
(defun muse-docbook-fixup-citations ()
 
285
  ;; remove the role attribute if there is no role
 
286
  (goto-char (point-min))
 
287
  (while (re-search-forward "<\\(citation role=\"nil\"\\)>" nil t)
 
288
    (replace-match "citation" t t nil 1))
 
289
  ;; replace colons in multi-head citations with semicolons
 
290
  (goto-char (point-min))
 
291
  (while (re-search-forward "<citation.*>" nil t)
 
292
    (let ((start (point))
 
293
          (end (re-search-forward "</citation>")))
 
294
      (save-restriction
 
295
        (narrow-to-region start end)
 
296
        (goto-char (point-min))
 
297
        (while (re-search-forward "," nil t)
 
298
          (replace-match ";"))))))
 
299
 
279
300
(defun muse-docbook-munge-buffer ()
280
 
  (muse-docbook-fixup-images))
 
301
  (muse-docbook-fixup-images)
 
302
  (muse-docbook-fixup-citations))
 
303
 
 
304
(defun muse-docbook-entities ()
 
305
  (save-excursion
 
306
    (goto-char (point-min))
 
307
    (if (re-search-forward "<citation" nil t)
 
308
        (concat
 
309
         " [\n<!ENTITY bibliography SYSTEM \""
 
310
         (if (string-match ".short$" (muse-page-name))
 
311
             (substring (muse-page-name) 0 -6)
 
312
           (muse-page-name))
 
313
         ".bib.xml\">\n]")
 
314
      "")))
 
315
 
 
316
(defun muse-docbook-bibliography ()
 
317
  (save-excursion
 
318
    (goto-char (point-min))
 
319
    (if (re-search-forward "<citation" nil t)
 
320
        "&bibliography;\n"
 
321
      "")))
281
322
 
282
323
(defun muse-docbook-finalize-buffer ()
283
324
  (when (boundp 'buffer-file-coding-system)