(Also available on pypi: https://pypi.python.org/pypi/typogrify)
Note: This fork tries to separate the general purpose logic from django
related code so that it can be used with other template engines like
Jinja2.
This application provides a set of custom filters for the Django template system which automatically apply various transformations to plain text in order to yield typographically-improved HTML.
typogrify is designed to work with Django, and so requires a
functioning installation of Django 0.96 or later. Also requires the Python port of John Gruber's SmartyPants for tokenization.
.._ Django: http://www.djangoproject.com/ .._ The Python port of John Gruber's SmartyPants: http://web.chad.org/projects/smartypants.py/
To install a packaged version of typogrify, download the latest package from Google Code_, and -- in the directory in which you
downloaded it -- open a command line and do the following::
tar zxvf typogrify-0.2.tar.gz
cd typogrify-0.2
python setup.py install
This will perform a standard installation of typogrify.
Alternately, you can perform a Subversion checkout of the latest code; execute the following in a directory that's on your Python path::
svn checkout http://typogrify.googlecode.com/svn/trunk/typogrify/
Once typogrify is installed on your system, you can add it to the
INSTALLED_APPS setting of any Django project in which you wish to
use it, and then use {% load typogrify %} in your templates to
load the filters it provides.
.._ the latest package from Google Code: http://typogrify.googlecode.com/files/typogrify-0.1.tar.gz
Wraps ampersands in HTML with <span class="amp"> so they can be
styled with CSS. Ampersands are also normalized to &. Requires
ampersands to have whitespace or an on both sides. Will not
change any ampersand which has already been wrapped in this fashion.
Wraps multiple capital letters in <span class="caps"> so they can
be styled with CSS.
Wraps initial quotes in <span class="dquo"> for double quotes or
<span class="quo"> for single quotes. Works inside these block
elements:
-
h1,h2,h3,h4,h5,h6 -
p -
li -
dt -
dd
Also accounts for potential opening inline elements: a, em,
strong, span, b, i.
Applies SmartyPants.
Applies all of the following filters, in order:
-
amp -
widont -
smartypants -
caps -
initial_quotes
Based on Shaun Inman's PHP utility of the same name, replaces the
space between the last two words in a string with to avoid
a final line of text with only one word.
Works inside these block elements:
-
h1,h2,h3,h4,h5,h6 -
p -
li -
dt -
dd
Also accounts for potential closing inline elements: a, em,
strong, span, b, i.