From 379c2075a0ce52ddbd74b38ec69e4922ec6dcac0 Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Wed, 8 Jan 2025 11:17:27 -0600 Subject: [PATCH] fix example rendering in README.rst use code-block directive instead of triple-backtick fencing, since the file is rST not markdown --- README.rst | 60 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/README.rst b/README.rst index d77c0212..381761d4 100644 --- a/README.rst +++ b/README.rst @@ -69,35 +69,37 @@ Beware, cssutils is known to be thread unsafe. Example ======= -```python -import cssutils - -css = '''/* a comment with umlaut ä */ - @namespace html "http://www.w3.org/1999/xhtml"; - @variables { BG: #fff } - html|a { color:red; background: var(BG) }''' -sheet = cssutils.parseString(css) - -for rule in sheet: - if rule.type == rule.STYLE_RULE: - # find property - for property in rule.style: - if property.name == 'color': - property.value = 'green' - property.priority = 'IMPORTANT' - break - # or simply: - rule.style['margin'] = '01.0eM' # or: ('1em', 'important') - -sheet.encoding = 'ascii' -sheet.namespaces['xhtml'] = 'http://www.w3.org/1999/xhtml' -sheet.namespaces['atom'] = 'http://www.w3.org/2005/Atom' -sheet.add('atom|title {color: #000000 !important}') -sheet.add('@import "sheets/import.css";') - -# cssutils.ser.prefs.resolveVariables == True since 0.9.7b2 -print sheet.cssText -``` + +.. code-block:: python + + import cssutils + + css = '''/* a comment with umlaut ä */ + @namespace html "http://www.w3.org/1999/xhtml"; + @variables { BG: #fff } + html|a { color:red; background: var(BG) }''' + sheet = cssutils.parseString(css) + + for rule in sheet: + if rule.type == rule.STYLE_RULE: + # find property + for property in rule.style: + if property.name == 'color': + property.value = 'green' + property.priority = 'IMPORTANT' + break + # or simply: + rule.style['margin'] = '01.0eM' # or: ('1em', 'important') + + sheet.encoding = 'ascii' + sheet.namespaces['xhtml'] = 'http://www.w3.org/1999/xhtml' + sheet.namespaces['atom'] = 'http://www.w3.org/2005/Atom' + sheet.add('atom|title {color: #000000 !important}') + sheet.add('@import "sheets/import.css";') + + # cssutils.ser.prefs.resolveVariables == True since 0.9.7b2 + print sheet.cssText + results in:: @charset "ascii";