]> code.delx.au - gnu-emacs/commitdiff
Disallow parenthesis in non-pseudo CSS selectors
authorSimen Heggestøyl <simenheg@gmail.com>
Thu, 14 Jan 2016 18:24:03 +0000 (19:24 +0100)
committerSimen Heggestøyl <simenheg@gmail.com>
Thu, 14 Jan 2016 18:24:03 +0000 (19:24 +0100)
* lisp/textmodes/css-mode.el (css--font-lock-keywords): Disallow
parenthesis in selectors except for in the function notation that
might appear right after a pseudo-class.
* test/indent/scss-mode.scss: Add a test for it.

lisp/textmodes/css-mode.el
test/indent/scss-mode.scss

index 48c24844a683fb4600d42ba77e1036dd6604c720..d402fb199559bed6e51545abe6d3cbf729aba5de 100644 (file)
        (if (not sassy)
            ;; We don't allow / as first char, so as not to
            ;; take a comment as the beginning of a selector.
-           "[^@/:{} \t\n][^:{}]+"
+           "[^@/:{}() \t\n][^:{}()]+"
          ;; Same as for non-sassy except we do want to allow { and }
          ;; chars in selectors in the case of #{$foo}
          ;; variable interpolation!
          (concat "\\(?:" scss--hash-re
-                 "\\|[^@/:{} \t\n#]\\)"
-                 "[^:{}#]*\\(?:" scss--hash-re "[^:{}#]*\\)*"))
+                 "\\|[^@/:{}() \t\n#]\\)"
+                 "[^:{}()#]*\\(?:" scss--hash-re "[^:{}()#]*\\)*"))
        ;; Even though pseudo-elements should be prefixed by ::, a
        ;; single colon is accepted for backward compatibility.
        "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
        "\\|\\::" (regexp-opt css-pseudo-element-ids t) "\\)"
        "\\(?:([^)]+)\\)?"
        (if (not sassy)
-           "[^:{}\n]*"
-         (concat "[^:{}\n#]*\\(?:" scss--hash-re "[^:{}\n#]*\\)*"))
+           "[^:{}()\n]*"
+         (concat "[^:{}()\n#]*\\(?:" scss--hash-re "[^:{}()\n#]*\\)*"))
        "\\)*"
        "\\)\\(?:\n[ \t]*\\)*{")
      (1 'css-selector keep))
index 7a29929efcac552a6a116f591c310c5885ee5f1e..02a4a98a8c57d6fbe72c2e9d943a229bae58dbdb 100644 (file)
@@ -55,3 +55,13 @@ article[role="main"] {
 }
 
 .box { @include border-radius(10px); }
+
+// bug:21230
+$list: (
+   ('a', #000000, #fff)
+   ('b', #000000, #fff)
+   ('c', #000000, #fff)
+   ('d', #000000, #fff)
+   ('e', #000000, #fff)
+   ('f', #000000, #fff)
+);