Commits

Anonymous committed 0090a54

Fix at-rule handling in the CSS lexer.

Comments (0)

Files changed (3)

 
 - Fixes in the IRC and MuPad lexers.
 
+- Fix at-rule handling in the CSS lexer.
+
 - Handle KeyboardInterrupts gracefully in pygmentize.
 
 - Added BlackWhiteStyle.

pygments/lexers/web.py

 
     tokens = {
         'root': [
-            (r'(@media)(\s+)(\w+)(\s*)({)', bygroups(Keyword, Text, String,
-             Text, Punctuation), 'media'),
             include('basics'),
         ],
         'basics': [
             (r'\:[a-zA-Z0-9_-]+', Name.Decorator),
             (r'\.[a-zA-Z0-9_-]+', Name.Class),
             (r'\#[a-zA-Z0-9_-]+', Name.Function),
+            (r'@[a-zA-Z0-9_-]+', Keyword, 'atrule'),
             (r'[a-zA-Z0-9_-]+', Name.Tag),
             (r'[~\^\*!%&\[\]\(\)<>\|+=@:;,./?-]', Operator),
             (r'"(\\\\|\\"|[^"])*"', String.Double),
             (r"'(\\\\|\\'|[^'])*'", String.Single)
         ],
-        'media': [
+        'atrule': [
+            (r'{', Punctuation, 'atcontent'),
+            (r';', Punctuation, '#pop'),
             include('basics'),
-            (r'}', Punctuation, '#pop')
+        ],
+        'atcontent': [
+            include('basics'),
+            (r'}', Punctuation, '#pop:2'),
         ],
         'content': [
             (r'\s+', Text),

tests/examplefiles/test.css

     background: #ccc;
   }
 }
+
+@namespace "http://www.w3.org/1999/xhtml";
+
+@import url("mystyle.css");
+
+@charset "ISO-8859-1";
+
+@font-face { font-family: "Example Font"; src: url("http://www.example.com/fonts/example"); }
+
+@media screen { body { font-size: 16px } } @media print { body { font-size: 12pt } }
+
+
+@page { body { margin: 1in 1.5in; } }
+
+@page linke-seite:left { body { margin:20mm; margin-right:25mm; } }
+
+@-moz-document url-prefix(http://pygments.org) {  a {font-style: normal !important;} }
+
+