annotate lisp/w3/w3-latex.el @ 2:ac2d302a0011 r19-15b2

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