Generates (prop, value) pairs from declarations. In a future version may generate parsed tokens from tinycss/tinycss2 Parameters ---------- declarations_str : str
(self, declarations_str: str)
| 399 | yield prop, value |
| 400 | |
| 401 | def parse(self, declarations_str: str) -> Iterator[tuple[str, str]]: |
| 402 | """ |
| 403 | Generates (prop, value) pairs from declarations. |
| 404 | |
| 405 | In a future version may generate parsed tokens from tinycss/tinycss2 |
| 406 | |
| 407 | Parameters |
| 408 | ---------- |
| 409 | declarations_str : str |
| 410 | """ |
| 411 | for decl in declarations_str.split(";"): |
| 412 | if not decl.strip(): |
| 413 | continue |
| 414 | prop, sep, val = decl.partition(":") |
| 415 | prop = prop.strip().lower() |
| 416 | # TODO: don't lowercase case sensitive parts of values (strings) |
| 417 | val = val.strip().lower() |
| 418 | if sep: |
| 419 | yield prop, val |
| 420 | else: |
| 421 | warnings.warn( |
| 422 | f"Ill-formatted attribute: expected a colon in {decl!r}", |
| 423 | CSSWarning, |
| 424 | stacklevel=find_stack_level(), |
| 425 | ) |