Prettierfier is a Python library designed to intelligently pretty-print HTML/XML strings, specifically addressing the issue of unwanted line breaks that often occur with other tools like BeautifulSoup's `prettify()` method. It focuses on preserving inline tags without introducing extraneous whitespace. The current version is 1.0.3, and its release cadence appears to be inactive, with the last update in 2019, suggesting a stable but unmaintained project.
pip install prettierfierVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `prettierfier.prettify_html()` and `prettierfier.prettify_xml()` to reformat HTML and XML strings, respectively, addressing undesirable whitespace around inline tags or applying indentation.
Ensure you are installing `prettierfier` (for HTML/XML) and not attempting to use it for general Python code formatting, for which alternatives like Black or Ruff are recommended.
For heavily unformatted HTML without existing newlines, `prettierfier` might not introduce all the line breaks you expect for full readability. It works best on HTML that already has some structure or has been partially formatted (e.g., by BeautifulSoup.prettify()) and needs fine-tuning for inline elements.
Evaluate if the specific HTML/XML formatting needs are met by this library. For active development, consider alternative, more actively maintained tools if broader or more robust formatting features are required. Given its simple scope and reliance on standard libraries, it might continue to function well for its intended purpose.
Ensure you have installed the library using pip: `pip install prettierfier`
Use the correct function names: `prettierfier.prettify_html(html_string)` for HTML or `prettierfier.prettify_xml(xml_string)` for XML.
For heavily unformatted HTML or XML, consider a pre-processing step (e.g., using `BeautifulSoup.prettify()` if working with HTML) to introduce initial line breaks before using `prettierfier` to refine inline tag spacing and consolidate unwanted whitespace.
No dependency data recorded yet.