CSS::Tidy - reformat CSS
use CSS::Tidy 'tidy_css'; my $output = tidy_css ($input);
This documents version 0.04 of CSS-Tidy corresponding to git commit d237baf76e9f413725f83c33b825d7ed347e86d4 released on Sat Jul 30 19:54:16 2022 +0900.
This reformats CSS.
The idea is to have a formatting script which can be used to consistently format CSS.
copy_css (in => $infile, out => $outfile);
Copy CSS from a file specified by "in" to a file specified by "out".
Input file. The file is read in via the function read_text in "File::Slurper" so it must be in the UTF-8 encoding.
read_text
Output file. The file is written using write_text from "File::Slurper" so it must be in the UTF-8 encoding.
write_text
Remove comments from the output file.
my $output = tidy_css ($input, %options);
Given CSS in $input, reformat it into a consistent format and return the value.
$input
Options are as follows:
Set to a true value to remove comments from the output
Indentation is changed to multiples of four spaces.
Trailing whitespace (blanks after the end of the line) is removed.
The spacing between property/value pairs such as
font-size:21em;
is altered to put a single space after the colon:
font-size: 21em;
A blank line is inserted between declaration blocks.
.something { something:something; }
is expanded to
.something { something: something; }
If the comment is on a line by itself, it will be given one blank line before and after itself.
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.
This is used for comment regex.
This is used to read and write files
CSS Syntax Module Level 3 at the W3 Consortium.
[Author: IAMCAL; Date: 2011-03-22; Version: 1.09]
2011-03-22
1.09
[Author: GUGU; Date: 2009-12-26; Version: 0.09]
2009-12-26
0.09
[⭐ Author: SPROUT; Date: 2018-01-29; Version: 0.17]
2018-01-29
0.17
[⭐ Author: JDEGUEST; Date: 2020-08-12; Version: v0.1.3]
2020-08-12
v0.1.3
[Author: BJOERN; Date: 2008-07-05; Version: 0.08]
2008-07-05
0.08
👎 This seems to be unusable, it fails on the CSS stylesheets we've tried it on.
[Author: KAMELKEV; Date: 2017-11-16; Version: 3224]
2017-11-16
3224
[Author: SKIM; Date: 2021-01-28; Version: 0.04]
2021-01-28
0.04
[⭐ Author: CHORNY; Date: 2016-03-10; Version: 1.20]
2016-03-10
1.20
Claims to reduce memory usage compared to the CSS module.
[⭐ Author: LNATION; Date: 2021-04-15; Version: 0.07]
2021-04-15
0.07
"dedupe, minify and extend CSS". We haven't tried it, but from the documentation it seems to be a CSS preprocessor.
[Author: MUGIFLY; Date: 2013-09-20; Version: v0.0.3]
2013-09-20
v0.0.3
[Author: MNF; Date: 2011-06-20; Version: v0.9.2.4]
2011-06-20
v0.9.2.4
[⭐ Author: OCBNET; Date: 2020-05-04; Version: v3.6.3]
2020-05-04
v3.6.3
Unfortunately this is built on top of a deprecated library which is being replaced with Dart Sass.
[⭐ Author: VANSTYN; Date: 2015-08-27; Version: 0.04]
2015-08-27
[⭐ Author: JANUS; Date: 2018-12-03; Version: 0.05]
2018-12-03
0.05
[⭐ Author: PMICHAUX; Date: 2007-08-03; Version: 0.01]
2007-08-03
0.01
[⭐ Author: GTERMARS; Date: 2021-02-07; Version: 0.13]
2021-02-07
0.13
[⭐ Author: LEEJO; Date: 2021-03-02; Version: 2.08]
2021-03-02
2.08
[Author: TSIBLEY; Date: 2010-11-05; Version: 0.10]
2010-11-05
0.10
[⭐ Author: SARTAK; Date: 2013-08-08; Version: 0.04]
2013-08-08
👎 Test whether your styles are actually in use or not. Unfortunately it depends on "CSS::SAC" which seems to be unusable.
[⭐ Author: KAMELKEV; Date: 2020-01-01; Version: 4014]
2020-01-01
4014
[Author: HDP; Date: 2011-11-06; Version: 0.003]
2011-11-06
0.003
[Author: DFH; Date: 2014-07-04; Version: 0.002]
2014-07-04
0.002
[⭐ Author: CFAERBER; Date: 2019-05-01; Version: 1.14]
2019-05-01
1.14
This provides a map from the names of colours valid in CSS to their RGB values.
[Author: MANWAR; Date: 2017-09-09; Version: 0.08]
2017-09-09
Test CSS files or strings using regular expressions and a list of properties. The properties list is somewhat out of date, for example it doesn't have the touch-action property. See https://github.com/manwar/Test-CSS/issues/2.
touch-action
Ben Bullock, <bkb@cpan.org>
This package and associated files are copyright (C) 2021-2022 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.
To install CSS::Tidy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CSS::Tidy
CPAN shell
perl -MCPAN -e shell install CSS::Tidy
For more information on module installation, please visit the detailed CPAN module installation guide.