CSS library for D

Package Information

Version0.1.3 (2016-Dec-01)
LicenseMIT License
CopyrightCopyright © 2015, Márcio Martins
AuthorsMárcio Martins
Registered byMárcio Martins
Dependencies none


To use this package, put the following dependency into your project's dependencies section:




CSS library for D

The library currently includes a non-validating parser module and a DOM agnostic (currently through an element proxy template) selector matching module The selector matching module currently implements all CSS3 and the case-insensitive attribute matching from CSS4. Pseudo-elements are currently left to be handled by the user code to minimize the proxy template interface.

Example handler:

struct CSSOMBuilder {
	void onSelector(const(char)[] data) {}
	void onSelectorEnd() {}
	void onBlockEnd() {}
	void onPropertyName(const(char)[] data) {}
	void onPropertyValue(const(char)[] data) {}
	void onPropertyValueEnd() {}
	void onComment(const(char)[] data) {}

Example usage:

auto builder = CSSOMBuilder();
parseCSS(`h1:hover > span#highlight { background: black; }`, builder);

Example selector usage:

	auto highlightSelector = Selector.parse("h1:hover > span#highlight"); // parses selector into a representation that is fast to test
	if (highlightSelector.matches(someElement))
		someElement.attr("style", highlightStyle);

Available versions

0.1.3 0.1.2 0.1.1 0.1.0 ~master