RSS Feed

Lisp Project of the Day

softdrink

You can support this project by donating at:

Donate using PatreonDonate using Liberapay

softdrinkweb

This is a small library by @shinmera. It is able to extract CSS from HTML or embed it back.

"Softdrink" could be useful, for example, to produce HTML emails. Most email software ignores external stylesheets but is able to use styles, embedded into HTML nodes.

Unfortunately, even the README examples don't work. Probably because the library's dependencies were changed in the last few years.

I've created an issue about these problems:

https://github.com/Shinmera/softdrink/issues/1

Hope, @shinmera will help to figure out, how to fix the problems.

Update

Nicolas was able to fix the issue very quickly. You can install a fixed version from:

https://ultralisp.org

Let's try how it works!

The first example shows how to extract CSS from HTML:

POFTHEDAY> (softdrink:slurp "<div>
                               <foo/>
                               <foo id=\"bla\"
                                    style=\"foo: bar; blah: minor\" />
                             </div>")
"div>#bla{
    foo: bar;
    blah: minor;
}"

The second example embeds CSS into HTML and renders it into the string:

POFTHEDAY> (softdrink:pour
            (softdrink:mix
             "<foo>
                <p>Hello Lisp World!</p>
              </foo>"
             ;; This is a style to embed into HTML
             '(p :text-decoration underline)))

"<foo>
                <p style=\"text-decoration:underline;\">Hello Lisp World!</p>
              </foo>"

Great! Everything work like expected!


Brought to you by 40Ants under Creative Commons License