MCPcopy Index your code
hub / github.com/unclecode/crawl4ai / dumb_css_parser

Function dumb_css_parser

crawl4ai/html2text/utils.py:31–54  ·  view source on GitHub ↗

:type data: str :returns: A hash of css selectors, each of which contains a hash of css attributes. :rtype: dict

(data: str)

Source from the content-addressed store, hash-verified

29
30
31def dumb_css_parser(data: str) -> Dict[str, Dict[str, str]]:
32 """
33 :type data: str
34
35 :returns: A hash of css selectors, each of which contains a hash of
36 css attributes.
37 :rtype: dict
38 """
39 # remove @import sentences
40 data += ";"
41 importIndex = data.find("@import")
42 while importIndex != -1:
43 data = data[0:importIndex] + data[data.find(";", importIndex) + 1 :]
44 importIndex = data.find("@import")
45
46 # parse the css. reverted from dictionary comprehension in order to
47 # support older pythons
48 pairs = [x.split("{") for x in data.split("}") if "{" in x.strip()]
49 try:
50 elements = {a.strip(): dumb_property_dict(b) for a, b in pairs}
51 except ValueError:
52 elements = {} # not that important
53
54 return elements
55
56
57def element_style(

Callers 1

handle_dataMethod · 0.85

Calls 1

dumb_property_dictFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…