Project Home

css-convert

Table of Contents

Description

Read a simplified format for CSS files, strips comments and outputs a valid CSS file. You can specify multiple input files and the result will be a concatenation of them. Optionally runs the file through m4, and/or compress the output into a more compact and harder-to-read format.

Specify '-' as a filename to read from stdin, or no filename at all.

The purpose is to be able to more easily edit CSS stylesheet with a comment syntax that is easier to use, and to use indentation as a way of grouping rather than requiring curly brackets to delimit sections.

Also, this script can produce a compressed version of the CSS file which is harder to read by humans (e.g. humans who would want to rip off tricks off of your design) and is smaller to download, thus saving bandwidth.

The simplified syntax is best illustrated by an example:

div.header
  background-color: white

// Make first paragraphs in bold.
p.first
  font-style: bold

p#special, div#special
  font-size: larger // larger fonts

Notes

  • we do not use curly brackets
  • comments are parsed C++ style, so it's easy to comment entire regions
  • you do not need to terminate lines with semicolons
  • comment are stripped from the output file
  • just like CSS, blocks cannot be nested

Note that if cssutils is installed in your system, we validate the CSS file through its parser.

Usage

css-convert <input-file> [<input-file> ...]

Please Donate!

Important

This computer program or library is provided for free. I am aware that some of the programs that I provide for free allow people to get their work done faster or better, save them time and money. If you are using this program for benefit, especially if you are using it within a commercial environment and it saves you time or work, please consider making a donation by sending me a book from my Amazon Wishlist or by a direct donation to my company's PayPal account by clicking on the link below.

Download

Download program here.