Skip to content

cssmerge

About cssmerge

cssmerge is a commandline utility which extracts selected blocks of CSS from multiple input stylesheets, and merges them into a single coherent output stylesheet, with optional comments on where they came from, and warnings about conflicting styles.

It is written in Perl 5 and requires the CSS::Tiny module from CPAN. Other than that, it’s just a simple perl script; download it, rename it to cssmerge, make it executable, and run it. The license terms are the same as for Perl itself. Documentation is in POD format within the script (ie, type perldoc cssmerge)

I welcome your feedback; you can either leave a comment on the announcement for the version you are using, or email ben@removethisbit.qolc.net.

cssmerge 1.15 released

Apologies for the download link being broken for a while. For some reason, anything with a .pl suffix doesn’t work at my new hosting provider. Fixed now.

A new version of cssmerge is available. Download, rename it to cssmerge, and run with perl cssmerge (or make it executable and put it somewhere in your PATH).

There are several major changes since the last release.

First of all, it has been rewritten to use CSS::Tiny instead of the rather heavyweight and buggy CSS. So please ensure you have CSS::Tiny installed.

A new option --regex allows you to search for selectors or properties using Perl regular expression syntax.

Meanwhile the mechanism used by the default search method (when neither --regex nor --exact is specified) is now more precisely specified. It differs according to whether you’re searching for selectors or properties, so that most of the time it should just Do The Right Thing.

For example, cssmerge --selector a will return all codeblocks relating to the element <a> (including li ul a.foo, a:hover etc), but not the element <abbr> nor any class .a or ID #a. To search for classes, ID or pseudos, simply include the appropriate sigil in your search, ie --selector .class, --selector '#id', --selector :hover. Note the quotes in the second example there; some shells will otherwise ignore anything following a hash sign.

cssmerge --property font will search not just for the font property but also font-family, font-size etc… which is almost certainly what you want. If it isn’t, of course, you can use --exact or --regex 🙂

There is also support for escaped characters in identifiers, per the CSS 2.1 spec.

Your feedback is always welcome. Please feel free to add a comment to this post, or send email to the address on the About page.

cssmerge 1.12 released

v1.12 of cssmerge has now been released. The main change is to fix the --exact option that was broken in v1.10. This option is not normally useful anyway, but I thought I might as well fix it.

Download here.

I’ve also changed the licensing to just GPL, as I’m not convinced about using Artistic on scripts (as opposed to modules).

cssmerge 1.10 released

cssmerge is a commandline utility which extracts selected blocks of CSS from multiple input files and merges them into a single coherent output, with optional comments on where they came from, and warnings about conflicting styles. v1.10 is the first public release.

It is written in Perl 5 and requires the CSS module from CPAN. Other than that, it’s just a simple perl script; download it, rename it if you want, and run it. The license terms are the same as for Perl itself. Documentation is in POD format within the script.

Download cssmerge 1.10.

I welcome your feedback; please leave a comment here or email ben@removethisbit.qolc.net.