Skip to content

Instantly share code, notes, and snippets.

@nomatteus
nomatteus / format_html.py
Created October 17, 2011 16:00
Format HTML Using Python (Non-destructive, unlike HTML Tidy)
##
# This is a quick script that will format/indent HTML
# HTML Tidy is often too destructive, especially with bad HTML, so we're using Beautiful Soup
##
# USAGE: Designed to be used on the command line, just pipe HTML to it, and it will output
# cat file.html | python format_html.py
###
# Download & Install Beautiful Soup, if you don't have it already:
# Go to the Beautiful Soup web site, http://www.crummy.com/software/BeautifulSoup/
# Download the package