noloop / cl-minify-css

To minify css with common lisp.
10 stars 1 forks source link

*** To minify css with common lisp.

** Getting Started in cl-minify-css

*** Dependencies

No dependencies. Yes, I was crazy, and I did it without cl-ppcre by fun.

*** Download and Load

1 - Load cl-minify-css system by quicklisp

IN PROGRESS... but will be like this: ~(ql:quickload :cl-minify-css)~

2 - Download and load cl-minify-css system by github and asdf

download from github:

+BEGIN_SRC

git clone https://github.com/noloop/cl-minify-css.git

+END_SRC

and load by asdf:

+BEGIN_SRC lisp

(asdf:load-system :cl-minify-css)

+END_SRC

Note: Remember to configure asdf to find your directory where you downloaded the libraries (asdf call them "systems") above, if you do not know how to make a read at: https://common-lisp.net/project/asdf/asdf/Configuring-ASDF-to-find-your-systems.html or https://lisp-lang.org/learn/writing-libraries.

** How to minify a css string?

+BEGIN_SRC lisp

(defparameter css "/By somebody | License GPLv3/ div,ul,li:focus { outline:none; /some comment/ margin: 5px 0 0 1px; }

body { font: 1em/150% Helvetica, Arial, sans-serif; padding: 1em; margin: 0 auto; max-width: 33em; }

@media (min-width: 70em) { body { font-size: 130%; /more some comment/ } }

h1 { font-size: 1.5em; }") (minify-css css :keep-license-p nil) ;; => "div,ul,li:focus{outline:none;margin:5px 0 0 1px;}body{font:1em/150% Helvetica, Arial, sans-serif;padding:1em;margin:0 auto;max-width:33em;}@media (min-width:70em){body{font-size:130%;}}h1{font-size:1.5em;}" (minify-css css :keep-license-p t) ;; => "/By somebody | License GPLv3/div,ul,li:focus{outline:none;margin:5px 0 0 1px;}body{font:1em/150% Helvetica, Arial, sans-serif;padding:1em;margin:0 auto;max-width:33em;}@media (min-width:70em){body{font-size:130%;}}h1{font-size:1.5em;}"

+END_SRC

** API

function (minify-css css &key keep-license-p)