annotate lisp/w3/css.el @ 26:441bb1e64a06 r19-15b96

Import from CVS: tag r19-15b96
author cvs
date Mon, 13 Aug 2007 08:51:32 +0200
parents 859a2309aef8
children ec9a17fef872
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
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
3 ;; Created: 1997/02/20 00:47:21
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
4 ;; Version: 1.28
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)))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
359 (if weight
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
360 (push (cons 'font-weight (css-expand-value 'weight weight)) retval))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
361 (if size
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
362 (push (cons 'font-size (css-expand-length size)) retval))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
363 (if height
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
364 (push (cons 'line-height (css-expand-length height)) retval))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
365 (if family
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
366 (push (cons 'font-family (css-expand-value 'string-list family)) retval))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
367 retval))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
368
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
369 (defun css-expand-length (spec)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
370 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
371 ((not (stringp spec)) spec)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
372 ((string-equal spec "auto") nil)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
373 ((string-match "\\([+-]?\\([0-9]+\\|[0-9]*\\.[0-9]+\\)\\)%" spec) ; A percentage
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
374 nil)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
375 ((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
376 (max 0 (round (string-to-number (match-string 1 spec)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
377 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
378 (truncate (font-spatial-to-canonical spec)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
379 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
380 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
381
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
382 (defsubst css-unhex-char (x)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
383 (if (> x ?9)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
384 (if (>= x ?a)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
385 (+ 10 (- x ?a))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
386 (+ 10 (- x ?A)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
387 (- x ?0)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
388
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
389 (defsubst css-pow (x n)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
390 (apply '* (make-list n x)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
391
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
392 (defun css-unhex (x)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
393 (let ((ord (length x))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
394 (rval 0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
395 (while (> ord 0)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
396 (setq rval (+ rval
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
397 (* (css-pow 16 (- (length x) ord))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
398 (css-unhex-char (aref x (1- ord)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
399 ord (1- ord)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
400 rval))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
401
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
402 (defmacro css-symbol-list-as-regexp (&rest keys)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
403 (` (eval-when-compile
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
404 (concat "^\\("
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
405 (mapconcat 'symbol-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
406 (quote (, keys))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
407 "\\|") "\\)$"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
408
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
409 (defun css-expand-color (color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
410 (cond
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
411 ((string-match "^\\(transparent\\|none\\)$" color)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
412 (setq color nil))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
413 ((string-match "^#" color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
414 (let (r g b)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
415 (cond
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 ;; 3-char rgb spec, expand out to six chars by replicating
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
418 ;; digits, not adding zeros.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
419 (setq r (css-unhex (make-string 2 (aref color 1)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
420 g (css-unhex (make-string 2 (aref color 2)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
421 b (css-unhex (make-string 2 (aref color 3)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
422 ((string-match "^#\\(..\\)\\(..\\)\\(..\\)$" color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
423 (setq r (css-unhex (match-string 1 color))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
424 g (css-unhex (match-string 2 color))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
425 b (css-unhex (match-string 3 color))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
426 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
427 (setq color (substring color 1))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
428 (let* ((n (/ (length color) 3))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
429 (max (float (css-pow 16 n))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
430 (setq r (css-unhex (substring color 0 n))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
431 g (css-unhex (substring color n (* n 2)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
432 b (css-unhex (substring color (* n 2) (* n 3)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
433 r (round (* (/ r max) 255))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
434 g (round (* (/ g max) 255))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
435 b (round (* (/ b max) 255))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
436 (setq color (vector 'rgb r g b))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
437 ((string-match "^rgb *( *\\([0-9]+\\)[, ]+\\([0-9]+\\)[, ]+\\([0-9]+\\) *) *$" color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
438 ;; rgb(r,g,b) 0 - 255, cutting off at 255
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
439 (setq color (vector
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
440 'rgb
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
441 (min (string-to-int (match-string 1 color)) 255)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
442 (min (string-to-int (match-string 2 color)) 255)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
443 (min (string-to-int (match-string 3 color)) 255))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
444 ((string-match "^rgb *( *\\([0-9]+\\) *%[, ]+\\([0-9]+\\) *%[, ]+\\([0-9]+\\) *% *) *$" color)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
445 ;; rgb(r%,g%,b%) 0 - 100%, cutting off at 100%
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
446 (let ((r (min (string-to-number (match-string 1 color)) 100.0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
447 (g (min (string-to-number (match-string 2 color)) 100.0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
448 (b (min (string-to-number (match-string 3 color)) 100.0)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
449 (setq r (round (* r 2.55))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
450 g (round (* g 2.55))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
451 b (round (* b 2.55))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
452 color (vector 'rgb r g b))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
453 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
454 ;; Hmmm... pass it through unmangled and hope the underlying
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
455 ;; windowing system can handle it.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
456 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
457 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
458 color
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
459 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
460
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
461 (defun css-expand-value (type value)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
462 (if value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
463 (case type
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
464 (length ; CSS, Section 6.1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
465 (setq value (css-expand-length value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
466 (percentage ; CSS, Section 6.2
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
467 (setq value (/ (string-to-number value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
468 (if (fboundp 'float) (float 100) 1))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
469 (color ; CSS, Section 6.3
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
470 (setq value (css-expand-color value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
471 (url ; CSS, Section 6.4
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
472 (declare (special url purl))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
473 (if (string-match "url *(\\([^ )]+\\) *)" value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
474 (setq value (match-string 1 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
475 (if (string-match " *\\([^ ]+\\) *" value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
476 (setq value (match-string 1 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
477 (setq value (url-expand-file-name value (or url purl))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
478 (angle ; ACSS, Section 2.2.1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
479 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
480 (time ; ACSS, Section 2.2.2
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
481 (let ((val (string-to-number value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
482 (units 'ms))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
483 (if (string-match "^[0-9]+ *\\([a-zA-Z.]+\\)" value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
484 (setq units (intern (downcase (match-string 1 value)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
485 (setq value (case units
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
486 ((s second seconds)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
487 val)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
488 ((min minute minutes)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
489 (* val 60))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
490 ((hr hour hours)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
491 (* val 60 60))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
492 ((day days)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
493 (* val 24 60 60))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
494 (otherwise
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
495 (/ val (float 1000)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
496 (elevation ; ACSS, Section 4.2
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
497 (if (string-match
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
498 (css-symbol-list-as-regexp below level above higher lower) value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
499 (setq value (intern (downcase (match-string value 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
500 value (case value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
501 (below -90)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
502 (above 90)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
503 (level 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
504 (higher 45)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
505 (lower -45)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
506 ))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
507 (setq value (css-expand-value 'angle value))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
508 (color-shorthand ; CSS, Section 5.3.7
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
509 ;; color|image|repeat|attach|position
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
510 (let ((keys (split-string value " +"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
511 cur color image repeat attach position)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
512 (while (setq cur (pop keys))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
513 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
514 ((string-match "url" cur) ; Only image can have a URL
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
515 (setq image (css-expand-value 'url cur)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
516 ((string-match "%" cur) ; Only position can have a perc.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
517 (setq position (css-expand-value 'percentage cur)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
518 ((string-match "repeat" cur) ; Only repeat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
519 (setq repeat (intern (downcase cur))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
520 ((string-match "scroll\\|fixed" cur)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
521 (setq attach (intern (downcase (substring cur
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
522 (match-beginning 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
523 (match-end 0))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
524 ((string-match (css-symbol-list-as-regexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
525 top center bottom left right) cur)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
526 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
527 (t
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
528 (setq color (css-expand-value 'color cur)))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
529 (setq value (list (cons 'background-color color)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
530 (cons 'background-image image)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
531 (cons 'background-repeat repeat)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
532 (cons 'background-attachment attach)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
533 (cons 'background-position position)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
534 (font ; CSS, Section 5.2.7
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
535 ;; [style | variant | weight]? size[/line-height]? family
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
536 (setq value (css-split-font-shorthand value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
537 (border ; width | style | color
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
538 ;; FIXME
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
539 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
540 (border-shorthand ; width | style | color
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
541 ;; FIXME
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
542 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
543 (list-style ; CSS, Section 5.6.6
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
544 ;; keyword | position | url
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
545 (setq value (split-string value "[ ,]+"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
546 (if (= (length value) 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
547 (setq value (list (cons 'list-style-type
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
548 (intern (downcase (car value))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
549 (setq value (list (cons 'list-style-type
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
550 (css-expand-value 'symbol (nth 0 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
551 (cons 'list-style-position
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
552 (css-expand-value 'symbol (nth 1 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
553 (cons 'list-style-image
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
554 (css-expand-value 'url (nth 2 value)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
555 (boundary-shorthand ; CSS, Section 5.5.x
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
556 ;; length|percentage|auto {1,4}
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
557 (setq value (split-string value "[ ,]+"))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
558 (let* ((top (intern (format "%s-top" type)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
559 (bottom (intern (format "%s-bottom" type)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
560 (left (intern (format "%s-left" type)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
561 (right (intern (format "%s-right" type))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
562 (setq top (cons top (css-expand-value (get top 'css-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
563 (nth 0 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
564 right (cons right (css-expand-value (get right 'css-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
565 (nth 1 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
566 bottom (cons bottom (css-expand-value (get bottom 'css-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
567 (nth 2 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
568 left (cons left (css-expand-value (get left 'css-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
569 (nth 3 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
570 value (list top right bottom left))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
571 (weight ; CSS, Section 5.2.5
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
572 ;; normal|bold|bolder|lighter|[1-9]00
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
573 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
574 ((string-match "^[0-9]+" value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
575 (setq value (/ (string-to-number value) 100)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
576 value (or (nth value css-weights) :bold)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
577 ((string-match (css-symbol-list-as-regexp normal bold bolder lighter)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
578 value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
579 (setq value (intern (downcase (concat ":" value)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
580 (t setq value (intern ":bold"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
581
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
582 ;; The rest of these deal with how we handle things internally
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
583 ((symbol integer) ; Read it in
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
584 (setq value (read (downcase value))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
585 (symbol-list ; A space/comma delimited symlist
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
586 (setq value (downcase value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
587 value (split-string value "[ ,]+")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
588 value (mapcar 'intern value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
589 (string-list ; A space/comma delimited list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
590 (setq value (split-string value " *, *")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
591 (otherwise ; Leave it as is
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
592 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
593 )
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
594 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
595 value
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
596 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
597
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
598 (defun css-parse-args (st &optional nd)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
599 ;; Return an assoc list of attribute/value pairs from a CSS style entry
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
600 (let (
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
601 name ; From name=
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
602 value ; its value
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
603 results ; Assoc list of results
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
604 name-pos ; Start of XXXX= position
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
605 val-pos ; Start of value position
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 20
diff changeset
606 (case-fold-search t)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
607 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
608 (save-excursion
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
609 (if (stringp st)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
610 (progn
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
611 (set-buffer (get-buffer-create " *css-style-temp*"))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
612 (set-syntax-table css-syntax-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
613 (erase-buffer)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
614 (insert st)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
615 (setq st (point-min)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
616 nd (point-max)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
617 (set-syntax-table css-syntax-table))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
618 (save-restriction
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
619 (narrow-to-region st nd)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
620 (goto-char (point-min))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
621 (while (not (eobp))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
622 (skip-chars-forward ";, \n\t")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
623 (setq name-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
624 (skip-chars-forward "^ \n\t:=,;")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
625 (downcase-region name-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
626 (setq name (intern (buffer-substring name-pos (point))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
627 (skip-chars-forward " \t\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
628 (if (not (eq (char-after (point)) ?:)) ; There is no value
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
629 (setq value nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
630 (skip-chars-forward " \t\n:")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
631 (setq val-pos (point)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
632 value
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
633 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
634 ((or (= (or (char-after val-pos) 0) ?\")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
635 (= (or (char-after val-pos) 0) ?'))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
636 (buffer-substring (1+ val-pos)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
637 (condition-case ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
638 (prog2
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
639 (forward-sexp 1)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
640 (1- (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
641 (skip-chars-forward "\""))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
642 (error
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
643 (skip-chars-forward "^ \t\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
644 (point)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
645 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
646 (buffer-substring val-pos
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
647 (progn
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
648 (skip-chars-forward "^;")
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
649 (skip-chars-backward " \t")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
650 (point)))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
651 (setq value (css-expand-value (get name 'css-type) value))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
652 (if (get name 'css-shorthand)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
653 (setq results (append value results))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
654 (setq results (cons (cons name value) results)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
655 (skip-chars-forward ";, \n\t"))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
656 results))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
657
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
658 (defun css-handle-media-directive (data active)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
659 (let (type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
660 (if (string-match "\\([^ \t\r\n{]+\\)" data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
661 (setq type (intern (downcase (substring data (match-beginning 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
662 (match-end 1))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
663 data (substring data (match-end 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
664 (setq type 'unknown))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
665 (if (string-match "^[ \t\r\n]*{" data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
666 (setq data (substring data (match-end 0))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
667 (if (memq type active)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
668 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
669 (insert data)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
670
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
671 (defun css-handle-import (data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
672 (let (url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
673 (setq url (css-expand-value 'url data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
674 (and url
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
675 (let ((url-working-buffer (generate-new-buffer-name " *styleimport*"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
676 (url-mime-accept-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
677 "text/css ; level=2")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
678 (sheet nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
679 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
680 (set-buffer (get-buffer-create url-working-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
681 (setq url-be-asynchronous nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
682 (url-retrieve url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
683 (css-clean-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
684 (setq sheet (buffer-string))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
685 (set-buffer-modified-p nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
686 (kill-buffer (current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
687 (insert sheet)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
688
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
689 (defun css-clean-buffer ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
690 ;; Nuke comments, etc.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
691 (goto-char (point-min))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
692 (let ((save-pos nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
693 (while (search-forward "/*" nil t)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
694 (setq save-pos (- (point) 2))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
695 (delete-region save-pos
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
696 (if (search-forward "*/" nil t)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
697 (point)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
698 (end-of-line)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
699 (point)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
700 (goto-char (point-min))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
701 (delete-matching-lines "^[ \t\r]*$") ; Nuke blank lines
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
702 (css-replace-regexp "^[ \t\r]+" "") ; Nuke whitespace at beg. of line
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
703 (css-replace-regexp "[ \t\r]+$" "") ; Nuke whitespace at end of line
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
704 (goto-char (point-min)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
705
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
706 (defun css-active-device-types (&optional device)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
707 (let ((types (list 'all (if css-running-xemacs 'xemacs 'emacs)))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
708 (type (device-type device)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
709 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
710 ((featurep 'emacspeak)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
711 (setq types (cons 'speech types)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
712 ((eq type 'tty)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
713 (if (and (fboundp 'tty-color-list)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
714 (/= 0 (length (tty-color-list))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
715 (setq types (cons 'ansi-tty types))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
716 (setq types (cons 'tty types))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
717 ((eq 'color (device-class))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
718 (if (not (device-bitplanes))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
719 (setq types (cons 'color types))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
720 (setq types
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
721 (append
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
722 (list (intern (format "%dbit-color"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
723 (device-bitplanes)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
724 (intern (format "%dbit"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
725 (device-bitplanes)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
726 'color) types))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
727 (if (= 24 (device-bitplanes))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
728 (setq types (cons 'truecolor types)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
729 ((eq 'grayscale (device-class))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
730 (setq types (append (list (intern (format "%dbit-grayscale"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
731 (device-bitplanes)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
732 'grayscale)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
733 types)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
734 ((eq 'mono (device-class))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
735 (setq types (append (list 'mono 'monochrome) types)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
736 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
737 (setq types (cons 'unknown types))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
738 types))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
739
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
740 (defmacro css-rule-specificity-internal (rule)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
741 (`
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
742 (progn
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
743 (setq tmp (cdr (, rule)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
744 (if (listp tmp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
745 (while tmp
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
746 (if (= ?# (aref (car tmp) 0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
747 (incf a)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
748 (incf b))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
749 (setq tmp (cdr tmp)))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
750
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
751 (defsubst css-specificity (rule)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
752 ;; To find specificity, according to the september 1996 CSS draft
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
753 ;; a = # of ID attributes in the selector
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
754 ;; b = # of class attributes in the selector
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
755 ;; c = # of tag names in the selector
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
756 (let ((a 0) (b 0) (c 0) cur tmp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
757 (if (not (listp (car rule)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
758 (css-rule-specificity-internal rule)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
759 (setq c (length rule))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
760 (while rule
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
761 (css-rule-specificity-internal (pop rule))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
762 (+ (* 100 a) (* 10 b) c)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
763 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
764 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
765
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
766 (defun css-copy-stylesheet (sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
767 (let ((new (make-hash-table :size (hash-table-count sheet))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
768 (cl-maphash
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
769 (function
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
770 (lambda (k v)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
771 (cl-puthash k (copy-tree v) new))) sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
772 new))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
773
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
774 (defsubst css-store-rule (attrs applies-to)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
775 (declare (special sheet))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
776 (let (rules cur tag node)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
777 (while applies-to
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
778 (setq cur (pop applies-to)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
779 tag (car cur))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
780 (if (listp tag)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
781 (setq tag (car tag)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
782 (setq rules (cl-gethash tag sheet))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
783 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
784 ((null rules)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
785 ;; First rule for this tag. Create new ruleset
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
786 (cl-puthash tag (list (cons cur attrs)) sheet))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
787 ((setq node (assoc cur rules))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
788 ;; Similar rule already exists, splice in our information
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
789 (setcdr node (append attrs (cdr node))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
790 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
791 ;; First rule for this particular combination of tag/ancestors/class.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
792 ;; Slap it onto the existing set of rules and push back into sheet.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
793 (setq rules (cons (cons cur attrs) rules))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
794 (cl-puthash tag rules sheet))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
795 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
796 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
797 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
798 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
799
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
800 (defun css-parse (url &optional string inherit)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
801 (let (
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
802 (url-mime-accept-string
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
803 "text/css ; level=2")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
804 (save-pos nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
805 (applies-to nil) ; List of tags to apply style to
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
806 (attrs nil) ; List of name/value pairs
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
807 (att nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
808 (cur nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
809 (val nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
810 (device-type nil)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
811 (purl (url-view-url t))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
812 (active-device-types (css-active-device-types (selected-device)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
813 (sheet inherit))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
814 (if (not sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
815 (setq sheet (make-hash-table :size 13 :test 'eq)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
816 (save-excursion
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
817 (set-buffer (get-buffer-create
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
818 (generate-new-buffer-name " *style*")))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
819 (set-syntax-table css-syntax-table)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
820 (erase-buffer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
821 (if url (url-insert-file-contents url))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
822 (goto-char (point-max))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
823 (if string (insert string))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
824 (css-clean-buffer)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
825 (goto-char (point-min))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
826 (while (not (eobp))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
827 (setq save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
828 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
829 ;; *sigh* SGML comments are being used to 'hide' data inlined
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
830 ;; with the <style> tag from older browsers.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
831 ((or (looking-at "<!--+") ; begin
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
832 (looking-at "--+>")) ; end
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
833 (goto-char (match-end 0)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
834 ;; C++ style comments, and we are doing IE compatibility
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
835 ((looking-at "//")
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
836 (end-of-line))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
837 ;; Pre-Processor directives
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
838 ((looking-at "[ \t\r]*@\\([^ \t\r\n]\\)")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
839 (let (data directive)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
840 (skip-chars-forward " @\t\r") ; Past any leading whitespace
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
841 (setq save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
842 (skip-chars-forward "^ \t\r\n") ; Past the @ directive
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
843 (downcase-region save-pos (point))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
844 (setq directive (intern (buffer-substring save-pos (point))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
845 (skip-chars-forward " \t\r")
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
846 (setq save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
847 (cond
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
848 ((looking-at ".*\\({\\)")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
849 (goto-char (match-beginning 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
850 (forward-sexp 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
851 (setq data (buffer-substring save-pos (1- (point)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
852 ((looking-at "[\"']+")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
853 (setq save-pos (1+ save-pos))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
854 (forward-sexp 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
855 (setq data (buffer-substring save-pos (1- (point)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
856 (t
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
857 (skip-chars-forward "^;")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
858 (if (not data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
859 (setq data (buffer-substring save-pos (point))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
860 (setq save-pos (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
861 (case directive
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
862 (import (css-handle-import data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
863 (media (css-handle-media-directive data active-device-types))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
864 (t (message "Unknown directive in stylesheet: @%s" directive)))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
865 ;; Giving us some output device information
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
866 ((looking-at "[ \t\r]*:\\([^: \n]+\\):")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
867 (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
868 (sleep-for 2)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
869 (downcase-region (match-beginning 1) (match-end 1))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
870 (setq device-type (intern (buffer-substring (match-beginning 1)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
871 (match-end 1))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
872 (goto-char (match-end 0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
873 (if (not (memq device-type active-device-types))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
874 ;; Not applicable to us... skip the info
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
875 (progn
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
876 (if (re-search-forward ":[^:{ ]*:" nil t)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
877 (goto-char (match-beginning 0))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
878 (goto-char (point-max))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
879 ;; Default is to treat it like a stylesheet declaration
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
880 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
881 (skip-chars-forward "^{")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
882 ;;(downcase-region save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
883 (setq applies-to (css-applies-to save-pos (point)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
884 (skip-chars-forward "^{")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
885 (setq save-pos (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
886 (condition-case ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
887 (forward-sexp 1)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
888 (error (goto-char (point-max))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
889 (end-of-line)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
890 (skip-chars-backward "\r}")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
891 (subst-char-in-region save-pos (point) ?\n ? )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
892 (subst-char-in-region save-pos (point) ?\r ? )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
893 ;; This is for not choking on garbage at the end of the buffer.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
894 ;; 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
895 ;; socks gateway.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
896 (if (eobp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
897 nil
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
898 (setq attrs (css-parse-args (1+ save-pos) (point)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
899 (skip-chars-forward "}\r\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
900 (css-store-rule attrs applies-to))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
901 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
902 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
903 (skip-chars-forward " \t\r\n"))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
904 (set-buffer-modified-p nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
905 (kill-buffer (current-buffer)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
906 sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
907 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
908
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
909 ;; Tools for pretty-printing an existing stylesheet.
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
910 (defun css-rule-name (rule)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
911 (cond
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
912 ((listp (car rule)) ; Contextual
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
913 (mapconcat 'css-rule-name
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
914 (reverse rule) " "))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
915 ((listp (cdr rule)) ; More than one class
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
916 (let ((classes (cdr rule))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
917 (rval (symbol-name (car rule))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
918 (while classes
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
919 (setq rval (concat rval
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
920 (if (= (aref (car classes) 0) ?:)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
921 (pop classes)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
922 (concat "." (pop classes))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
923 rval))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
924 (t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
925 (symbol-name (car rule)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
926
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
927 (defun css-display (sheet)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
928 (with-output-to-temp-buffer "CSS Stylesheet"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
929 (set-buffer standard-output)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
930 (indented-text-mode)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
931 (insert "# Stylesheet auto-regenerated by css.el\n#\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
932 "# This is a mixture of the default stylesheet and any\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
933 "# styles specified by the document. The rules are in no\n"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
934 "# particular order.\n\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
935 (let (tmp cur goal-col)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
936 (cl-maphash
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
937 (function
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
938 (lambda (k v)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
939 (while v
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
940 (setq cur (pop v))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
941 (insert (css-rule-name (car cur)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
942 (insert " { ")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
943 (setq goal-col (point))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
944 (insert "\n")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
945 ;; Display the rules
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
946 (setq tmp (cdr cur))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
947 (let (prop val)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
948 (while tmp
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
949 (setq prop (caar tmp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
950 val (cdar tmp)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
951 tmp (cdr tmp))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
952 (case (get prop 'css-type)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
953 (symbol-list
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
954 (setq val (mapconcat 'symbol-name val ",")))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
955 (weight
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
956 (setq val (substring (symbol-name val) 1 nil)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
957 (otherwise
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
958 nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
959 )
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
960 (insert (format " %s: %s;\n" prop val))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
961 (insert "}\n\n");
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
962 )))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
963 sheet))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
964
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents:
diff changeset
965 (provide 'css)