Generate HTML from CSS rules. Compatible with Node.js and the jsdom module to serve up your CSS stylesheets as HTML styleguides.
- Should support all valid CSS selectors: type, universal, attribute, class, id, pseudo, descendant, child, sibling etc.
- Options to populate generated HTML with placeholder content.
- 190+ unit tests with QUnit.
css2html(css, [options])
- css - (string) CSS rules.
- options - (object, optional) Options object.
- autoExpand - (bool: default
true
) Whether to expand selectors into valid DOM trees. - dataAttr - (bool: default
false
) Whether to set an HTML5 data attribute 'data-selector' with the value of the CSS selector. - debug - (bool: default
false
) Whether to log debugging/error messages to a console (if one is available). - out - (string: default
nodes
) Either 'nodes' to output HTML nodes, or 'html' to output HTML text. - populate - (bool: default
false
) Whether to populate HTML with placeholder text.
To use with Node.js ensure the jsdom module has been installed and import into your Node.js module:
var css2html = require('./lib/css2html.js');