Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
25:383a494979f8 | 26:441bb1e64a06 |
---|---|
1 ;;; css.el -- Cascading Style Sheet parser | 1 ;;; css.el -- Cascading Style Sheet parser |
2 ;; Author: wmperry | 2 ;; Author: wmperry |
3 ;; Created: 1997/02/08 05:24:49 | 3 ;; Created: 1997/02/20 00:47:21 |
4 ;; Version: 1.27 | 4 ;; Version: 1.28 |
5 ;; Keywords: | 5 ;; Keywords: |
6 | 6 |
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu) | 8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu) |
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc. | 9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc. |
354 (setq height (match-string 1 font) | 354 (setq height (match-string 1 font) |
355 family (substring font (match-end 0) nil)) | 355 family (substring font (match-end 0) nil)) |
356 (if (string-match "^[ \t]+" font) | 356 (if (string-match "^[ \t]+" font) |
357 (setq family (substring font (match-end 0) nil)) | 357 (setq family (substring font (match-end 0) nil)) |
358 (setq family font))) | 358 (setq family font))) |
359 (if weight (setq retval (cons (cons 'font-weight weight) retval))) | 359 (if weight |
360 (if size (setq retval (cons (cons 'font-size size) retval))) | 360 (push (cons 'font-weight (css-expand-value 'weight weight)) retval)) |
361 (if height (setq retval (cons (cons 'line-height height) retval))) | 361 (if size |
362 (if family (setq retval (cons (cons 'font-family family) retval))) | 362 (push (cons 'font-size (css-expand-length size)) retval)) |
363 (if height | |
364 (push (cons 'line-height (css-expand-length height)) retval)) | |
365 (if family | |
366 (push (cons 'font-family (css-expand-value 'string-list family)) retval)) | |
363 retval)) | 367 retval)) |
364 | 368 |
365 (defun css-expand-length (spec) | 369 (defun css-expand-length (spec) |
366 (cond | 370 (cond |
367 ((not (stringp spec)) spec) | 371 ((not (stringp spec)) spec) |
402 (quote (, keys)) | 406 (quote (, keys)) |
403 "\\|") "\\)$")))) | 407 "\\|") "\\)$")))) |
404 | 408 |
405 (defun css-expand-color (color) | 409 (defun css-expand-color (color) |
406 (cond | 410 (cond |
411 ((string-match "^\\(transparent\\|none\\)$" color) | |
412 (setq color nil)) | |
407 ((string-match "^#" color) | 413 ((string-match "^#" color) |
408 (let (r g b) | 414 (let (r g b) |
409 (cond | 415 (cond |
410 ((string-match "^#...$" color) | 416 ((string-match "^#...$" color) |
411 ;; 3-char rgb spec, expand out to six chars by replicating | 417 ;; 3-char rgb spec, expand out to six chars by replicating |
517 (match-end 0)))))) | 523 (match-end 0)))))) |
518 ((string-match (css-symbol-list-as-regexp | 524 ((string-match (css-symbol-list-as-regexp |
519 top center bottom left right) cur) | 525 top center bottom left right) cur) |
520 ) | 526 ) |
521 (t | 527 (t |
522 (setq color cur)))) | 528 (setq color (css-expand-value 'color cur))))) |
523 (setq value (list (cons 'background-color color) | 529 (setq value (list (cons 'background-color color) |
524 (cons 'background-image image) | 530 (cons 'background-image image) |
525 (cons 'background-repeat repeat) | 531 (cons 'background-repeat repeat) |
526 (cons 'background-attachment attach) | 532 (cons 'background-attachment attach) |
527 (cons 'background-position position))))) | 533 (cons 'background-position position))))) |
528 (font ; CSS, Section 5.2.7 | 534 (font ; CSS, Section 5.2.7 |
529 ;; [style | variant | weight]? size[/line-height]? family | 535 ;; [style | variant | weight]? size[/line-height]? family |
530 (setq value (css-split-font-shorthand value))) | 536 (setq value (css-split-font-shorthand value))) |
531 (border ; width | style | color | 537 (border ; width | style | color |
532 ;; FIX | 538 ;; FIXME |
533 ) | 539 ) |
534 (border-shorthand ; width | style | color | 540 (border-shorthand ; width | style | color |
535 ;; FIX | 541 ;; FIXME |
536 ) | 542 ) |
537 (list-style ; CSS, Section 5.6.6 | 543 (list-style ; CSS, Section 5.6.6 |
538 ;; keyword | position | url | 544 ;; keyword | position | url |
539 (setq value (split-string value "[ ,]+")) | 545 (setq value (split-string value "[ ,]+")) |
540 (if (= (length value) 1) | 546 (if (= (length value) 1) |
595 name ; From name= | 601 name ; From name= |
596 value ; its value | 602 value ; its value |
597 results ; Assoc list of results | 603 results ; Assoc list of results |
598 name-pos ; Start of XXXX= position | 604 name-pos ; Start of XXXX= position |
599 val-pos ; Start of value position | 605 val-pos ; Start of value position |
606 (case-fold-search t) | |
600 ) | 607 ) |
601 (save-excursion | 608 (save-excursion |
602 (if (stringp st) | 609 (if (stringp st) |
603 (progn | 610 (progn |
604 (set-buffer (get-buffer-create " *css-style-temp*")) | 611 (set-buffer (get-buffer-create " *css-style-temp*")) |