annotate lisp/w3/css.el @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 0293115a14e9
children 441bb1e64a06
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
1 ;;; css.el -- Cascading Style Sheet parser
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
2 ;; Author: wmperry
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3 ;; Created: 1997/02/08 05:24:49
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
4 ;; Version: 1.27
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
5 ;; Keywords:
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
6
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
10 ;;;
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
11 ;;; This file is not part of GNU Emacs, but the same permissions apply.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
12 ;;;
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
14 ;;; it under the terms of the GNU General Public License as published by
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
15 ;;; the Free Software Foundation; either version 2, or (at your option)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
16 ;;; any later version.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
17 ;;;
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
21 ;;; GNU General Public License for more details.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
22 ;;;
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
23 ;;; You should have received a copy of the GNU General Public License
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
26 ;;; Boston, MA 02111-1307, USA.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
27 ;;;
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
29
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
30 (eval-and-compile
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
31 (require 'cl)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
32 (require 'font)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
33 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
34
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
35 ;; CBI = Cant Be Implemented - due to limitations in emacs/xemacs
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
36 ;; NYI = Not Yet Implemented - due to limitations of space/time
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
37 ;; NYPI = Not Yet Partially Implemented - possible partial support, eventually
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
38
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
39 (defconst css-properties
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
40 '(;; Property name Inheritable? Type of data
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
41 ;; Base CSS level 1 properties: http://www.w3.org/pub/WWW/TR/REC-CSS1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
42 ;; Font properties, Section 5.2
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
43 [font-family t string-list]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
44 [font-style t symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
45 [font-variant t symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
46 [font-weight t weight]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
47 [font-size t length]
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
48 [font nil font]
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
49
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
50 ;; Color and background properties, Section 5.3
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
51 [color t color]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
52 [background nil color-shorthand]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
53 [background-color nil color]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
54 [background-image nil url] ; NYI
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
55 [background-repeat nil symbol] ; CBI
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
56 [background-attachment nil symbol] ; CBI
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
57 [background-position nil symbol] ; CBI
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
58
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
59 ;; Text properties, Section 5.4
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
60 [word-spacing t length] ; CBI
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
61 [letter-spacing t length] ; CBI
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
62 [text-decoration t symbol-list]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
63 [vertical-align nil symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
64 [text-transform t symbol]
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
65 [text-align t symbol]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
66 [text-indent t length] ; NYI
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
67 [line-height t length] ; CBI
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
68
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
69 ;; Box properties, Section 5.5
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
70 [margin nil boundary-shorthand]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
71 [margin-left nil length]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
72 [margin-right nil length]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
73 [margin-top nil length]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
74 [margin-bottom nil length]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
75 [padding nil boundary-shorthand]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
76 [padding-left nil length]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
77 [padding-right nil length]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
78 [padding-top nil length]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
79 [padding-bottom nil length]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
80 [border nil border-shorthand]
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
81 [border-left nil border]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
82 [border-right nil border]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
83 [border-top nil border]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
84 [border-bottom nil border]
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
85 [border-top-width nil nil]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
86 [border-right-width nil nil]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
87 [border-bottom-width nil nil]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
88 [border-left-width nil nil]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
89 [border-width nil boundary-shorthand]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
90 [border-color nil color]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
91 [border-style nil symbol]
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
92 [width nil length] ; NYPI
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
93 [height nil length] ; NYPI
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
94 [float nil symbol]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
95 [clear nil symbol]
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
96
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
97 ;; Classification properties, Section 5.6
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
98 [display nil symbol]
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
99 [list-style-type t symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
100 [list-style-image t url]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
101 [list-style-position t symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
102 [list-style nil list-style]
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
103 [white-space t symbol]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
104
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
105 ;; These are for specifying speech properties (ACSS-style)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
106 ;; http://www.w3.org/pub/WWW/Style/CSS/Speech/NOTE-ACSS
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
107
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
108 ;; General audio properties, Section 3
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
109 [volume t string] ; Needs its own type?
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
110 [pause-before nil time]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
111 [pause-after nil time]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
112 [pause nil pause]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
113 [cue-before nil string]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
114 [cue-after nil string]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
115 [cue-during nil string]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
116 [cue nil string] ; Needs its own type?
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
117
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
118 ;; Spatial properties, Section 4
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
119 [azimuth t angle]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
120 [elevation t elevation]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
121
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
122 ;; Speech properties, Section 5
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
123 [speed t string]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
124 [voice-family t string-list]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
125 [pitch t string]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
126 [pitch-range t percentage]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
127 [stress t percentage]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
128 [richness t percentage]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
129 [speak-punctuation t symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
130 [speak-date t symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
131 [speak-numeral t symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
132 [speak-time t symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
133
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
134 ;; Proposed printing extensions
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
135 ;; http://www.w3.org/pub/WWW/Style/Group/WD-PRINT-961220
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
136 ;; These apply only to pages (@page directive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
137 [size nil symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
138 [orientation nil symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
139 [margin-inside nil length]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
140 ;; These apply to the document
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
141 [page-break-before nil symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
142 [page-break-after nil symbol]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
143
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
144 ;; These are for specifying speech properties (Raman-style)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
145 [voice-family t string]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
146 [gain t integer]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
147 [left-volume t integer]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
148 [right-volume t integer]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
149 [pitch t integer]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
150 [pitch-range t integer]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
151 [stress t integer]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
152 [richness t integer]
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
153 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
154 "A description of the various CSS properties and how to interpret them.")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
155
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
156 (put 'font 'css-shorthand t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
157 (put 'background 'css-shorthand t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
158 (put 'margin 'css-shorthand t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
159 (put 'padding 'css-shorthand t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
160 (put 'border 'css-shorthand t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
161 (put 'list-style 'css-shorthand t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
162
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
163 (mapcar
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
164 (lambda (entry)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
165 (put (aref entry 0) 'css-inherit (aref entry 1))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
166 (put (aref entry 0) 'css-type (aref entry 2)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
167 css-properties)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
168
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
169 (defconst css-weights
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
170 '(nil ;never used
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
171 :extra-light
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
172 :light
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
173 :demi-light
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
174 :medium
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
175 :normal
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
176 :demi-bold
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
177 :bold
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
178 :extra-bold
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
179 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
180 "List of CSS font weights.")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
181
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
182 (defvar css-syntax-table
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
183 (copy-syntax-table emacs-lisp-mode-syntax-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
184 "The syntax table for parsing stylesheets")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
185
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
186 (modify-syntax-entry ?' "\"" css-syntax-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
187 (modify-syntax-entry ?` "\"" css-syntax-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
188 (modify-syntax-entry ?{ "(" css-syntax-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
189 (modify-syntax-entry ?} ")" css-syntax-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
190
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
191 (eval-when-compile
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
192 (defvar css-scratch-val nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
193 (defvar css-scratch-id nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
194 (defvar css-scratch-class nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
195 (defvar css-scratch-possibles nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
196 (defvar css-scratch-current nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
197 (defvar css-scratch-classes nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
198 (defvar css-scratch-class-match nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
199 (defvar css-scratch-current-rule nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
200 (defvar css-scratch-current-value nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
201 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
202
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
203 (defconst css-running-xemacs
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
204 (string-match "XEmacs" (emacs-version))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
205 "Whether we are running in XEmacs or not.")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
206
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
207 (defsubst css-replace-regexp (regexp to-string)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
208 (goto-char (point-min))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
209 (while (re-search-forward regexp nil t)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
210 (replace-match to-string t nil)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
211
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
212 (defun css-contextual-match (rule stack)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
213 (let ((ancestor)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
214 (p-args)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
215 (p-class)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
216 (matched t))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
217 (while rule
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
218 (setq ancestor (assq (caar rule) stack))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
219 (if (not ancestor)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
220 (setq rule nil
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
221 matched nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
222 (setq p-args (cdr ancestor)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
223 p-class (or (cdr-safe (assq 'class p-args)) t))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
224 (if (not (equal p-class (cdar rule)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
225 (setq matched nil
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
226 rule nil)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
227 (setq rule (cdr rule)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
228 matched))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
229
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
230 (defsubst css-get-internal (tag args)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
231 (declare (special tag sheet element-stack default))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
232 (setq css-scratch-id (or (cdr-safe (assq 'id args))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
233 (cdr-safe (assq 'name args)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
234 css-scratch-class (or (cdr-safe (assq 'class args)) t)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
235 css-scratch-possibles (cl-gethash tag sheet))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
236 (while css-scratch-possibles
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
237 (setq css-scratch-current (car css-scratch-possibles)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
238 css-scratch-current-rule (car css-scratch-current)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
239 css-scratch-current-value (cdr css-scratch-current)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
240 css-scratch-classes (if (listp (car css-scratch-current-rule))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
241 (cdar css-scratch-current-rule)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
242 (cdr css-scratch-current-rule))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
243 css-scratch-class-match t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
244 css-scratch-possibles (cdr css-scratch-possibles))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
245 (if (eq t css-scratch-classes)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
246 (setq css-scratch-classes nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
247 (if (eq t css-scratch-class)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
248 (setq css-scratch-class nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
249 (while css-scratch-classes
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
250 (if (not (member (pop css-scratch-classes) css-scratch-class))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
251 (setq css-scratch-class-match nil
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
252 css-scratch-classes nil)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
253 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
254 ((and (listp (car css-scratch-current-rule)) css-scratch-class-match)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
255 ;; Contextual!
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
256 (setq css-scratch-current-rule (cdr css-scratch-current-rule))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
257 (if (css-contextual-match css-scratch-current-rule element-stack)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
258 (setq css-scratch-val
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
259 (append css-scratch-val css-scratch-current-value)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
260 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
261 (css-scratch-class-match
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
262 (setq css-scratch-val (append css-scratch-val css-scratch-current-value))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
263 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
264 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
265 nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
266 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
267 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
268
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
269 (defsubst css-get (tag args &optional sheet element-stack)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
270 (setq css-scratch-val nil
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
271 css-scratch-class (or (cdr-safe (assq 'class args)) t))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
272
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
273 ;; check for things without the class
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
274 (if (listp css-scratch-class)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
275 (css-get-internal tag nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
276
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
277 ;; check for global class values
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
278 (css-get-internal '*document args)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
279
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
280 ;; Now check for things with the class - they will be stuck on the front
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
281 ;; of the list, which will mean we do the right thing
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
282 (css-get-internal tag args)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
283
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
284 ;; Defaults are up to the calling application to provide
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
285 css-scratch-val)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
286
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
287 (defun css-ancestor-get (info ancestors sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
288 ;; Inheritable property, check ancestors
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
289 (let (cur)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
290 (while ancestors
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
291 (setq cur (car ancestors)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
292 css-scratch-val (css-get info (car cur) (cdr cur) sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
293 ancestors (if css-scratch-val nil (cdr ancestors)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
294 css-scratch-val)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
295
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
296 (defun css-split-selector (tag)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
297 ;; Return a list
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
298 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
299 ((string-match " " tag) ; contextual
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
300 (let ((tags (split-string tag "[ \t]+"))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
301 (result nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
302 (while tags
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
303 (setq result (cons (css-split-selector (car tags)) result)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
304 tags (cdr tags)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
305 result))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
306 ((string-match "[:\\.]" tag)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
307 (let ((tag (if (= (match-beginning 0) 0)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
308 '*document
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
309 (intern (downcase (substring tag 0 (match-beginning 0))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
310 (rest (substring tag (match-beginning 0) nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
311 (classes nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
312 (while (string-match "^[:\\.][^:\\.]+" rest)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
313 (if (= ?. (aref rest 0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
314 (setq classes (cons (substring rest 1 (match-end 0)) classes))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
315 (setq classes (cons (substring rest 0 (match-end 0)) classes)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
316 (setq rest (substring rest (match-end 0) nil)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
317 (setq classes (sort classes 'string-lessp))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
318 (cons tag classes)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
319 ((string-match "^#" tag) ; id selector
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
320 (cons '*document tag))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
321 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
322 (cons (intern (downcase tag)) t)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
323 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
324 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
325 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
326
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
327 (defun css-applies-to (st nd)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
328 (let ((results nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
329 (save-pos nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
330 (narrow-to-region st nd)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
331 (goto-char st)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
332 (skip-chars-forward " \t\r\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
333 (while (not (eobp))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
334 (setq save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
335 (skip-chars-forward "^,")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
336 (skip-chars-backward " \r\t\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
337 (setq results (cons (css-split-selector
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
338 (buffer-substring save-pos (point))) results))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
339 (skip-chars-forward ", \t\r\n"))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
340 (widen)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
341 results))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
342
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
343 (defun css-split-font-shorthand (font)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
344 ;; [<font-weight> || <font-style>]? <font-size> [ / <line-height> ]? <font-family>
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
345 (let (weight size height family retval)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
346 (if (not (string-match " *\\([0-9.]+[^ /]+\\)" font))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
347 (error "Malformed font shorthand: %s" font))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
348 (setq weight (if (/= 0 (match-beginning 0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
349 (substring font 0 (match-beginning 0)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
350 size (match-string 1 font)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
351 font (substring font (match-end 0) nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
352 (if (string-match " */ *\\([^ ]+\\) *" font)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
353 ;; they specified a line-height as well
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
354 (setq height (match-string 1 font)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
355 family (substring font (match-end 0) nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
356 (if (string-match "^[ \t]+" font)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
357 (setq family (substring font (match-end 0) nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
358 (setq family font)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
359 (if weight (setq retval (cons (cons 'font-weight weight) retval)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
360 (if size (setq retval (cons (cons 'font-size size) retval)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
361 (if height (setq retval (cons (cons 'line-height height) retval)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
362 (if family (setq retval (cons (cons 'font-family family) retval)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
363 retval))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
364
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
365 (defun css-expand-length (spec)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
366 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
367 ((not (stringp spec)) spec)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
368 ((string-equal spec "auto") nil)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
369 ((string-match "\\([+-]?\\([0-9]+\\|[0-9]*\\.[0-9]+\\)\\)%" spec) ; A percentage
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
370 nil)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
371 ((string-match "\\([+-]?\\([0-9]+\\|[0-9]*\\.[0-9]+\\)\\)e[mx]" spec) ; Character based
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
372 (max 0 (round (string-to-number (match-string 1 spec)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
373 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
374 (truncate (font-spatial-to-canonical spec)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
375 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
376 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
377
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
378 (defsubst css-unhex-char (x)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
379 (if (> x ?9)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
380 (if (>= x ?a)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
381 (+ 10 (- x ?a))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
382 (+ 10 (- x ?A)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
383 (- x ?0)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
384
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
385 (defsubst css-pow (x n)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
386 (apply '* (make-list n x)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
387
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
388 (defun css-unhex (x)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
389 (let ((ord (length x))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
390 (rval 0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
391 (while (> ord 0)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
392 (setq rval (+ rval
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
393 (* (css-pow 16 (- (length x) ord))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
394 (css-unhex-char (aref x (1- ord)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
395 ord (1- ord)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
396 rval))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
397
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
398 (defmacro css-symbol-list-as-regexp (&rest keys)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
399 (` (eval-when-compile
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
400 (concat "^\\("
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
401 (mapconcat 'symbol-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
402 (quote (, keys))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
403 "\\|") "\\)$"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
404
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
405 (defun css-expand-color (color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
406 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
407 ((string-match "^#" color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
408 (let (r g b)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
409 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
410 ((string-match "^#...$" color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
411 ;; 3-char rgb spec, expand out to six chars by replicating
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
412 ;; digits, not adding zeros.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
413 (setq r (css-unhex (make-string 2 (aref color 1)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
414 g (css-unhex (make-string 2 (aref color 2)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
415 b (css-unhex (make-string 2 (aref color 3)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
416 ((string-match "^#\\(..\\)\\(..\\)\\(..\\)$" color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
417 (setq r (css-unhex (match-string 1 color))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
418 g (css-unhex (match-string 2 color))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
419 b (css-unhex (match-string 3 color))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
420 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
421 (setq color (substring color 1))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
422 (let* ((n (/ (length color) 3))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
423 (max (float (css-pow 16 n))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
424 (setq r (css-unhex (substring color 0 n))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
425 g (css-unhex (substring color n (* n 2)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
426 b (css-unhex (substring color (* n 2) (* n 3)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
427 r (round (* (/ r max) 255))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
428 g (round (* (/ g max) 255))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
429 b (round (* (/ b max) 255))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
430 (setq color (vector 'rgb r g b))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
431 ((string-match "^rgb *( *\\([0-9]+\\)[, ]+\\([0-9]+\\)[, ]+\\([0-9]+\\) *) *$" color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
432 ;; rgb(r,g,b) 0 - 255, cutting off at 255
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
433 (setq color (vector
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
434 'rgb
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
435 (min (string-to-int (match-string 1 color)) 255)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
436 (min (string-to-int (match-string 2 color)) 255)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
437 (min (string-to-int (match-string 3 color)) 255))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
438 ((string-match "^rgb *( *\\([0-9]+\\) *%[, ]+\\([0-9]+\\) *%[, ]+\\([0-9]+\\) *% *) *$" color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
439 ;; rgb(r%,g%,b%) 0 - 100%, cutting off at 100%
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
440 (let ((r (min (string-to-number (match-string 1 color)) 100.0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
441 (g (min (string-to-number (match-string 2 color)) 100.0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
442 (b (min (string-to-number (match-string 3 color)) 100.0)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
443 (setq r (round (* r 2.55))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
444 g (round (* g 2.55))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
445 b (round (* b 2.55))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
446 color (vector 'rgb r g b))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
447 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
448 ;; Hmmm... pass it through unmangled and hope the underlying
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
449 ;; windowing system can handle it.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
450 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
451 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
452 color
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
453 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
454
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
455 (defun css-expand-value (type value)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
456 (if value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
457 (case type
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
458 (length ; CSS, Section 6.1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
459 (setq value (css-expand-length value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
460 (percentage ; CSS, Section 6.2
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
461 (setq value (/ (string-to-number value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
462 (if (fboundp 'float) (float 100) 1))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
463 (color ; CSS, Section 6.3
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
464 (setq value (css-expand-color value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
465 (url ; CSS, Section 6.4
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
466 (declare (special url purl))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
467 (if (string-match "url *(\\([^ )]+\\) *)" value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
468 (setq value (match-string 1 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
469 (if (string-match " *\\([^ ]+\\) *" value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
470 (setq value (match-string 1 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
471 (setq value (url-expand-file-name value (or url purl))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
472 (angle ; ACSS, Section 2.2.1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
473 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
474 (time ; ACSS, Section 2.2.2
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
475 (let ((val (string-to-number value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
476 (units 'ms))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
477 (if (string-match "^[0-9]+ *\\([a-zA-Z.]+\\)" value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
478 (setq units (intern (downcase (match-string 1 value)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
479 (setq value (case units
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
480 ((s second seconds)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
481 val)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
482 ((min minute minutes)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
483 (* val 60))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
484 ((hr hour hours)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
485 (* val 60 60))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
486 ((day days)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
487 (* val 24 60 60))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
488 (otherwise
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
489 (/ val (float 1000)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
490 (elevation ; ACSS, Section 4.2
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
491 (if (string-match
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
492 (css-symbol-list-as-regexp below level above higher lower) value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
493 (setq value (intern (downcase (match-string value 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
494 value (case value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
495 (below -90)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
496 (above 90)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
497 (level 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
498 (higher 45)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
499 (lower -45)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
500 ))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
501 (setq value (css-expand-value 'angle value))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
502 (color-shorthand ; CSS, Section 5.3.7
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
503 ;; color|image|repeat|attach|position
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
504 (let ((keys (split-string value " +"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
505 cur color image repeat attach position)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
506 (while (setq cur (pop keys))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
507 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
508 ((string-match "url" cur) ; Only image can have a URL
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
509 (setq image (css-expand-value 'url cur)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
510 ((string-match "%" cur) ; Only position can have a perc.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
511 (setq position (css-expand-value 'percentage cur)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
512 ((string-match "repeat" cur) ; Only repeat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
513 (setq repeat (intern (downcase cur))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
514 ((string-match "scroll\\|fixed" cur)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
515 (setq attach (intern (downcase (substring cur
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
516 (match-beginning 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
517 (match-end 0))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
518 ((string-match (css-symbol-list-as-regexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
519 top center bottom left right) cur)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
520 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
521 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
522 (setq color cur))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
523 (setq value (list (cons 'background-color color)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
524 (cons 'background-image image)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
525 (cons 'background-repeat repeat)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
526 (cons 'background-attachment attach)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
527 (cons 'background-position position)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
528 (font ; CSS, Section 5.2.7
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
529 ;; [style | variant | weight]? size[/line-height]? family
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
530 (setq value (css-split-font-shorthand value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
531 (border ; width | style | color
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
532 ;; FIX
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
533 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
534 (border-shorthand ; width | style | color
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
535 ;; FIX
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
536 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
537 (list-style ; CSS, Section 5.6.6
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
538 ;; keyword | position | url
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
539 (setq value (split-string value "[ ,]+"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
540 (if (= (length value) 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
541 (setq value (list (cons 'list-style-type
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
542 (intern (downcase (car value))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
543 (setq value (list (cons 'list-style-type
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
544 (css-expand-value 'symbol (nth 0 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
545 (cons 'list-style-position
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
546 (css-expand-value 'symbol (nth 1 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
547 (cons 'list-style-image
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
548 (css-expand-value 'url (nth 2 value)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
549 (boundary-shorthand ; CSS, Section 5.5.x
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
550 ;; length|percentage|auto {1,4}
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
551 (setq value (split-string value "[ ,]+"))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
552 (let* ((top (intern (format "%s-top" type)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
553 (bottom (intern (format "%s-bottom" type)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
554 (left (intern (format "%s-left" type)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
555 (right (intern (format "%s-right" type))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
556 (setq top (cons top (css-expand-value (get top 'css-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
557 (nth 0 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
558 right (cons right (css-expand-value (get right 'css-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
559 (nth 1 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
560 bottom (cons bottom (css-expand-value (get bottom 'css-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
561 (nth 2 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
562 left (cons left (css-expand-value (get left 'css-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
563 (nth 3 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
564 value (list top right bottom left))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
565 (weight ; CSS, Section 5.2.5
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
566 ;; normal|bold|bolder|lighter|[1-9]00
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
567 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
568 ((string-match "^[0-9]+" value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
569 (setq value (/ (string-to-number value) 100)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
570 value (or (nth value css-weights) :bold)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
571 ((string-match (css-symbol-list-as-regexp normal bold bolder lighter)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
572 value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
573 (setq value (intern (downcase (concat ":" value)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
574 (t setq value (intern ":bold"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
575
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
576 ;; The rest of these deal with how we handle things internally
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
577 ((symbol integer) ; Read it in
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
578 (setq value (read (downcase value))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
579 (symbol-list ; A space/comma delimited symlist
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
580 (setq value (downcase value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
581 value (split-string value "[ ,]+")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
582 value (mapcar 'intern value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
583 (string-list ; A space/comma delimited list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
584 (setq value (split-string value " *, *")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
585 (otherwise ; Leave it as is
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
586 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
587 )
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
588 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
589 value
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
590 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
591
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
592 (defun css-parse-args (st &optional nd)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
593 ;; Return an assoc list of attribute/value pairs from a CSS style entry
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
594 (let (
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
595 name ; From name=
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
596 value ; its value
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
597 results ; Assoc list of results
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
598 name-pos ; Start of XXXX= position
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
599 val-pos ; Start of value position
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
600 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
601 (save-excursion
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
602 (if (stringp st)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
603 (progn
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
604 (set-buffer (get-buffer-create " *css-style-temp*"))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
605 (set-syntax-table css-syntax-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
606 (erase-buffer)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
607 (insert st)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
608 (setq st (point-min)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
609 nd (point-max)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
610 (set-syntax-table css-syntax-table))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
611 (save-restriction
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
612 (narrow-to-region st nd)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
613 (goto-char (point-min))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
614 (while (not (eobp))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
615 (skip-chars-forward ";, \n\t")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
616 (setq name-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
617 (skip-chars-forward "^ \n\t:=,;")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
618 (downcase-region name-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
619 (setq name (intern (buffer-substring name-pos (point))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
620 (skip-chars-forward " \t\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
621 (if (not (eq (char-after (point)) ?:)) ; There is no value
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
622 (setq value nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
623 (skip-chars-forward " \t\n:")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
624 (setq val-pos (point)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
625 value
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
626 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
627 ((or (= (or (char-after val-pos) 0) ?\")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
628 (= (or (char-after val-pos) 0) ?'))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
629 (buffer-substring (1+ val-pos)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
630 (condition-case ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
631 (prog2
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
632 (forward-sexp 1)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
633 (1- (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
634 (skip-chars-forward "\""))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
635 (error
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
636 (skip-chars-forward "^ \t\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
637 (point)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
638 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
639 (buffer-substring val-pos
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
640 (progn
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
641 (skip-chars-forward "^;")
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
642 (skip-chars-backward " \t")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
643 (point)))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
644 (setq value (css-expand-value (get name 'css-type) value))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
645 (if (get name 'css-shorthand)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
646 (setq results (append value results))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
647 (setq results (cons (cons name value) results)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
648 (skip-chars-forward ";, \n\t"))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
649 results))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
650
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
651 (defun css-handle-media-directive (data active)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
652 (let (type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
653 (if (string-match "\\([^ \t\r\n{]+\\)" data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
654 (setq type (intern (downcase (substring data (match-beginning 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
655 (match-end 1))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
656 data (substring data (match-end 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
657 (setq type 'unknown))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
658 (if (string-match "^[ \t\r\n]*{" data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
659 (setq data (substring data (match-end 0))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
660 (if (memq type active)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
661 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
662 (insert data)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
663
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
664 (defun css-handle-import (data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
665 (let (url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
666 (setq url (css-expand-value 'url data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
667 (and url
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
668 (let ((url-working-buffer (generate-new-buffer-name " *styleimport*"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
669 (url-mime-accept-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
670 "text/css ; level=2")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
671 (sheet nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
672 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
673 (set-buffer (get-buffer-create url-working-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
674 (setq url-be-asynchronous nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
675 (url-retrieve url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
676 (css-clean-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
677 (setq sheet (buffer-string))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
678 (set-buffer-modified-p nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
679 (kill-buffer (current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
680 (insert sheet)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
681
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
682 (defun css-clean-buffer ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
683 ;; Nuke comments, etc.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
684 (goto-char (point-min))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
685 (let ((save-pos nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
686 (while (search-forward "/*" nil t)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
687 (setq save-pos (- (point) 2))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
688 (delete-region save-pos
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
689 (if (search-forward "*/" nil t)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
690 (point)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
691 (end-of-line)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
692 (point)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
693 (goto-char (point-min))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
694 (delete-matching-lines "^[ \t\r]*$") ; Nuke blank lines
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
695 (css-replace-regexp "^[ \t\r]+" "") ; Nuke whitespace at beg. of line
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
696 (css-replace-regexp "[ \t\r]+$" "") ; Nuke whitespace at end of line
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
697 (goto-char (point-min)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
698
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
699 (defun css-active-device-types (&optional device)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
700 (let ((types (list 'all (if css-running-xemacs 'xemacs 'emacs)))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
701 (type (device-type device)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
702 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
703 ((featurep 'emacspeak)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
704 (setq types (cons 'speech types)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
705 ((eq type 'tty)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
706 (if (and (fboundp 'tty-color-list)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
707 (/= 0 (length (tty-color-list))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
708 (setq types (cons 'ansi-tty types))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
709 (setq types (cons 'tty types))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
710 ((eq 'color (device-class))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
711 (if (not (device-bitplanes))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
712 (setq types (cons 'color types))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
713 (setq types
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
714 (append
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
715 (list (intern (format "%dbit-color"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
716 (device-bitplanes)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
717 (intern (format "%dbit"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
718 (device-bitplanes)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
719 'color) types))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
720 (if (= 24 (device-bitplanes))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
721 (setq types (cons 'truecolor types)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
722 ((eq 'grayscale (device-class))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
723 (setq types (append (list (intern (format "%dbit-grayscale"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
724 (device-bitplanes)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
725 'grayscale)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
726 types)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
727 ((eq 'mono (device-class))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
728 (setq types (append (list 'mono 'monochrome) types)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
729 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
730 (setq types (cons 'unknown types))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
731 types))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
732
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
733 (defmacro css-rule-specificity-internal (rule)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
734 (`
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
735 (progn
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
736 (setq tmp (cdr (, rule)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
737 (if (listp tmp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
738 (while tmp
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
739 (if (= ?# (aref (car tmp) 0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
740 (incf a)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
741 (incf b))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
742 (setq tmp (cdr tmp)))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
743
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
744 (defsubst css-specificity (rule)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
745 ;; To find specificity, according to the september 1996 CSS draft
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
746 ;; a = # of ID attributes in the selector
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
747 ;; b = # of class attributes in the selector
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
748 ;; c = # of tag names in the selector
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
749 (let ((a 0) (b 0) (c 0) cur tmp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
750 (if (not (listp (car rule)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
751 (css-rule-specificity-internal rule)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
752 (setq c (length rule))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
753 (while rule
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
754 (css-rule-specificity-internal (pop rule))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
755 (+ (* 100 a) (* 10 b) c)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
756 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
757 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
758
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
759 (defun css-copy-stylesheet (sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
760 (let ((new (make-hash-table :size (hash-table-count sheet))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
761 (cl-maphash
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
762 (function
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
763 (lambda (k v)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
764 (cl-puthash k (copy-tree v) new))) sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
765 new))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
766
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
767 (defsubst css-store-rule (attrs applies-to)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
768 (declare (special sheet))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
769 (let (rules cur tag node)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
770 (while applies-to
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
771 (setq cur (pop applies-to)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
772 tag (car cur))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
773 (if (listp tag)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
774 (setq tag (car tag)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
775 (setq rules (cl-gethash tag sheet))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
776 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
777 ((null rules)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
778 ;; First rule for this tag. Create new ruleset
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
779 (cl-puthash tag (list (cons cur attrs)) sheet))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
780 ((setq node (assoc cur rules))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
781 ;; Similar rule already exists, splice in our information
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
782 (setcdr node (append attrs (cdr node))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
783 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
784 ;; First rule for this particular combination of tag/ancestors/class.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
785 ;; Slap it onto the existing set of rules and push back into sheet.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
786 (setq rules (cons (cons cur attrs) rules))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
787 (cl-puthash tag rules sheet))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
788 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
789 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
790 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
791 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
792
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
793 (defun css-parse (url &optional string inherit)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
794 (let (
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
795 (url-mime-accept-string
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
796 "text/css ; level=2")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
797 (save-pos nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
798 (applies-to nil) ; List of tags to apply style to
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
799 (attrs nil) ; List of name/value pairs
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
800 (att nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
801 (cur nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
802 (val nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
803 (device-type nil)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
804 (purl (url-view-url t))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
805 (active-device-types (css-active-device-types (selected-device)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
806 (sheet inherit))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
807 (if (not sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
808 (setq sheet (make-hash-table :size 13 :test 'eq)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
809 (save-excursion
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
810 (set-buffer (get-buffer-create
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
811 (generate-new-buffer-name " *style*")))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
812 (set-syntax-table css-syntax-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
813 (erase-buffer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
814 (if url (url-insert-file-contents url))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
815 (goto-char (point-max))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
816 (if string (insert string))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
817 (css-clean-buffer)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
818 (goto-char (point-min))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
819 (while (not (eobp))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
820 (setq save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
821 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
822 ;; *sigh* SGML comments are being used to 'hide' data inlined
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
823 ;; with the <style> tag from older browsers.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
824 ((or (looking-at "<!--+") ; begin
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
825 (looking-at "--+>")) ; end
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
826 (goto-char (match-end 0)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
827 ;; C++ style comments, and we are doing IE compatibility
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
828 ((looking-at "//")
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
829 (end-of-line))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
830 ;; Pre-Processor directives
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
831 ((looking-at "[ \t\r]*@\\([^ \t\r\n]\\)")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
832 (let (data directive)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
833 (skip-chars-forward " @\t\r") ; Past any leading whitespace
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
834 (setq save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
835 (skip-chars-forward "^ \t\r\n") ; Past the @ directive
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
836 (downcase-region save-pos (point))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
837 (setq directive (intern (buffer-substring save-pos (point))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
838 (skip-chars-forward " \t\r")
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
839 (setq save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
840 (cond
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
841 ((looking-at ".*\\({\\)")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
842 (goto-char (match-beginning 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
843 (forward-sexp 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
844 (setq data (buffer-substring save-pos (1- (point)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
845 ((looking-at "[\"']+")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
846 (setq save-pos (1+ save-pos))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
847 (forward-sexp 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
848 (setq data (buffer-substring save-pos (1- (point)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
849 (t
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
850 (skip-chars-forward "^;")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
851 (if (not data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
852 (setq data (buffer-substring save-pos (point))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
853 (setq save-pos (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
854 (case directive
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
855 (import (css-handle-import data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
856 (media (css-handle-media-directive data active-device-types))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
857 (t (message "Unknown directive in stylesheet: @%s" directive)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
858 ;; Giving us some output device information
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
859 ((looking-at "[ \t\r]*:\\([^: \n]+\\):")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
860 (message "You are using the old way of specifying device-dependent stylesheets! Please upgrade!")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
861 (sleep-for 2)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
862 (downcase-region (match-beginning 1) (match-end 1))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
863 (setq device-type (intern (buffer-substring (match-beginning 1)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
864 (match-end 1))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
865 (goto-char (match-end 0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
866 (if (not (memq device-type active-device-types))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
867 ;; Not applicable to us... skip the info
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
868 (progn
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
869 (if (re-search-forward ":[^:{ ]*:" nil t)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
870 (goto-char (match-beginning 0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
871 (goto-char (point-max))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
872 ;; Default is to treat it like a stylesheet declaration
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
873 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
874 (skip-chars-forward "^{")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
875 ;;(downcase-region save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
876 (setq applies-to (css-applies-to save-pos (point)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
877 (skip-chars-forward "^{")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
878 (setq save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
879 (condition-case ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
880 (forward-sexp 1)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
881 (error (goto-char (point-max))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
882 (end-of-line)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
883 (skip-chars-backward "\r}")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
884 (subst-char-in-region save-pos (point) ?\n ? )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
885 (subst-char-in-region save-pos (point) ?\r ? )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
886 ;; This is for not choking on garbage at the end of the buffer.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
887 ;; I get bit by this every once in a while when going through my
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
888 ;; socks gateway.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
889 (if (eobp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
890 nil
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
891 (setq attrs (css-parse-args (1+ save-pos) (point)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
892 (skip-chars-forward "}\r\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
893 (css-store-rule attrs applies-to))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
894 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
895 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
896 (skip-chars-forward " \t\r\n"))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
897 (set-buffer-modified-p nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
898 (kill-buffer (current-buffer)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
899 sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
900 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
901
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
902 ;; Tools for pretty-printing an existing stylesheet.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
903 (defun css-rule-name (rule)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
904 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
905 ((listp (car rule)) ; Contextual
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
906 (mapconcat 'css-rule-name
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
907 (reverse rule) " "))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
908 ((listp (cdr rule)) ; More than one class
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
909 (let ((classes (cdr rule))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
910 (rval (symbol-name (car rule))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
911 (while classes
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
912 (setq rval (concat rval
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
913 (if (= (aref (car classes) 0) ?:)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
914 (pop classes)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
915 (concat "." (pop classes))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
916 rval))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
917 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
918 (symbol-name (car rule)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
919
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
920 (defun css-display (sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
921 (with-output-to-temp-buffer "CSS Stylesheet"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
922 (set-buffer standard-output)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
923 (indented-text-mode)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
924 (insert "# Stylesheet auto-regenerated by css.el\n#\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
925 "# This is a mixture of the default stylesheet and any\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
926 "# styles specified by the document. The rules are in no\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
927 "# particular order.\n\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
928 (let (tmp cur goal-col)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
929 (cl-maphash
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
930 (function
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
931 (lambda (k v)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
932 (while v
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
933 (setq cur (pop v))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
934 (insert (css-rule-name (car cur)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
935 (insert " { ")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
936 (setq goal-col (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
937 (insert "\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
938 ;; Display the rules
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
939 (setq tmp (cdr cur))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
940 (let (prop val)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
941 (while tmp
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
942 (setq prop (caar tmp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
943 val (cdar tmp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
944 tmp (cdr tmp))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
945 (case (get prop 'css-type)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
946 (symbol-list
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
947 (setq val (mapconcat 'symbol-name val ",")))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
948 (weight
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
949 (setq val (substring (symbol-name val) 1 nil)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
950 (otherwise
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
951 nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
952 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
953 (insert (format " %s: %s;\n" prop val))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
954 (insert "}\n\n");
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
955 )))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
956 sheet))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
957
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
958 (provide 'css)