pelican-htmlmin
A Pelican plugin using htmlmin to remove comments and extra whitespace from your website.
Turning this:
<head> <title> Hello, World! </title> </head> <body> <p> How <em>you</em> doing? </p> </body>
Into this:
<head><title>Hello, World!</title><body><p> How <em>you</em> doing? </p></body>
Installing
pelican-htmlmin
, is available on pip
and takes advantage of
Pelican's namespace system to automatically register installed plugins.
Just install with pip
and you're ready to go:
$ pip install pelican-htmlmin
For a more detailed plugin installation guide, please refer to the Pelican Plugin Documentation.
Options
Being a very small wrapper around htmlmin
, there are only a few options
that you may need.
HTMLMIN_ENABLED
By Default, if Pelican is in DEBUG
mode, pelican-htmlmin
will
not minify any files, to help with debugging. To override this, set
HTMLMIN_ENABLED = True
to minify files regardless of the
DEBUG
flag.
HTMLMIN_ENABLED = logger.getEffectiveLevel() > logging.DEBUG
HTMLMIN_MATCH
Out of the box, pelican-htmlmin
looks for files ending with
.html
or .htm
to minify. You can use the HTMLMIN_MATCH
to change the regular expression that matches the files you wish to minify.
HTMLMIN_MATCH = r'.html?$'
HTMLMIN_OPTIONS
If you wish to pass arguments directly to htmlmin
, use the
HTMLMIN_OPTIONS
to pass keyword arguments.
HTMLMIN_OPTIONS = { 'remove_comments': True, 'remove_all_empty_space': True, 'remove_optional_attribute_quotes': False }
For more information on the arguments you can give htmlmin
, see their
documentation here
Contributing
Please feel free to help. Buying me Beer, emailing issues, or patches via email, are all warmly welcomed, especially beer.