aboutsummaryrefslogtreecommitdiffstats
path: root/readme.rst
blob: ec13d994503e337ce55b9f953b0622d0204352ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
pelican-htmlmin
###############

A `Pelican <https://github.com/getpelican/pelican/>`_ plugin that uses
`htmlmin <https://github.com/mankyd/htmlmin>`_ to remove comments and extra
whitespace from your website after the pages have been generated.

Turning this:

.. code-block:: html

   <html>
     <head>
       <title>  Hello, World!  </title>
     </head>
     <body>
       <p> How  <em>you</em> doing?  </p>
     </body>
   </html>


Into this:

.. code-block:: html

   <html><head><title>Hello, World!</title><body><p> How <em>you</em> doing? </p></body></html>

Installing
##########

:code:`pelican-htmlmin`, is available on pip:

.. code-block::

   $ pip install pelican-htmlmin

After you've installed the package, update the :code:`PLUGINS` variable in your
:code:`pelicanconf.py` to include the package in the next pelican build.

.. code-block:: python

   PLUGINS = [
       # ...
       'pelican-htmlmin',
       # ...
   ]

Options
#######

HTMLMIN_DEBUG
=============

To help with debugging, if Pelican is in DEBUG mode, :code:`pelican-htmlmin`
will not minify files. You can override this using the :code:`HTMLMIN_DEBUG`:

.. code-block:: python

   # minify generated files only if pelican is in DEBUG mode
   HTMLMIN_DEBUG = logger.getEffectiveLevel() == logging.DEBUG

HTMLMIN_MATCH
=============

By default, :code:`pelican-htmlmin` looks for files ending with :code:`.html`
or :code:`.htm` to minify. Use the :code:`HTMLMIN_MATCH` to update the regular
expression that matches with the files you wish to minify.

.. code-block:: python

   HTMLMIN_MATCH = r'.html?$'

HTMLMIN_OPTIONS
===============

If you wish to pass arguments to :code:`htmlmin` directly, use the
:code:`HTMLMIN_OPTIONS` in :code:`{key: value}` form.

.. code-block:: python

   HTMLMIN_OPTIONS = {
       'remove_commends': True,
       'remove_all_empty_space': True,
       'remove_optional_attribute_quotes': False
   }

For more information on the arguments you can give :code:`htmlmin`, see their
`documentation here
<https://htmlmin.readthedocs.io/en/latest/reference.html#main-functions>`_

Contributing
############

Please feel free to help. Issues, pull requests, and `patches via email
<https://bryanbrattlof.com/connect/>`_, all are warmly welcomed.