Simply Jonathan

html2css

I just started my first project at Google code: html2css, a project I’ve been working on for some weeks now.

html2css has one simple function: Turn an HTML file into a CSS file. This is a functionality I’ve become increasingly aware that I need; I often find myself in a situation where I’ve mocked up the entire HTML document, and then have to perform the tedious task of applying it all in my CSS file, which often leads to a disorganized mess.

It uses the incredible Beautiful Soup library, meaning that it can tolerate even the worst piece of HTML — it manages to produce a valid representation of a Google search.

There are two files of interest in the project (discarding the bundled beautifulsoup.py). The first one is html2css.py where most of the magic happens. The other is writecss.py which is a useful extension of html2css. It allows you to turn your HTML into CSS, respecting earlier generations from html2css. This means you can generate a CSS file for one HTML structure, add some CSS rules, modify the HTML, regenerate the CSS, and your rules will still be present, given that you haven’t modified the element they’re attached to.

This is a 0.1 release, but it should be pretty stable. Comments appreciated.

This is Simply Jonathan, a blog written by Jonathan Holst. It's mostly about technical topics (and mainly the Web at that), but an occasional post on clothing, sports, and general personal life topics can be found.

Jonathan Holst is a programmer, language enthusiast, sports fan, and appreciator of good design, living in Copenhagen, Denmark, Europe. He is also someone pretentious enough to call himself the 'author' of a blog. And talk about himself in the third person.