sabberworm / PHP-CSS-Parser

A Parser for CSS Files written in PHP. Allows extraction of CSS files into a data structure, manipulation of said structure and output as (optimized) CSS

Home Page:http://www.sabberworm.com/blog/2010/6/10/php-css-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CSS classes starting with a number are not correctly parsed

Tabrisrp opened this issue · comments

It is possible (though not recommended) to use a number as the starting character in a class/id name. An example: <p class="082874c1">hello world</p>

In the CSS declaration, the first number must be escaped with \3, like the following:

.\30 82874c1 {
        color: red;
      }

This type of declaration is not working well with the parser, as the output looks like so:

[
    {
        "tokens": [
            [
                {
                    ".\\30 82874c1": {
                        "1": [
                            "30"
                        ],
                        "0": [
                            "82874c1"
                        ]
                    }
                },
                [
                    "color:red"
                ]
            ]
        ]
    }
]

The selector part is split in 2, while it is in fact only one selector.