|
71 | 71 | ;; line 52 col 5 #000000 collides with #020202 (2:59)
|
72 | 72 | ;; line 52 col 5 #000000 collides with #010101 (20:20)
|
73 | 73 |
|
74 |
| -;;;; CSS Colorguard output before 1.0.0: |
75 |
| -;; Collision: #000000, #020202 |
76 |
| -;; - rgba(0,0,0,1) (#000000) [line: 2, 3, 7, 12, 13, 16, 17, 52] is too close (0.3146196209793196) to #020202 (#020202) [line: 2] |
77 |
| -;; Collision: #000000, #010101 |
78 |
| -;; - rgba(0,0,0,1) (#000000) [line: 2, 3, 7, 12, 13, 16, 17, 52] is too close (0.15712369811016996) to #010101 (#010101) [line: 20] |
79 |
| -;; Collision: #020202, #010101 |
80 |
| -;; - #020202 (#020202) [line: 2] is too close (0.1574963682909058) to #010101 (#010101) [line: 20] |
81 |
| - |
82 | 74 |
|
83 | 75 | ;;; Code:
|
84 | 76 |
|
85 | 77 | (require 'flycheck)
|
86 | 78 |
|
87 |
| -;;;; For output before css-colorguard 1.0.0 |
88 |
| -;; (defun flycheck-parse-css-colorguard (output checker buffer) |
89 |
| -;; "Proces OUTPUT from colorguard into flycheck errors. |
90 |
| -;; CHECKER and BUFFER are returned with flycheck error." |
91 |
| -;; (let (errors) |
92 |
| -;; (dolist (line (delete "" (split-string output "Collision: "))) |
93 |
| -;; (let ((good-part (nth 1 (split-string line " - ")))) |
94 |
| -;; (let ((first-color (car (split-string good-part " \\[Line: "))) |
95 |
| -;; (second-color (car (split-string (nth 1 (split-string good-part " to ")) " \\[Line: "))) |
96 |
| -;; (line-numbers (car (split-string (nth 1 (split-string good-part " \\[Line: ")) "]"))) |
97 |
| -;; (second-line (car (split-string (nth 2 (split-string good-part " \\[Line: ")) "]"))) |
98 |
| -;; (collision (car (split-string (nth 1 (split-string good-part "]")) " to "))) |
99 |
| -;; ) |
100 |
| -;; (dolist (error-line (split-string line-numbers ", ")) |
101 |
| -;; (push (flycheck-error-new-at |
102 |
| -;; (flycheck-string-to-number-safe error-line) |
103 |
| -;; nil |
104 |
| -;; 'info |
105 |
| -;; (format "%s is too close to %s at line %s" first-color second-color second-line) |
106 |
| -;; :checker checker |
107 |
| -;; :buffer buffer) |
108 |
| -;; errors) |
109 |
| -;; (push (flycheck-error-new-at |
110 |
| -;; (flycheck-string-to-number-safe second-line) |
111 |
| -;; nil |
112 |
| -;; 'info |
113 |
| -;; (format "%s is too close to %s at line %s" second-color first-color error-line) |
114 |
| -;; :checker checker |
115 |
| -;; :buffer buffer) |
116 |
| -;; errors))))) |
117 |
| -;; (nreverse errors))) |
118 |
| - |
119 | 79 | (flycheck-define-checker css-colorguard
|
120 | 80 | "Detect similar colors in CSS using CSS Colorguard.
|
121 | 81 |
|
122 | 82 | See URL
|
123 | 83 | `https://github.com/SlexAxton/css-colorguard'."
|
124 | 84 | :command ("colorguard" "--file" source)
|
125 | 85 | ;;(option "--threshold" "3")
|
126 |
| - ;; :error-parser flycheck-parse-css-colorguard ;; For css-colorguard older then 1.0.0 |
127 | 86 | :error-patterns
|
128 | 87 | ((warning line-start
|
129 | 88 | " line " line (one-or-more " ") " col " column (one-or-more " ") (message) line-end))
|
|
0 commit comments