An HTML Minifier, `htmlmin2` is a configurable HTML minifier with safety features. It is a fork of the `htmlmin` library, created to address compatibility issues with modern Python versions, particularly Python 3.13+. The current version is 0.1.13, released in March 2023. While functional and widely used, its release cadence is currently stalled.
pip install htmlmin2Verified import paths — ran on the pinned version, not inferred.
This example demonstrates how to minify a simple HTML string using the `minify` function. By default, it safely removes unnecessary whitespace and comments, preserving the structure and functionality of the HTML.
Use `from htmlmin import minify` after installing `htmlmin2`.
Install `htmlmin2` (`pip install htmlmin2`) instead of the original `htmlmin`.
Carefully test minified output when using aggressive whitespace removal options. Prefer default settings or less aggressive options unless thoroughly validated.
Be aware that updates may be infrequent. Verify compatibility for very new Python versions if they emerge after the last `htmlmin2` release. The Python 3.2 classifier can be ignored as it is a remnant.
Install `htmlmin2` instead of `htmlmin` by running `pip install htmlmin2`. `htmlmin2` was created to address this compatibility issue with modern Python versions.
Ensure your import statements use `htmlmin2` instead of `htmlmin`, for example: `import htmlmin2` instead of `import htmlmin`. If you're using a specific function, it would be `from htmlmin2.main import minify` or `htmlmin2.minify()` if imported directly.
Import the `minify` function directly from its submodule: `from htmlmin2.main import minify`. Then, you can call `minify(html_content)` directly. Alternatively, if you only import `htmlmin2`, you would access it as `htmlmin2.main.minify(html_content)`.
No dependency data recorded yet.