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

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; w3-style.el,v --- Emacs-W3 binding style sheet mechanism
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Created: 1996/05/31 21:34:16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Version: 1.82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: faces, hypermedia
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) 1993, 1994, 1995 by William M. Perry (wmperry@spry.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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; A style sheet mechanism for emacs-w3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; This will eventually be able to under DSSSL[-lite] as well as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; experimental W3C mechanism
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (require 'w3-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (require 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defvar w3-style-css-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (copy-syntax-table mm-parse-args-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "The syntax table for parsing stylesheets")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defvar w3-style-ie-compatibility nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "*Whether we want to do Internet Explorer 3.0 compatible parsing of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 CSS stylesheets.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defun w3-style-css-parse-args (st &optional nd defines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; Return an assoc list of attribute/value pairs from a CSS style entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 name ; From name=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 value ; its value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 results ; Assoc list of results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 name-pos ; Start of XXXX= position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 val-pos ; Start of value position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (if (stringp st)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (set-buffer (get-buffer-create " *w3-style-temp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (set-syntax-table w3-style-css-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (insert st)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (setq st (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 nd (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (set-syntax-table w3-style-css-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (if (< nd st)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (narrow-to-region nd nd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (narrow-to-region st nd))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (skip-chars-forward ";, \n\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (setq name-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (skip-chars-forward "^ \n\t:=,;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (downcase-region name-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (setq name (buffer-substring name-pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (if (not (eq (char-after (point)) ?:)) ; There is no value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (setq value nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (skip-chars-forward " \t\n:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setq val-pos (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ((or (= (or (char-after val-pos) 0) ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (= (or (char-after val-pos) 0) ?'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (buffer-substring (1+ val-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (prog2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (skip-chars-forward "\""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (skip-chars-forward "^ \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (buffer-substring val-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (if w3-style-ie-compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (skip-chars-forward "^;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (skip-chars-forward "^,;"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq results (cons (cons name value) results))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (skip-chars-forward ";, \n\t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 results))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defvar w3-style-css-define-table nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defun w3-style-css-handle-define ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (let ((name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (retval nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (skip-chars-forward "^ \t\r\n") ; Past the name token
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (downcase-region save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (setq name (buffer-substring save-pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (skip-chars-forward "= \t\r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (setq save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (skip-chars-forward "^;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (setq retval (cons name (buffer-substring save-pos (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (skip-chars-forward " \t\r\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defun w3-style-css-handle-import ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (let ((url nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (save-pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (if (looking-at "'\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (error (skip-chars-forward "^ \t\r\n;")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (skip-chars-forward "^ \t\r\n;"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (setq url (url-expand-file-name (buffer-substring save-pos (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (skip-chars-forward "\"; \t\r\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (setq save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (let ((url-working-buffer (url-generate-new-buffer-name " *styleimport*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (url-mime-accept-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 "text/css ; level=2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (sheet nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (set-buffer (get-buffer-create url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (setq url-be-asynchronous nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (url-retrieve url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (w3-style-css-clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (setq sheet (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (insert sheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (goto-char save-pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (defun w3-style-css-clean ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; Nuke comments, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (let ((save-pos nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (while (search-forward "/*" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (setq save-pos (- (point) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (delete-region save-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (if (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (delete-matching-lines "^[ \t\r]*$") ; Nuke blank lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (w3-replace-regexp "^[ \t\r]+" "") ; Nuke whitespace at beg. of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (w3-replace-regexp "[ \t\r]+$" "") ; Nuke whitespace at end of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (goto-char (point-min)))
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-style-css-applies-to (st nd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (let ((results nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (save-pos nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (narrow-to-region st nd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (goto-char st)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (skip-chars-forward " \t\r\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (setq save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (skip-chars-forward "^,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (skip-chars-backward " \r\t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (setq results (cons (buffer-substring save-pos (point)) results))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (skip-chars-forward ", \t\r\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 results))
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-style-parse-css (fname &optional string inherit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (url-mime-accept-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 "text/css ; level=2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (save-pos nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (applies-to nil) ; List of tags to apply style to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (attrs nil) ; List of name/value pairs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (tag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (att nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (cur nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (val nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (class nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (defines nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (device-type nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (active-device-types (list 'normal 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if w3-running-FSF19 'emacs 'xemacs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (sheet inherit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (let ((type (device-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ((eq type 'tty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (if (and (fboundp 'tty-color-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (/= 0 (length (tty-color-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (setq active-device-types (cons 'ansi-tty active-device-types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (setq active-device-types (cons 'tty active-device-types))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ((eq 'color (device-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (setq active-device-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (list (intern (format "%dbit-color"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (device-bitplanes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (intern (format "%dbit"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (device-bitplanes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 'color) active-device-types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (if (= 24 (device-bitplanes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (setq active-device-types (cons 'truecolor active-device-types))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ((eq 'grayscale (device-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (setq active-device-types (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (list (intern (format "%dbit-grayscale"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (device-bitplanes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 'grayscale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 active-device-types)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ((eq 'mono (device-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (setq active-device-types (append (list 'mono 'monochrome)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 active-device-types)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (setq active-device-types (cons 'unknown active-device-types)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (set-buffer (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (url-generate-new-buffer-name " *style*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (set-syntax-table w3-style-css-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (if fname (url-insert-file-contents fname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (if string (insert string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (w3-style-css-clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; C++ style comments, and we are doing IE compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ((and (looking-at "//") w3-style-ie-compatibility)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;; Pre-Processor directives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ((looking-at "[ \t\r]*@\\([^ \t\r\n]\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (let ((directive nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (skip-chars-forward " @\t\r") ; Past any leading whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (setq save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (skip-chars-forward "^ \t\r\n") ; Past the @ directive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (downcase-region save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (setq directive (buffer-substring save-pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (skip-chars-forward " \t\r") ; Past any trailing whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (setq save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ((string= directive "define")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (let ((retval (w3-style-css-handle-define)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (and defines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (setq defines (cons retval defines)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ((string= directive "import")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (w3-style-css-handle-import))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (w3-warn 'style (format "Unknown directive: @%s" directive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 'warning)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; Giving us some output device information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ((looking-at "[ \t\r]*:\\([^:]+\\):")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (downcase-region (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (setq device-type (intern (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (if (not (memq device-type active-device-types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; Not applicable to us... skip the info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (if (re-search-forward ":[^:]*:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (goto-char (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; Default is to treat it like a stylesheet declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (skip-chars-forward "^{:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (downcase-region save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (setq applies-to (w3-style-css-applies-to save-pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (skip-chars-forward "^{")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (setq save-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (skip-chars-backward "\r}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (subst-char-in-region save-pos (point) ?\n ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (subst-char-in-region save-pos (point) ?\r ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq attrs (w3-style-css-parse-args (1+ save-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (point) defines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (skip-chars-forward "}\r\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (while applies-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq cur (car applies-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 applies-to (cdr applies-to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ((string-match "\\(.*\\)\\.\\(.*\\)" cur) ; Normal class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (setq tag (intern (downcase (match-string 1 cur)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 class (match-string 2 cur)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ((string-match "\\(.*\\):\\(.*\\)" cur) ; Pseudo class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq tag (intern (downcase (match-string 1 cur)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 class (match-string 2 cur)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (t ; No class - global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq tag (intern (downcase cur))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 class 'internal)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (let ((loop attrs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (while loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (if (stringp (car (car loop)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (setcar (car loop) (intern (car (car loop)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (setq att (car (car loop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 val (cdr (car loop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 loop (cdr loop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (case att
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ((align textalign text-align display white-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq val (intern (downcase val))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ((indent left-margin right-margin top-margin bottom-margin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (setq val (string-to-int val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (let* ((node-1 (assq tag sheet))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (node-2 (and node-1 (assoc class node-1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (node-3 (and node-2 (assq att node-2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ((not node-1) ; New top-level element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (setq sheet (cons (cons tag (list (cons class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (cons att val)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 sheet)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ((and node-1 (not node-2)) ; New class for existing element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (setcdr node-1 (cons (cons class (list (cons att val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (cdr node-1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ((and node-2 (not node-3)) ; attribute/value on old class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (setcdr node-2 (cons (cons att val) (cdr node-2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (node-3 ; Replace existing attribute value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (setcdr node-3 val)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (skip-chars-forward " \t\r\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (cons sheet defines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (defvar w3-style-font-size-mappings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 '(("xx-small" . 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ("x-small" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ("small" . 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ("medium" . 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ("large" . 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ("x-large" . 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ("xx-large" . 6)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 "A list of font size mappings")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defvar w3-style-font-weight-mappings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 '(("-3" . :extra-light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ("-2" . :light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ("-1" . :demi-light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ("0" . :medium)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ("1" . :normal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ("2" . :demi-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ("3" . :bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ("4" . :extrabold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ("bold" . :bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ("demi-light" . :demi-light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ("demi-bold" . :demi-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ("extra-bold" . :extra-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ("extra-light". :extra-light)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 "A list of font weight mappings.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (defun w3-style-font-size-for-index (index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (if (stringp index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (setq index (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (cdr-safe (assoc (downcase index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 w3-style-font-size-mappings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (setq index (- index 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (let ((scaler (if (> index 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 1.44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 0.695))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (size 12))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq index (abs index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (while (/= index 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (setq size (* size scaler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 index (1- index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;; This rounds to the nearest '10'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (format "%dpt" (* 10 (round (/ size 10))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (defun w3-generate-stylesheet-faces (sheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (let ((todo sheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (cur nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (cur-classes nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (node nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (voice nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (voice-person nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (voice-tone nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (fore nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (back nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (pixmap nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (font nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (family nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (decoration nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (style nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (size nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (index nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (shorthand nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (weight nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (break-style nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (while todo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (setq cur (car todo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 cur-classes (cdr cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 todo (cdr todo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (while cur-classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (setq node (cdr (car cur-classes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 cur (car cur-classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 cur-classes (cdr cur-classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 fore (cdr-safe (assq 'color node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 back (cdr-safe (assq 'background node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 voice-person (cdr-safe (assq 'voice node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 voice-tone (cdr-safe (assq 'voice-tone node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 decoration (cdr-safe (assq 'text-decoration node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 pixmap (cdr-safe (assq 'backdrop node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 index (cdr-safe (assq 'font-size-index node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 size (or (and index (w3-style-font-size-for-index index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (cdr-safe (assq 'font-size node)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 family (cdr-safe (assq 'font-family node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 weight (cdr-safe (assq 'font-weight node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 weight (or (cdr-safe (assoc weight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 w3-style-font-weight-mappings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 weight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 style (cdr-safe (assq 'font-style node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 shorthand (cdr-safe (assq 'font node)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (setq voice (if (or voice-person voice-tone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (intern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ((and voice-person voice-tone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (concat voice-person "-" voice-tone))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (voice-person voice-person)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (voice-tone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (concat "default-voice-" voice-tone))
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 (error "IMPOSSIBLE"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;; Make sure all 'break' items get intern'd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (if (or style decoration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (setq style (concat style decoration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (setq break-style (assq 'break node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (if (and (cdr break-style) (stringp (cdr break-style)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (setcdr break-style (intern (cdr break-style))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if shorthand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (let ((shorthand (split-string shorthand "[ \t]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (setq size (or (nth 0 shorthand) size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 family (or (nth 1 shorthand) size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 weight (or (nth 2 shorthand) weight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 weight (or (cdr-safe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (assoc weight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 w3-style-font-weight-mappings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 weight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 style (or (nth 3 shorthand) style))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (if style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (setq style (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (while (string-match "-" x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (setq x (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (substring x 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (substring x (match-end 0) nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (concat "font-set-" (downcase x) "-p"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (delete "" (split-string style "[ \t&,]")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (if family (setq family (delete "" (split-string family "[ \t]"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (if (or family weight style size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (setq font (make-font :family family :weight weight :size size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (while style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (and (fboundp (car style))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (funcall (car style) font t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (setq style (cdr style))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (setq font nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (if voice (setcdr cur (cons (cons 'voice-spec voice) (cdr cur))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (if font (setcdr cur (cons (cons 'font-spec font) (cdr cur))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (if fore (setcdr cur (cons (cons 'foreground fore) (cdr cur))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (if back (setcdr cur (cons (cons 'background back) (cdr cur))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (defun w3-handle-style (&optional args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (let ((fname (or (cdr-safe (assq 'href args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (cdr-safe (assq 'src args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (cdr-safe (assq 'uri args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (type (downcase (or (cdr-safe (assq 'notation args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 "experimental")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (url-working-buffer " *style*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (base (cdr-safe (assq 'base args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (stylesheet nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (defines nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (cur-sheet w3-current-stylesheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (string (cdr-safe (assq 'data args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (if fname (setq fname (url-expand-file-name fname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (cdr-safe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (assoc base w3-base-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (set-buffer (get-buffer-create url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (setq url-be-asynchronous nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 ((member type '("experimental" "arena" "w3c-style" "css"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (let ((data (w3-style-parse-css fname string cur-sheet)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (setq stylesheet (nth 0 data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 defines (nth 1 data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (w3-warn 'html "Unknown stylesheet notation: %s" type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (setq w3-current-stylesheet stylesheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (if (and w3-current-stylesheet (fboundp 'make-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (w3-generate-stylesheet-faces w3-current-stylesheet))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (defun w3-display-stylesheet (&optional sheet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (if (not sheet) (setq sheet w3-current-stylesheet))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (with-output-to-temp-buffer "W3 Stylesheet"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (set-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (emacs-lisp-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (require 'pp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (pp sheet (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (provide 'w3-style)