Created
October 1, 2009 04:10
-
-
Save tyler/198723 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defconst css2-tags | |
'("a" "abbr" "acronym" "address" "applet" "area" "b" | |
"base" "basefont" "bdo" "big" "blockquote" "body" "br" | |
"button" "caption" "center" "cite" "code" "col" | |
"colgroup" "dd" "del" "dfn" "dir" "div" "dl" "dt" "em" | |
"fieldset" "font" "form" "frame" "frameset" "h1" "h2" | |
"h3" "h4" "h5" "h6" "head" "hr" "html" "i" "iframe" | |
"img" "input" "ins" "isindex" "kbd" "label" "legend" | |
"li" "link" "map" "menu" "meta" "noframes" "noscript" | |
"object" "ol" "optgroup" "option" "p" "param" "pre" "q" | |
"s" "samp" "script" "select" "small" "span" "strike" | |
"strong" "style" "sub" "sup" "table" "tbody" "td" | |
"textarea" "tfoot" "th" "thead" "title" "tr" "tt" "u" | |
"ul" "var" "*") | |
"Valid tags for use in CSS selectors") | |
(defconst css2-attributes | |
'("azimuth" "background" "background-attachment" "background-color" | |
"background-image" "background-position" "background-repeat" | |
"border" "border-collapse" "border-color" "border-spacing" | |
"border-style" "border-top" "border-right" "border-bottom" | |
"border-left" "border-top-color" "border-right-color" | |
"border-bottom-color" "border-left-color" "border-top-style" | |
"border-right-style" "border-bottom-style" "border-left-style" | |
"border-top-width" "border-right-width" "border-bottom-width" | |
"border-left-width" "border-width" "bottom" "caption-side" | |
"clear" "clip" "color" "content" "counter-increment" | |
"counter-reset" "cue" "cue-after" "cue-before" "cursor" | |
"direction" "display" "elevation" "empty-cells" "float" "font" | |
"font-family" "font-size" "font-size-adjust" "font-stretch" | |
"font-style" "font-variant" "font-weight" "height" "left" | |
"letter-spacing" "line-height" "list-style" "list-style-image" | |
"list-style-position" "list-style-type" "margin" "margin-top" | |
"margin-right" "margin-bottom" "margin-left" "marker-offset" | |
"marks" "max-height" "max-width" "min-height" "min-width" | |
"orphans" "outline" "outline-color" "outline-style" | |
"outline-width" "overflow" "padding" "padding-top" | |
"padding-right" "padding-bottom" "padding-left" "page" | |
"page-break-after" "page-break-before" "page-break-inside" | |
"pause" "pause-after" "pause-before" "pitch" "pitch-range" | |
"play-during" "position" "quotes" "richness" "right" "size" | |
"speak" "speak-header" "speak-numeral" "speak-punctuation" | |
"speech-rate" "stress" "table-layout" "text-align" | |
"text-decoration" "text-indent" "text-shadow" "text-transform" | |
"top" "unicode-bidi" "vertical-align" "visibility" "voice-family" | |
"volume" "white-space" "widows" "width" "word-spacing" | |
"z-index" "-moz-border-radius" "-webkit-border-radius" | |
"-webkit-border-top-left-radius" "-webkit-border-top-right-radius" | |
"-webkit-border-bottom-left-radius" "-webkit-border-bottom-right-radius" | |
"-moz-border-top-left-radius" "-moz-border-top-right-radius" | |
"-moz-border-bottom-left-radius" "-moz-border-bottom-right-radius" | |
"position" "filter") | |
"Attributes used inside CSS rulesets") | |
(defconst css2-combinators | |
'("+" "~" ">") | |
"Combinator symbols that combine CSS selectors") | |
(defconst css2-pseudo-classes | |
'("before" "after" "hover" "active" "first-child" "first-line" | |
"first-letter" "focus" "not" "root" "target" "enabled" | |
"disabled" "checked" "empty" "last-child" "nth-child" | |
"nth-of-type" "visited" ":selection") | |
"Pseudo classes that modify CSS selectors") | |
(defconst css2-operators | |
'("." "#" ":") | |
"Operators that occur inside CSS selectors") | |
;(defface css2-face-comment | |
; '((((class grayscale)) (:foreground "Gray")) | |
; (((class color)) (:foreground "Purple")) | |
; (t (:bold nil))) | |
; "Font Lock face used to highlight tags." | |
; :group 'css2-font-lock-faces) | |
;(defconst css2-face-comment 'css2-face-comment) | |
(defface css2-face-tag | |
'((((class grayscale)) (:foreground "LightGray")) | |
(((class color)) (:foreground "LightSalmon")) | |
(t (:bold nil))) | |
"Font Lock face used to highlight tags." | |
:group 'css2-font-lock-faces) | |
(defconst css2-face-tag 'css2-face-tag) | |
(defface css2-face-attr | |
'((((class grayscale)) (:foreground "LightGray")) | |
(((class color)) (:foreground "RosyBrown2")) | |
(t (:bold nil))) | |
"Font Lock face used to highlight attrs." | |
:group 'css2-font-lock-faces) | |
(defconst css2-face-attr 'css2-face-attr) | |
(defface css2-face-rule-divider | |
'((((class grayscale)) (:foreground "LightGray")) | |
(((class color)) (:foreground "Thistle3")) | |
(t (:bold nil))) | |
"Font Lock face used to highlight attrs." | |
:group 'css2-font-lock-faces) | |
(defconst css2-face-rule-divider 'css2-face-rule-divider) | |
(defface css2-face-rule-value | |
'((((class grayscale)) (:foreground "LightGray")) | |
(((class color)) (:foreground "Thistle1")) | |
(t (:bold nil))) | |
"Font Lock face used to highlight attrs." | |
:group 'css2-font-lock-faces) | |
(defconst css2-face-rule-value 'css2-face-rule-value) | |
(defface css2-face-rule-ending | |
'((((class grayscale)) (:foreground "LightGray")) | |
(((class color)) (:foreground "Thistle4")) | |
(t (:bold nil))) | |
"Font Lock face used to highlight attrs." | |
:group 'css2-font-lock-faces) | |
(defconst css2-face-rule-ending 'css2-face-rule-ending) | |
;(defface css2-face-combinator | |
; '((((class grayscale)) (:foreground "LightGray")) | |
; (((class color)) (:foreground "LightSalmon")) | |
; (t (:bold nil))) | |
; "Font Lock face used to highlight combinators." | |
; :group 'css2-font-lock-faces) | |
;(defconst css2-face-combinator 'css2-face-combinator) | |
(defface css2-face-pseudo | |
'((((class grayscale)) (:foreground "LightGray")) | |
(((class color)) (:foreground "light goldenrod")) | |
(t (:bold nil))) | |
"Font Lock face used to highlight pseudos." | |
:group 'css2-font-lock-faces) | |
(defconst css2-face-pseudo 'css2-face-pseudo) | |
(defface css2-face-operator | |
'((((class grayscale)) (:foreground "Black")) | |
(((class color)) (:foreground "Aquamarine")) | |
(t (:bold nil))) | |
"Font Lock face used to highlight operators." | |
:group 'css2-font-lock-faces) | |
(defconst css2-face-operator 'css2-face-operator) | |
(defface css2-face-class | |
'((((class grayscale)) (:foreground "Black")) | |
(((class color)) (:foreground "SteelBlue1")) | |
(t (:bold nil))) | |
"Font Lock face used to highlight operators." | |
:group 'css2-font-lock-faces) | |
(defconst css2-face-class 'css2-face-class) | |
(defface css2-face-id | |
'((((class grayscale)) (:foreground "Black")) | |
(((class color)) (:foreground "LightSkyBlue2")) | |
(t (:bold nil))) | |
"Font Lock face used to highlight operators." | |
:group 'css2-font-lock-faces) | |
(defconst css2-face-id 'css2-face-id) | |
(defvar css2-font-lock-keywords | |
(list | |
`(,(format "\\(%s\\)[ \t]*:[ \t]*.+;" | |
(regexp-opt css2-attributes)) 1 css2-face-attr) | |
`(,(format "\\(%s\\)[ \t]*\\(:\\)[ \t]*.+;" | |
(regexp-opt css2-attributes)) 2 css2-face-rule-divider) | |
`(,(format "\\(%s\\)[ \t]*:[ \t]*\\(.+\\);" | |
(regexp-opt css2-attributes)) 2 css2-face-rule-value) | |
`(,(format "\\(%s\\)[ \t]*:[ \t]*.+\\(;\\)" | |
(regexp-opt css2-attributes)) 2 css2-face-rule-ending) | |
`(,(format "\\(^\\|[ \t]\\|%s\\)\\(%s\\)" | |
(regexp-opt css2-tags) | |
(regexp-opt css2-operators)) 2 css2-face-operator) | |
`(,(format "\\b\\(%s\\):\\(%s\\)" | |
(regexp-opt css2-tags) | |
(regexp-opt css2-pseudo-classes)) 2 css2-face-pseudo) | |
`(,(format "\\(\\.\\)\\(\\(\\w\\|_\\|-\\)+\\)" | |
(regexp-opt css2-operators)) 2 css2-face-class) | |
`(,(format "\\(#\\)\\(\\(\\w\\|_\\|-\\)+\\)" | |
(regexp-opt css2-operators)) 2 css2-face-id) | |
`(,(format "\\b\\(%s\\)\\(,\\| \\|%s\\|:\\)" | |
(regexp-opt css2-tags) | |
(regexp-opt css2-operators)) 1 css2-face-tag) | |
;`(,(format "\\(%s\\)" (regexp-opt css2-attributes)) 1 css2-face-attr) | |
;`(,(format "\\(%s\\)" (regexp-opt css2-combinators)) 1 css2-face-combinator) | |
) | |
"Highlighting for CSS Mode") | |
(defvar css2-mode-hook nil) | |
(defvar css2-mode-syntax-table | |
(let ((st (make-syntax-table))) | |
(modify-syntax-entry ?\{ "(}" st) | |
(modify-syntax-entry ?\} "){" st) | |
st)) | |
(define-derived-mode css2-mode fundamental-mode "CSS2" | |
"A major mode for editing CSS files." | |
:syntax-table css2-mode-syntax-table | |
(set (make-local-variable 'font-lock-defaults) '(css2-font-lock-keywords))) | |
(run-hooks 'css2-mode-hook) | |
(provide 'css2-mode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment