annotate lisp/w3/w3-latex.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; w3-latex.el,v --- Emacs-W3 printing via LaTeX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Created: 1996/06/06 15:00:18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Version: 1.4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: hypermedia, printing, typesetting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Copyright (c) 1996 by Stephen Peters <speters%samsun@us.oracle.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; This file is not part of GNU Emacs, but the same permissions apply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Elisp code to convert a W3 parse tree into a LaTeX buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Heavily hacked upon by William Perry <wmperry@spry.com> to add more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; bells and whistles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; KNOWN BUGS:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; 1) This does not use stylesheets to get the formatting information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; 2) This means that the new drawing routines need to be abstracted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; further so that the same main engine can be used for either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; text-output (standard stuff in w3-draw), LaTeX output (this file),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; Postscript (to-be-implemented), etc., etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; 3) This still doesn't handle tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (require 'w3-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defvar w3-latex-print-links nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 "*If non-nil, prints the URLs of hypertext links as footnotes on a page.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defvar w3-latex-use-latex2e nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "*If non-nil, configures LaTeX parser to use LaTeX2e syntax. A `nil'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 value indicates that LaTeX 2.0.9 compatibility will be used instead.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defvar w3-latex-packages nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "*List of LaTeX packages to include. Currently this is only used if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 `w3-latex-use-latex2e' is non-nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (defvar w3-latex-use-maketitle nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 "*Non-nil makes the LaTeX parser use real LaTeX title pages for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 document titles.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; Internal variables - do not touch!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defvar w3-latex-current-url nil "What URL we are formatting")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defvar w3-latex-verbatim nil "Whether we are in a {verbatim} block or not")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defvar w3-latex-entities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 '((nbsp . "~")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (iexcl . "!`")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ; (cent . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (pound . "\\pounds ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ; (curren . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ; (yen . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (brvbar . "|")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (sect . "\\S")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (uml . "\\\"{ }")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (copy . "\\copyright ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ; (ordf . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (laquo . "$\\ll$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (not . "\\neg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (shy . "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (reg . "(R)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (macr . "\\={ }")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (deg . "$\\deg$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (plusmn . "$\\pm$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (sup2 . "$^{2}$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (sup3 . "$^{3}$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (acute . "\\'{ }")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (micro . "$\\mu$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (para . "\\P ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (middot . "$\\cdot$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (cedil . "\\c{ }")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (sup1 . "$^{1}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ; (ordm . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (raquo . "$\\gg$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (frac14 . "$\frac{1}{4}$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (frac12 . "$\frac{1}{2}$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (frac34 . "$\frac{3}{4}$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (iquest . "?`")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (Agrave . "\\`{A}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (Aacute . "\\'{A}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (Acirc . "\\^{A}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (Atilde . "\\~{A}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (Auml . "\\\"{A}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (Aring . "\\AA ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (AElig . "\\AE ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (Ccedil . "\\c{C}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (Egrave . "\\`{E}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (Eacute . "\\'{E}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (Ecirc . "\\^{E}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (Euml . "\\\"{E}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (Igrave . "\\`{I}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (Iacute . "\\'{I}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (Icirc . "\\^{I}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (Iuml . "\\\"{I}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ; (ETH . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (Ntilde . "\\~{N}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (Ograve . "\\`{O}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (Oacute . "\\'{O}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (Ocirc . "\\^{O}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (Otilde . "\\~{O}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (Ouml . "\\\"{O}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (times . "$\\times$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (Oslash . "\\O")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (Ugrave . "\\`{U}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (Uacute . "\\'{U}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (Ucirc . "\\^{U}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (Uuml . "\\\"{U}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (Yacute . "\\'{Y}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ; (THORN . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (szlig . "\\ss ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (agrave . "\\`{a}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (aacute . "\\'{a}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (acirc . "\\^{a}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (atilde . "\\~{a}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (auml . "\\\"{a}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (aring . "\\aa ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (aelig . "\\ae ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (ccedil . "\\c{c}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (egrave . "\\`{e}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (eacute . "\\'{e}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (ecirc . "\\^{e}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (euml . "\\\"{e}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (igrave . "\\`{i}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (iacute . "\\'{i}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (icirc . "\\^{i}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (iuml . "\\\"{i}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ; (eth . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (ntilde . "\\~{n}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (ograve . "\\`{o}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (oacute . "\\'{o}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (ocirc . "\\^{o}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (otilde . "\\~{o}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (ouml . "\\\"{o}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (divide . "$\\div$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (oslash . "\\o")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (ugrave . "\\`{u}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (uacute . "\\'{u}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (ucirc . "\\^{u}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (uuml . "\\\"{u}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (yacute . "\\'{y}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ; (thorn . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (yuml . "\\\"{y}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 "Defines mappings between `w3-html-entities' and LaTeX characters.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defun w3-latex-replace-entities (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (let ((start 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (while (string-match "[\200-\377]" str start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ; get the character code, and then search for a match in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ; w3-html-entities. If one is found, use it to perform a lookup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ; in w3-latex-entities, and use the resulting match to replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ; the character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (let* ((match (rassq (aref str (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 w3-html-entities))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (replace (and match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (assq (car match) w3-latex-entities))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (if replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (setq str (replace-match (cdr replace) t t str)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (setq start (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (defun w3-latex-insert-string (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;; convert string to a LaTeX-compatible one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (let ((todo (list (cons "\\\\" "\\BaCkSlAsH")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (cons "[%&#_{}$]" "\\\\\\&")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (cons "[~^]" "\\\\\\&{ }")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (cons "[*]" "{\\&}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (cons "[><|]" "$\\&$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (cons "\\\\BaCkSlAsH" "$\\backslash$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (cons "\n" (if w3-latex-verbatim
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 "\\\\newline\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 " ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (if w3-latex-verbatim
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (setq todo (append todo '((" " . "\\\\ ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (set-buffer (get-buffer-create " *w3-latex-munging*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (insert str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (while todo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (while (re-search-forward (caar todo) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (replace-match (cdar todo)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (setq todo (cdr todo)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (setq str (w3-latex-replace-entities (buffer-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (insert str)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defun w3-latex-contents (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;; passes contents of subtree through to the latex-subtree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (let ((contents (car (cdr (cdr tree)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (while contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (w3-latex-subtree (car contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (setq contents (cdr contents)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (defun w3-latex-html (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (insert "% This document automatically generated by Emacs-W3 v"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 w3-version-number "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if w3-latex-current-url
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (insert "% from <URL:" w3-latex-current-url ">\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (insert "%\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 "\\begin{document}\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (insert "\\end{document}\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (defun w3-latex-title (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (if w3-latex-use-maketitle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (insert "\\title{")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (insert "\\section*{\\centering "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (insert "}\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (if w3-latex-use-maketitle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (insert "\\author{}\\date{}\n\\maketitle")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (defun w3-latex-heading (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; look through the additional markup to see if an align=right or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;; align=center is in here...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (let ((align (assq 'align (car (cdr tree))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (sym (car tree)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (cond ((and align (string-equal (cdr align) "center"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (insert "\\begin{center}\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ((and align (string-equal (cdr align) "right"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (insert "\\begin{flushright}\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (cond ((eq sym 'h1) (insert "\\section*{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ((eq sym 'h2) (insert "\\subsection*{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ((eq sym 'h3) (insert "\\subsubsection*{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ((eq sym 'h4) (insert "\\subsubsection*{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ((eq sym 'h5) (insert "\\paragraph*{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ((eq sym 'h6) (insert "\\subparagraph*{")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (insert "}\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (cond ((and align (string-equal (cdr align) "center"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (insert "\\end{center}\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ((and align (string-equal (cdr align) "right"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (insert "\\end{flushright}\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (defun w3-latex-bold (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (insert "{\\bf ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (insert "}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun w3-latex-italic (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (insert "{\\em ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (insert "}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defun w3-latex-typewriter (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (insert "{\\tt ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (insert "}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (defun w3-latex-list (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (let* ((sym (car tree))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (list-type (cond ((eq sym 'ol) "enumerate")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ((eq sym 'dl) "description")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (t "itemize"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (insert (concat "\n\\begin{" list-type "}\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (insert (concat "\n\\end{" list-type "}\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (defun w3-latex-list-item (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (let ((sym (car tree)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (cond ((eq sym 'dt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (insert "\n\\item["))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ((eq sym 'dd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; don't do anything for dd -- the item is handled by dt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (t (insert "\n\\item")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (if (eq sym 'dt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (insert "]"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (defun w3-latex-center (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (insert "\\begin{center}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (insert "\\end{center}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (defun w3-latex-rule (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ; use \par to make paragraph division clear.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (insert "\n\\par\\noindent\\rule{\\textwidth}{.01in}\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (defun w3-latex-para (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; look through the additional markup to see if an align=right or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;; align=center is in here...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (let ((align (assq 'align (car (cdr tree)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (cond ((and align
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (string-equal (cdr align) "center"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (w3-latex-center tree))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ((and align
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (string-equal (cdr align) "right"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (insert "\\begin{flushright}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (insert "\\end{flushright}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (t (insert "\\par ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (w3-latex-contents tree)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (defun w3-latex-quote (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (insert "\\begin{quote}\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (insert "\\end{quote}\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (defun w3-latex-break (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;; no content allowed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (insert "\\linebreak"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defun w3-latex-href (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (let ((href (cdr-safe (assq 'href (cadr tree)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ((not w3-latex-print-links) ; No special treatment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (w3-latex-contents tree))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (href ; Special treatment requested
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (insert "\\underline{") ; and we have a URL - underline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (w3-latex-contents tree) ; it and prepare a footnote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (insert "}\\footnote{" href "}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (t ; Special treatment requested, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (w3-latex-contents tree))))) ; no URL - do nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (defun w3-latex-preformatted (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (let ((w3-latex-verbatim t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (insert "\\tt{")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (insert "}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (defun w3-latex-xmp (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (insert "\\begin{verbatim}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (w3-latex-contents tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (insert "\\end{verbatim}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (let ((todo '((title . w3-latex-title)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (html . w3-latex-html)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (pre . w3-latex-preformatted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (xmp . w3-latex-xmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (h1 . w3-latex-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (h2 . w3-latex-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (h3 . w3-latex-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (h4 . w3-latex-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (h5 . w3-latex-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (h6 . w3-latex-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (a . w3-latex-href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (strong . w3-latex-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (b . w3-latex-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (dfn . w3-latex-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (em . w3-latex-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (i . w3-latex-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (address . w3-latex-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (code . w3-latex-typewriter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (samp . w3-latex-typewriter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (tt . w3-latex-typewriter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (kbd . w3-latex-typewriter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (var . w3-latex-typewriter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (ol . w3-latex-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (dl . w3-latex-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (ul . w3-latex-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (menu . w3-latex-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (dir . w3-latex-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (li . w3-latex-list-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (dt . w3-latex-list-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (dd . w3-latex-list-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (center . w3-latex-center)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (hr . w3-latex-rule)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (p . w3-latex-para)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (br . w3-latex-break)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (blockquote . w3-latex-quote))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (while todo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (put (caar todo) 'w3-latex-formatter (cdar todo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (setq todo (cdr todo))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defun w3-latex-subtree (tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ((stringp tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (w3-latex-insert-string tree))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ((stringp (car-safe tree))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (while tree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (w3-latex-insert-string (car tree))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq tree (cdr tree))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ((symbolp (car tree))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (let ((proc (get (car tree) 'w3-latex-formatter)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (if (and proc (fboundp proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (funcall proc tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ;; anything else gets passed through unchanged
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (w3-latex-contents tree))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (w3-latex-contents tree))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (defun w3-parse-tree-to-latex (tree &optional url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ; assumes that url-working-buffer exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (set-buffer (get-buffer-create url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (setq w3-latex-current-url url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (if w3-latex-use-latex2e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (insert (concat "\\documentclass" w3-latex-docstyle "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (insert (concat "\\documentstyle" w3-latex-docstyle "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (if (and w3-latex-use-latex2e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 w3-latex-packages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (insert (apply 'concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (mapcar (lambda (x) (concat "\\usepackage{" x "}\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 w3-latex-packages))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (while tree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (w3-latex-subtree (car tree))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (setq tree (cdr tree))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (defun w3-show-dvi ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 "Uses xdvi to show DVI file created from `w3-parse-tree-to-latex'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (w3-parse-tree-to-latex w3-current-parse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (set-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (write-region (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (expand-file-name "w3-tmp.latex"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 w3-temporary-directory) nil 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (shell-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 "(cd %s ; latex w3-tmp.latex ; xdvi w3-tmp.dvi ; rm -f w3-tmp*) &"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 w3-temporary-directory))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (provide 'w3-latex)