annotate lisp/w3/w3-latex.el @ 82:6a378aca36af r20-0b91

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