NAME

CSS::Tidy - reformat CSS

SYNOPSIS

use CSS::Tidy 'tidy_css';
my $output = tidy_css ($input);

VERSION

This documents version 0.00_02 of CSS-Tidy corresponding to git commit 7f8b73d8016ed837294b64baf0704f219b36fef8 released on Wed Jan 27 12:45:52 2021 +0900.

DESCRIPTION

This reformats CSS.

The idea is to have a formatting script which can be used to consistently format CSS.

FUNCTIONS

tidy_css

my $output = tidy_css ($input);

Given CSS in $input, reformat it into a consistent format and return the value.

TRANSFORMATIONS APPLIED

Indentation

Indentation is changed to multiples of four spaces.

Trailing whitespace

Trailing whitespace (blanks after the end of the line) is removed.

Property/value pairs

The spacing between property/value pairs such as

font-size:21em;

is altered to put a single space after the colon:

font-size: 21em;
Declaration blocks

A blank line is inserted between declaration blocks.

Single-line braces are expanded out
.something { something:something; }

is expanded to

.something {
    something: something;
}
Comments have a blank line before and after

If the comment is on a line by itself, it will be given one blank line before and after itself.

SCRIPT

The script csstidy runs "tidy_css" on STDIN and prints the result to STDOUT. There is also css-tidy.el in the distribution which enables one to run csstidy on the current buffer.

AUTHOR

Ben Bullock, <bkb@cpan.org>

COPYRIGHT & LICENCE

This package and associated files are copyright (C) 2021 Ben Bullock.

You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.