jaredly / jaredly/css

invalid parsed selector, question about url() and built-in types

Open
#3 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
17
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Hello,

I'm using css lib to parse styles uploaded by users and then do some validation rules. First problem is about inproperly parsed selectors, for example:

```
#editTemporaryPriceList,
#addTemporaryPriceList,
#addPriceList { font-size: 1.2em; display: block; color: #333; text-decoration: underline; margin-top: 10px; padding-bottom: 3px; }
```

is parsed as:

```
(None, {'pseudo': [], 'attrib': [], 'hash': ['editTemporaryPriceList'], 'class': []})
(None, {'pseudo': [], 'attrib': [], 'hash': ['#addTemporaryPriceList'], 'class': []})
(None, {'pseudo': [], 'attrib': [], 'hash': ['#addPriceList'], 'class': []})
```

(# at the begging of 'hash' in two selectors)

The second problem is about attributes with url(). Why url() is stripped from value?

Third and the last problem is about built-in types. For example Percentage, Length, Rgb. I'm trying to create cleaned sheet from CSSStyleSheet, but i'm unable to check if attribute value is type of Length or other. When I import those classes from codetalker, 'isinstance' always return False and i need to do some hasattr checks to discover value's type. Is there any other way to do that?

It would be great if css could work in both ways (parse and print).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the three examples against the CSS parser and CSSStyleSheet, then inspect the selector, url() value, and codetalker built-in type handling. Compare parsed output with the original CSS and define done as preserving selectors and url() values while exposing reliable type checks; add regression coverage for each case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.