Crosstips.org

My fun Crossword solver project. Crosstips.org & Krysstips.se

Kung Fu

Fujian White Crane Kung Fu

Fry-IT

Fry-IT is the company I work for

Photos

Photoalbum, both old and new.

Zope

What I have and am doing with Zope

Receptsamlingen

In Swedish only. About my "Collection of Recipes" website.

Contact me

My contact details and how to contact me.

 

KungFuPeople.com
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com


Mobile version of this page Mobile version of this page


 

XHTML, HTML and CSS compressor

http://www.peterbe.com/plog/blogitem-040406-1/compressor

checkoutabletemplates, fry-it, compress, xhtml, css, slimmer

6th of April 2004

Last week Fry-IT released CheckoutableTemplates which is a templating module add-on for Zope. It includes a module called slimmer.py which can compress XHTML, HTML and CSS. The CSS had a flaw in it that I hadn't foreseen. This flaw arises when you use M$ Internet Explorer hacks like this for example:

 #centercontent {
    margin-left
: 259px;
    margin-right
:249px;
    voice-family
: "\"}\"";
    voice-family
: inherit;
    margin-left
: 271px;
    margin-right
:251px;
    
}

Now that bug has been fixed, so I give you: The XHTML, HTML and CSS compressor It's a little application of slimmer.py so that the compressing can be tested and so that one can see the effect.



Comment

23 comments so far
Peter - 1st April 2004  [«« Reply to this]
These guys have done it with JavaScript but not as good and they hope to sell each license for $7.
http://www.creativyst.com/Prod/3/
flump - 20th August 2004  [«« Reply to this]
hey, i've been working on something like this for a while now http://flumpcakes.co.uk/css/optimiser/
Peter - 20th August 2004   [«« Reply to this]
I like it. It's much more clever than mine. We should combine our efforts since we obviously take two completely different approaches and that they would work together. What programming language do you use?
Jake Lafcraft - 7th September 2006  [«« Reply to this]
Congratulations on a great web site. I am a new computer user and finding you was like coming home. Continued success.
Qween Lorry - 13th September 2006  [«« Reply to this]
Congratulations on a great web site. I am a new computer user and finding you was like coming home. Continued success.
Marrick Linn - 21st September 2006  [«« Reply to this]
Congratulations on a great web site. I am a new computer user and finding you was like coming home. Continued success.
Linda Right - 26th September 2006  [«« Reply to this]
How do you think. If I quit using internet... No, CAN I quit?
incest videos - 23rd November 2006  [«« Reply to this]
{links:30
Nadeem Afana - 3rd November 2008  [«« Reply to this]
Hi,
I was trying your nice tool for compressing an XHTML file, but the compressor removes white-spaces from an attribute value (that is between double quotation marks).

I hope you can correct this,
Thanks!
Peter Bengtsson - 4th November 2008   [«« Reply to this]
Really?? That's a bug. Can you provide me with an example where it happens and I'll try to fix it.
Nadeem Afana - 5th November 2008   [«« Reply to this]
Here is an example:

<example attribute="This is a test." />
Nadeem Afana - 5th November 2008   [«« Reply to this]
Well, add spaces between the double quotation marks.

It seems that this tool removes spaces too.
Peter Bengtsson - 5th November 2008   [«« Reply to this]
I see the problem. It actually saves whitespace before and after but not inside the attribute. example (. replaces whitespace):

>>> from slimmer import html_slimmer
>>> html='''<example attribute="....This is....a test...." />'''
>>> html_slimmer(html)
'<example attribute="....This is a test...." />'

You're right. It is a bug.

However, I can't find the time to work on this now. To begin with, whitespace slimming on HTML is often less important since HTML is often regenerated every time unlike CSS and Javascript which is often more static and needs only to be slimmed once per build.

I've taken note of the bug but not going to commit any time to it now I'm afraid. Thanks for spotting it!
Nadeem Afana - 5th November 2008  [«« Reply to this]
OK.
It does not matter.

Is not there an executable version or source code of your code?
Peter Bengtsson - 6th November 2008   [«« Reply to this]
No but you could quite easily make one yourself with py2exe. The instructions are quite easy.
Deborah - 6th September 2009  [«« Reply to this]
Good afternoon. I feel like a tiny bird with a big song!
I am from Cyprus and now study English, tell me right I wrote the following sentence: "More than 16,000 graphics and more than 60 card girls banked in the system defence, easyhome prepaid mastercard."

Thanks :o. Deborah.
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.