Prettierfier

1.0.3 · maintenance · verified Sun Apr 12

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.

Warnings

Install

Imports

Quickstart

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.

import prettierfier

ugly_html = """<p> Introducing GitHub <sup> &reg; </sup> </p>"""
pretty_html = prettierfier.prettify_html(ugly_html)
print(pretty_html)

ugly_xml = """<root><tag1>Text</tag1><tag2 attr='value'></tag2></root>"""
pretty_xml = prettierfier.prettify_xml(ugly_xml, indent=4)
print(pretty_xml)

view raw JSON →