Login

Tag "tidy"

Snippet List

Prettify HTML5 middleware

Slightly updated version of http://djangosnippets.org/snippets/172/ . Supports new HTML5 tags (even though tidy doesn't).

  • middleware
  • tidy
  • standard
  • html5
Read More

Prettify HTML body contents in HTTP response

This is an enhancement of snippet [#172](http://djangosnippets.org/snippets/172/). Here I use [BeautifulSoup](http://www.crummy.com/software/BeautifulSoup/) — far more easier to install through pip in a virtualenv, and possibly a bit more maintained — to format and properly indent the rendered HTML from templates. I also added a check to only tidy contents in a `DEBUG=True` environment, regarding high impact on performance while doing so in production. Last, it's compatible with Django 1.2.x.

  • templates
  • format
  • html
  • tidy
  • syntax
  • output
  • prettify
  • formatting
  • indentation
  • readability
Read More

prettify html

with this middleware you can use tidy to prettify your html, just add the class to the `MIDDLEWARE_CLASSES` setting. tidy has an enormous number of options, se [Tidy Options Reference](http://tidy.sourceforge.net/docs/quickref.html) . you must have [µTidylib](http://utidylib.berlios.de/) installed.

  • html
  • xhtml
  • tidy
  • standard
Read More

4 snippets posted so far.