A suite of tools to parse and transform web formats, for web applications and automation.
Takes HTML and converts it to corresponding CSS. Though, it doesn't truly "convert". It parses the HTML and extracts the ids and classes, outputting them to blank selectors.
Example:
Using
from code_reflector import css_reflector as cssref
reflector = cssref.CSSReflector(newlines_and_spaces=True)
reflector.process('myhtmlfile.html').make_stylesheet(output='output.css')<div id="foo">
<div id="bar">
<div id="bam" class="foo foo2"></div>
</div>
</div>becomes
#foo {}
#foo #bar {}
#foo #bar #bam.foo.foo2 {}or, if nested is set to False,
#foo #bar #bam.foo.foo2 {}Takes CSS and converts it to corresponding HTML. Similar to Emmett, but fully OSS, and programmable (and handles spaces for nested selectors). Also designed to work in conjunction with other Reflector components.
Example:
Using
from code_reflector import html_reflector as htmlref
reflector = htmlref.HTMLReflector(newlines_and_spaces=True)
reflector.process('mycssfile.css').extract().make_html(output='output.html').foo.bar#barbecomes
<div class="foo bar" id="bar"></div>Requires Python 2.7+ Packages: see requirements.txt for more.
python setup.py installTest coverage provided by nose. Run tests via python nosetests tests/