Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrisdrackett/django-typogrify
Typogrify is a collection of Django template filters that help prettify your web typography by preventing ugly quotes and widows and providing CSS hooks to style some special cases.
https://github.com/chrisdrackett/django-typogrify
Last synced: 9 days ago
JSON representation
Typogrify is a collection of Django template filters that help prettify your web typography by preventing ugly quotes and widows and providing CSS hooks to style some special cases.
- Host: GitHub
- URL: https://github.com/chrisdrackett/django-typogrify
- Owner: chrisdrackett
- License: other
- Created: 2009-01-15T19:08:12.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2022-03-20T23:22:25.000Z (over 2 years ago)
- Last Synced: 2024-10-05T07:16:16.937Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 76.2 KB
- Stars: 107
- Watchers: 9
- Forks: 21
- Open Issues: 3
-
Metadata Files:
- Readme: readme.markdown
- License: LICENSE.txt
Awesome Lists containing this project
README
typogrify: Django template filters to make web typography easier
================================================================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.Requirements
============typogrify is designed to work with Django, and so requires a
functioning installation of Django 0.96 or later.* **Django**: http://www.djangoproject.com/
Installation
============1. checkout the project into a folder called `typogrify` on your python path:
git clone [email protected]:chrisdrackett/django-typogrify.git typogrify
2. Add 'typogrify' to your INSTALLED_APPS setting.
Included filters
================amp
---Wraps ampersands in HTML with `` 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.caps
----Wraps multiple capital letters in `` so they can
be styled with CSS.initial_quotes
--------------Wraps initial quotes in `` for double quotes or
`` for single quotes. Works inside these block
elements:* h1, h2, h3, h4, h5, h6
* p
* li
* dt
* ddAlso accounts for potential opening inline elements: a, em,
strong, span, b, i.smartypants
-----------* Straight quotes ( " and ' ) into “curly” quote HTML entities (‘ | ’ | “ | ”)
* Backticks-style quotes (``like this'') into “curly” quote HTML entities (‘ | ’ | “ | ”)
* Dashes (“--” and “---”) into n-dash and m-dash entities (– | —)
* Three consecutive dots (“...”) into an ellipsis entity (…)widont
------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
* ddAlso accounts for potential closing inline elements: a, em,
strong, span, b, i.titlecase
---------http://daringfireball.net/2008/05/title_case
number_suffix
-------------wraps number suffix's in `` so they can be styled.
fuzzydate
---------
(uses code from http://djangosnippets.org/snippets/1347/)Returns the date in a more human readable format:
* Today
* Yesterday
* 4 days ago
* 3 weeks ago
* in 3 years
* etc.typogrify
---------Applies all of the following filters, in order:
* force_unicode (from django.utils.encoding)
* amp
* widont
* smartypants
* caps
* initial_quotesExamples
========Apply all `django-typogrify` filters to template output:
{% load typogrify_tags %}
{{ blog_post.contents|typogrify }}