htmlfy
Python package for HTML minification.
Installation
python3 -mpip install htmlfy
Usage
Minifing HTML markup in variable
>>> import htmlfy
>>> html = """
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>
<p>hello, world!</p>
</body>
</html>"""
>>> htmlfy.minify_html(html)
'<!DOCTYPE html><html><head><title>Hello</title></head><body><p>hello, world!</p></body></html>'
Minifing HTML file
>>> import htmlfy
>>> src_path = 'my_file.html'
>>> dst_path = 'my_file.min.html'
>>> htmlfy.minify_html_file(src_path,dst_path)
Arguments
def htmlfy.minify_html(html,
strict_spaces=True,
no_space_between_tags=True,
preserve=True,
remove_comments=True,
html5_min_attr=True,
html5_emptytags=True
)
def minify_html_file(source_path,minified_path,
strict_spaces=True,
no_space_between_tags=True,
preserve=True,
remove_comments=True,
html5_min_attr=True,
html5_emptytags=True
)
- strict_spaces - strict all spaces(new lines, tabs and etc.) to single space. Except preserved blocks.
- no_space_between_tags - delete all spaces between tags.
- preserve - it will save all formating in
<pre>,<textarea>,<script>tags. Also it will keep PHP expresions like<?php ... ?>and<?=...?> - remove_comments - delete all types of comments from the code also from
<style>and<script>like<!-- ... -->,/* ... */or// comment. You can save the comment using<!--! ... -->format. Expressions comments like<!--[if gte IE 7]>...<![endif]-->will be preserved also. - html5_min_attr - shrink
disabled="disabled",checked="checked",selected="selected"to HTML5 notationdisabled,checkedandselected - html5_emptytags - removes tailing slash in empty tags like
<br />,<img ... />or<input ... />
License
Copyright (c) 2019, Alexey Schebelev
Distributed under The BSD 3-Clause License.
Metadata
Release files for htmlfy 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| htmlfy-0.1.3.tar.gz | 3.0 kB | Without provenance | Details for htmlfy-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| htmlfy-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for htmlfy-0.1.3-py3-none-any.whl |
Total release size: 7.5 kB
Release files / htmlfy-0.1.3.tar.gz
| Download URL | htmlfy-0.1.3.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c94162b24e30af5d333c11f848d4c4f11fd82b07531e38c38ddbd81bd00c63c
|
|
BLAKE2b-256 checksum How to use checksums |
1a302db9b0d1216e5346555237aa275650a7800e7ab86d6d8812b4ea7289f735
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.9.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.2
|
Release files / htmlfy-0.1.3-py3-none-any.whl
| Download URL | htmlfy-0.1.3-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bba81521055172c47e3366b612c00d33165d4c7f9334bc8eae3f41b19faa8cfd
|
|
BLAKE2b-256 checksum How to use checksums |
8cddc8ebefaa482957462286b6f64187fd82319c42f6a6567422ebc4660328c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.9.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.2
|
Security for htmlfy 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.