htmlminify.py
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Python reimplementation of Juriy "kangax" Zaytsev's html-minifier javascript script. Uses lxml for html parsing.
## Note
This was something I wrote for shits and giggles when I was still familiarizing myself with Python. It was written as a direct translation of kangax's JavaScript code to Python, and no thought was given to redesigning it for the new language. (Even the original naming scheme was retained until I murdered the consistency with updates using the Python naming style) As a result, it has awful performance, hideous source, and should never be used for any sort of production-level work.

HtmlMinify.py
=============
Update: Changed the html parser to [LXML](http://lxml.de/). Should work a lot better now.

I needed a quick little python script for minimizing html that I could easily integrate into the build script of a project I was working on. (*Never actually used it in said build script or ever again after writing it*) Since the only usable thing I could find at the time was [kangax's js script](https://github.com/kangax/html-minifier/ "kangax / html-minifier"), I went to work converting his over to python. 

I had to make a few changes to some of the existing regular expressions, due to some funky effects when dealing with unclean html, but it shouldn't affect the end size too much. Let me know if you notice anything off.

All credit goes to him, since the entire script's logic down to the regular expressions are clones of his work.

Singlize.py
===========
Probably broken after the updates.

Usage
-----
singlize.py input_file.html output_file.html

Description
-----------
Threw together a script that utilizes htmlminifier, [pyquery](http://pypi.python.org/pypi/pyquery), [cssmin](http://pypi.python.org/pypi/cssmin/0.1.4), and a modified version of [ClosureCompiler](http://pypi.python.org/pypi/ClosureCompiler/0.1) (included) to turn a static page like this:

Original:
---------
		
		
		  
			Playing with Code Mirror
			
			
			
			
			
			
			
			
			
			
			
		  
		  
			
			
			
Into Result: ------------ Playing with Code Mirror
Pretty simple tool as it stands now. It will follow @imports, base64 any images it finds in the CSS (though not in tags yet), etc. At the moment, it doesn't resolve external links, chrome links, or file:// links. It also assumes that your root directory is your current working directory.

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。