@@ -69,36 +69,35 @@ Beware, cssutils is known to be thread unsafe.
6969
7070Example
7171=======
72- ::
73-
74- import cssutils
75-
76- css = '''/* a comment with umlaut ä */
77- @namespace html "http://www.w3.org/1999/xhtml";
78- @variables { BG: #fff }
79- html|a { color:red; background: var(BG) }'''
80- sheet = cssutils.parseString(css)
81-
82- for rule in sheet:
83- if rule.type == rule.STYLE_RULE:
84- # find property
85- for property in rule.style:
86- if property.name == 'color':
87- property.value = 'green'
88- property.priority = 'IMPORTANT'
89- break
90- # or simply:
91- rule.style['margin'] = '01.0eM' # or: ('1em', 'important')
92-
93- sheet.encoding = 'ascii'
94- sheet.namespaces['xhtml'] = 'http://www.w3.org/1999/xhtml'
95- sheet.namespaces['atom'] = 'http://www.w3.org/2005/Atom'
96- sheet.add('atom|title {color: #000000 !important}')
97- sheet.add('@import "sheets/import.css";')
98-
99- # cssutils.ser.prefs.resolveVariables == True since 0.9.7b2
100- print sheet.cssText
101-
72+ ```python
73+ import cssutils
74+
75+ css = '''/* a comment with umlaut ä */
76+ @namespace html "http://www.w3.org/1999/xhtml";
77+ @variables { BG: #fff }
78+ html|a { color:red; background: var(BG) }'''
79+ sheet = cssutils.parseString(css)
80+
81+ for rule in sheet:
82+ if rule.type == rule.STYLE_RULE:
83+ # find property
84+ for property in rule.style:
85+ if property.name == 'color':
86+ property.value = 'green'
87+ property.priority = 'IMPORTANT'
88+ break
89+ # or simply:
90+ rule.style['margin'] = '01.0eM' # or: ('1em', 'important')
91+
92+ sheet.encoding = 'ascii'
93+ sheet.namespaces['xhtml'] = 'http://www.w3.org/1999/xhtml'
94+ sheet.namespaces['atom'] = 'http://www.w3.org/2005/Atom'
95+ sheet.add('atom|title {color: #000000 !important}')
96+ sheet.add('@import "sheets/import.css";')
97+
98+ # cssutils.ser.prefs.resolveVariables == True since 0.9.7b2
99+ print sheet.cssText
100+ ` ``
102101results in::
103102
104103 @charset "ascii";
0 commit comments