Giter Club home page Giter Club logo

django-typogrify's Introduction

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.

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
  • dd

Also 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
  • dd

Also 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_quotes

django-typogrify's People

Contributors

dmishe avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.