emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/web-mode cb0375debc: css colorization fix


From: ELPA Syncer
Subject: [nongnu] elpa/web-mode cb0375debc: css colorization fix
Date: Tue, 14 Jun 2022 10:03:33 -0400 (EDT)

branch: elpa/web-mode
commit cb0375debc928dbf926e9669ee0b942abb98385e
Author: fxbois <fxbois@gmail.com>
Commit: fxbois <fxbois@gmail.com>

    css colorization fix
    
    #1245
---
 issues/1238.css.html |  2 +-
 issues/1245.css.html | 11 +++++++++++
 web-mode.el          | 18 +++++++++++-------
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/issues/1238.css.html b/issues/1238.css.html
index e61bd347f9..84ca47e7dd 100644
--- a/issues/1238.css.html
+++ b/issues/1238.css.html
@@ -1,7 +1,7 @@
 <style>
  .black { color: #000000 }
  .silver { color: #c0c0c0 }
- .gray { color: #808080 }
+ .gray { color: #808080; background-color: red; }
  .white { color: #ffffff }
  .maroon { color: #800000 }
  .red { color: #ff0000 }
diff --git a/issues/1245.css.html b/issues/1245.css.html
new file mode 100644
index 0000000000..49c4b1ab3e
--- /dev/null
+++ b/issues/1245.css.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<html>
+  <head>
+    <style>
+     .panel {
+       color: red; color: #ff55dd;
+       box-shadow: 0 1px 2px rgba(100, 200, 33, 0.3);
+     }
+    </style>
+  </head>
+</html>
diff --git a/web-mode.el b/web-mode.el
index 6c2ff5c561..f17b12605c 100644
--- a/web-mode.el
+++ b/web-mode.el
@@ -6983,11 +6983,11 @@ Also return non-nil if it is the command 
`self-insert-command' is remapped to."
     (when (and dec-beg dec-end)
       (goto-char dec-beg)
       (while (and web-mode-enable-css-colorization
-                  (re-search-forward "\\([: 
]\\(black\\|silver\\|gray\\|white\\|maroon\\|red\\|purple\\|fuchsia\\|green\\|lime\\|olive\\|yellow\\|navy\\|blue\\|teal\\|aqua\\|orange\\|aliceblue\\|antiquewhite\\|aquamarine\\|azure\\|beige\\|bisque\\|blanchedalmond\\|blueviolet\\|brown\\|burlywood\\|cadetblue\\|chartreuse\\|chocolate\\|coral\\|cornflowerblue\\|cornsilk\\|crimson\\|cyan\\|darkblue\\|darkcyan\\|darkgoldenrod\\|darkgray\\|darkgreen\\|darkgrey\\|darkkhaki\\|darkmagenta\\|darkol
 [...]
+                  (re-search-forward 
"\\(?1:#[0-9a-fA-F]\\{6\\}\\)\\|\\(?1:#[0-9a-fA-F]\\{3\\}\\)\\|\\(?1:rgba?([ 
]*\\(?2:[[:digit:]]\\{1,3\\}\\)[ ]*,[ ]*\\(?3:[[:digit:]]\\{1,3\\}\\)[ ]*,[ 
]*\\(?4:[[:digit:]]\\{1,3\\}\\)\\(.*?\\))\\)\\|[: 
]\\(?1:black\\|silver\\|gray\\|white\\|maroon\\|red\\|purple\\|fuchsia\\|green\\|lime\\|olive\\|yellow\\|navy\\|blue\\|teal\\|aqua\\|orange\\|aliceblue\\|antiquewhite\\|aquamarine\\|azure\\|beige\\|bisque\\|blanchedalmond\\|blueviolet\\|brown\\|burlywo
 [...]
                   ;;(progn (message "%S %S" end (point)) t)
                   (<= (point) dec-end))
         ;;(message "web-mode-colorize beg=%S end=%S match=%S" (match-beginning 
0) (match-end 0) (buffer-substring-no-properties (match-beginning 0) (match-end 
0)))
-        (web-mode-colorize (match-beginning 0) (match-end 0))
+        (web-mode-colorize (match-beginning 1) (match-end 1))
         ) ;while
       ) ;when
     ;;) ;let
@@ -7002,18 +7002,22 @@ Also return non-nil if it is the command 
`self-insert-command' is remapped to."
         "white" "black")))
 
 (defun web-mode-colorize (beg end)
-  (let (str plist)
+  (let (str str1 plist)
     (setq str (buffer-substring-no-properties beg end))
-    ;;(message "%S" str)
+    ;;(setq str1 (match-string-no-properties 1))
+    ;;(message "str=%S" str str1)
     (cond
+     ;;(t
+     ;; (message "%S %S %S %S %S" (match-string-no-properties 0) 
(match-string-no-properties 1) (match-string-no-properties 2) 
(match-string-no-properties 3) (match-string-no-properties 4))
+     ;; )
      ((string= (substring str 0 1) "#")
       (setq plist (list :background str
                         :foreground (web-mode-colorize-foreground str))))
-     ((and (>= (length str) 5) (or (string= (substring str 0 4) "rgb(") 
(string= (substring str 0 5) "rgba(")))
+     ((and (>= (length str) 3) (string= (substring str 0 3) "rgb"))
       (setq str (format "#%02X%02X%02X"
-                        (string-to-number (match-string-no-properties 1))
                         (string-to-number (match-string-no-properties 2))
-                        (string-to-number (match-string-no-properties 3))))
+                        (string-to-number (match-string-no-properties 3))
+                        (string-to-number (match-string-no-properties 4))))
       (setq plist (list :background str
                         :foreground (web-mode-colorize-foreground str))))
      ((string= str "black") (setq plist (list :background "#000000" 
:foreground (web-mode-colorize-foreground "#000000"))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]