diff -Nru typogrify-20111209/debian/changelog typogrify-2.0.4/debian/changelog --- typogrify-20111209/debian/changelog 2011-12-20 07:39:29.000000000 -0800 +++ typogrify-2.0.4/debian/changelog 2014-08-24 15:19:24.000000000 -0700 @@ -1,3 +1,14 @@ +typogrify (1:2.0.4-0.1) unstable; urgency=medium + + * Non-maintainer upload. + * New upstream release (Closes: #744978). + - New upstream version scheme requires adding an epoch. + * Add debian/watch file. + * Update homepage. + * Build Python 3 package. + + -- Andrew Starr-Bochicchio Sun, 24 Aug 2014 15:19:19 -0700 + typogrify (20111209-2) unstable; urgency=low * Build-Depends on python-setuptools (Closes: #652789) diff -Nru typogrify-20111209/debian/control typogrify-2.0.4/debian/control --- typogrify-20111209/debian/control 2011-12-20 07:39:29.000000000 -0800 +++ typogrify-2.0.4/debian/control 2014-08-24 15:15:12.000000000 -0700 @@ -2,17 +2,35 @@ Section: python Priority: extra Maintainer: Julien Danjou -Build-Depends: debhelper (>= 8.0.0), python, python-setuptools, python-smartypants +Build-Depends: debhelper (>= 8.0.0), + dh-python, + python-all (>= 2.6.6-3~), + python-setuptools, + python-smartypants, + python3-all, + python3-setuptools, + python3-smartypants Standards-Version: 3.9.2 -Homepage: https://github.com/hyde/typogrify +Homepage: https://github.com/mintchaos/typogrify Vcs-Git: git://git.debian.org/collab-maint/typogrify.git Vcs-Browser: http://git.debian.org/?p=collab-maint/typogrify.git;a=summary Package: python-typogrify Architecture: all Recommends: python-jinja2 -Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends} +Depends: ${misc:Depends}, ${python:Depends}, ${shlibs:Depends} Description: filters to transform text into typographically-improved HTML This 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. + +Package: python3-typogrify +Architecture: all +Recommends: python3-jinja2 +Depends: ${misc:Depends}, ${python3:Depends}, ${shlibs:Depends} +Description: filters to transform text into typographically-improved HTML (Python 3) + This 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. + . + This is the Python 3 version of the package. diff -Nru typogrify-20111209/debian/docs typogrify-2.0.4/debian/docs --- typogrify-20111209/debian/docs 2011-12-20 07:39:29.000000000 -0800 +++ typogrify-2.0.4/debian/docs 2014-08-24 14:16:54.000000000 -0700 @@ -1 +1 @@ -README.markdown +README.rst diff -Nru typogrify-20111209/debian/rules typogrify-2.0.4/debian/rules --- typogrify-20111209/debian/rules 2011-12-20 07:39:29.000000000 -0800 +++ typogrify-2.0.4/debian/rules 2014-08-24 15:13:19.000000000 -0700 @@ -1,9 +1,7 @@ #!/usr/bin/make -f # -*- makefile -*- -%: - dh $@ --with python2 +export PYBUILD_NAME=typogrify -override_dh_clean: - rm -rf typogrify.egg-info - dh_clean +%: + dh $@ --with python2,python3 --buildsystem=pybuild diff -Nru typogrify-20111209/debian/watch typogrify-2.0.4/debian/watch --- typogrify-20111209/debian/watch 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/debian/watch 2014-08-24 14:14:20.000000000 -0700 @@ -0,0 +1,2 @@ +version=3 +http://pypi.python.org/packages/source/t/typogrify/typogrify-(.*)\.tar\.gz diff -Nru typogrify-20111209/.git/config typogrify-2.0.4/.git/config --- typogrify-20111209/.git/config 2011-12-09 06:04:04.000000000 -0800 +++ typogrify-2.0.4/.git/config 1969-12-31 16:00:00.000000000 -0800 @@ -1,11 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true -[remote "origin"] - fetch = +refs/heads/*:refs/remotes/origin/* - url = https://github.com/hyde/typogrify.git -[branch "master"] - remote = origin - merge = refs/heads/master diff -Nru typogrify-20111209/.git/description typogrify-2.0.4/.git/description --- typogrify-20111209/.git/description 2011-12-09 06:02:53.000000000 -0800 +++ typogrify-2.0.4/.git/description 1969-12-31 16:00:00.000000000 -0800 @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff -Nru typogrify-20111209/.git/HEAD typogrify-2.0.4/.git/HEAD --- typogrify-20111209/.git/HEAD 2011-12-09 06:04:07.000000000 -0800 +++ typogrify-2.0.4/.git/HEAD 1969-12-31 16:00:00.000000000 -0800 @@ -1 +0,0 @@ -ref: refs/heads/debian/unstable diff -Nru typogrify-20111209/.git/hooks/applypatch-msg.sample typogrify-2.0.4/.git/hooks/applypatch-msg.sample --- typogrify-20111209/.git/hooks/applypatch-msg.sample 2011-12-09 06:02:53.000000000 -0800 +++ typogrify-2.0.4/.git/hooks/applypatch-msg.sample 1969-12-31 16:00:00.000000000 -0800 @@ -1,15 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message taken by -# applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. The hook is -# allowed to edit the commit message file. -# -# To enable this hook, rename this file to "applypatch-msg". - -. git-sh-setup -test -x "$GIT_DIR/hooks/commit-msg" && - exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} -: diff -Nru typogrify-20111209/.git/hooks/commit-msg.sample typogrify-2.0.4/.git/hooks/commit-msg.sample --- typogrify-20111209/.git/hooks/commit-msg.sample 2011-12-09 06:02:53.000000000 -0800 +++ typogrify-2.0.4/.git/hooks/commit-msg.sample 1969-12-31 16:00:00.000000000 -0800 @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message. -# Called by "git commit" with one argument, the name of the file -# that has the commit message. The hook should exit with non-zero -# status after issuing an appropriate message if it wants to stop the -# commit. The hook is allowed to edit the commit message file. -# -# To enable this hook, rename this file to "commit-msg". - -# Uncomment the below to add a Signed-off-by line to the message. -# Doing this in a hook is a bad idea in general, but the prepare-commit-msg -# hook is more suited to it. -# -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" - -# This example catches duplicate Signed-off-by lines. - -test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { - echo >&2 Duplicate Signed-off-by lines. - exit 1 -} diff -Nru typogrify-20111209/.git/hooks/post-update.sample typogrify-2.0.4/.git/hooks/post-update.sample --- typogrify-20111209/.git/hooks/post-update.sample 2011-12-09 06:02:53.000000000 -0800 +++ typogrify-2.0.4/.git/hooks/post-update.sample 1969-12-31 16:00:00.000000000 -0800 @@ -1,8 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare a packed repository for use over -# dumb transports. -# -# To enable this hook, rename this file to "post-update". - -exec git update-server-info diff -Nru typogrify-20111209/.git/hooks/pre-applypatch.sample typogrify-2.0.4/.git/hooks/pre-applypatch.sample --- typogrify-20111209/.git/hooks/pre-applypatch.sample 2011-12-09 06:02:53.000000000 -0800 +++ typogrify-2.0.4/.git/hooks/pre-applypatch.sample 1969-12-31 16:00:00.000000000 -0800 @@ -1,14 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed -# by applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-applypatch". - -. git-sh-setup -test -x "$GIT_DIR/hooks/pre-commit" && - exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} -: diff -Nru typogrify-20111209/.git/hooks/pre-commit.sample typogrify-2.0.4/.git/hooks/pre-commit.sample --- typogrify-20111209/.git/hooks/pre-commit.sample 2011-12-09 06:02:53.000000000 -0800 +++ typogrify-2.0.4/.git/hooks/pre-commit.sample 1969-12-31 16:00:00.000000000 -0800 @@ -1,50 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-commit". - -if git rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - -# If you want to allow non-ascii filenames set this variable to true. -allownonascii=$(git config hooks.allownonascii) - -# Redirect output to stderr. -exec 1>&2 - -# Cross platform projects tend to avoid non-ascii filenames; prevent -# them from being added to the repository. We exploit the fact that the -# printable range starts at the space character and ends with tilde. -if [ "$allownonascii" != "true" ] && - # Note that the use of brackets around a tr range is ok here, (it's - # even required, for portability to Solaris 10's /usr/bin/tr), since - # the square bracket bytes happen to fall in the designated range. - test $(git diff --cached --name-only --diff-filter=A -z $against | - LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 -then - echo "Error: Attempt to add a non-ascii file name." - echo - echo "This can cause problems if you want to work" - echo "with people on other platforms." - echo - echo "To be portable it is advisable to rename the file ..." - echo - echo "If you know what you are doing you can disable this" - echo "check using:" - echo - echo " git config hooks.allownonascii true" - echo - exit 1 -fi - -# If there are whitespace errors, print the offending file names and fail. -exec git diff-index --check --cached $against -- diff -Nru typogrify-20111209/.git/hooks/prepare-commit-msg.sample typogrify-2.0.4/.git/hooks/prepare-commit-msg.sample --- typogrify-20111209/.git/hooks/prepare-commit-msg.sample 2011-12-09 06:02:53.000000000 -0800 +++ typogrify-2.0.4/.git/hooks/prepare-commit-msg.sample 1969-12-31 16:00:00.000000000 -0800 @@ -1,36 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare the commit log message. -# Called by "git commit" with the name of the file that has the -# commit message, followed by the description of the commit -# message's source. The hook's purpose is to edit the commit -# message file. If the hook fails with a non-zero status, -# the commit is aborted. -# -# To enable this hook, rename this file to "prepare-commit-msg". - -# This hook includes three examples. The first comments out the -# "Conflicts:" part of a merge commit. -# -# The second includes the output of "git diff --name-status -r" -# into the message, just before the "git status" output. It is -# commented because it doesn't cope with --amend or with squashed -# commits. -# -# The third example adds a Signed-off-by line to the message, that can -# still be edited. This is rarely a good idea. - -case "$2,$3" in - merge,) - /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; - -# ,|template,) -# /usr/bin/perl -i.bak -pe ' -# print "\n" . `git diff --cached --name-status -r` -# if /^#/ && $first++ == 0' "$1" ;; - - *) ;; -esac - -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff -Nru typogrify-20111209/.git/hooks/pre-rebase.sample typogrify-2.0.4/.git/hooks/pre-rebase.sample --- typogrify-20111209/.git/hooks/pre-rebase.sample 2011-12-09 06:02:53.000000000 -0800 +++ typogrify-2.0.4/.git/hooks/pre-rebase.sample 1969-12-31 16:00:00.000000000 -0800 @@ -1,172 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006, 2008 Junio C Hamano -# -# The "pre-rebase" hook is run just before "git rebase" starts doing -# its job, and can prevent the command from running by exiting with -# non-zero status. -# -# The hook is called with the following parameters: -# -# $1 -- the upstream the series was forked from. -# $2 -- the branch being rebased (or empty when rebasing the current branch). -# -# This sample shows how to prevent topic branches that are already -# merged to 'next' branch from getting rebased, because allowing it -# would result in rebasing already published history. - -publish=next -basebranch="$1" -if test "$#" = 2 -then - topic="refs/heads/$2" -else - topic=`git symbolic-ref HEAD` || - exit 0 ;# we do not interrupt rebasing detached HEAD -fi - -case "$topic" in -refs/heads/??/*) - ;; -*) - exit 0 ;# we do not interrupt others. - ;; -esac - -# Now we are dealing with a topic branch being rebased -# on top of master. Is it OK to rebase it? - -# Does the topic really exist? -git show-ref -q "$topic" || { - echo >&2 "No such branch $topic" - exit 1 -} - -# Is topic fully merged to master? -not_in_master=`git rev-list --pretty=oneline ^master "$topic"` -if test -z "$not_in_master" -then - echo >&2 "$topic is fully merged to master; better remove it." - exit 1 ;# we could allow it, but there is no point. -fi - -# Is topic ever merged to next? If so you should not be rebasing it. -only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` -only_next_2=`git rev-list ^master ${publish} | sort` -if test "$only_next_1" = "$only_next_2" -then - not_in_topic=`git rev-list "^$topic" master` - if test -z "$not_in_topic" - then - echo >&2 "$topic is already up-to-date with master" - exit 1 ;# we could allow it, but there is no point. - else - exit 0 - fi -else - not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` - /usr/bin/perl -e ' - my $topic = $ARGV[0]; - my $msg = "* $topic has commits already merged to public branch:\n"; - my (%not_in_next) = map { - /^([0-9a-f]+) /; - ($1 => 1); - } split(/\n/, $ARGV[1]); - for my $elem (map { - /^([0-9a-f]+) (.*)$/; - [$1 => $2]; - } split(/\n/, $ARGV[2])) { - if (!exists $not_in_next{$elem->[0]}) { - if ($msg) { - print STDERR $msg; - undef $msg; - } - print STDERR " $elem->[1]\n"; - } - } - ' "$topic" "$not_in_next" "$not_in_master" - exit 1 -fi - -exit 0 - -<<\DOC_END -################################################################ - -This sample hook safeguards topic branches that have been -published from being rewound. - -The workflow assumed here is: - - * Once a topic branch forks from "master", "master" is never - merged into it again (either directly or indirectly). - - * Once a topic branch is fully cooked and merged into "master", - it is deleted. If you need to build on top of it to correct - earlier mistakes, a new topic branch is created by forking at - the tip of the "master". This is not strictly necessary, but - it makes it easier to keep your history simple. - - * Whenever you need to test or publish your changes to topic - branches, merge them into "next" branch. - -The script, being an example, hardcodes the publish branch name -to be "next", but it is trivial to make it configurable via -$GIT_DIR/config mechanism. - -With this workflow, you would want to know: - -(1) ... if a topic branch has ever been merged to "next". Young - topic branches can have stupid mistakes you would rather - clean up before publishing, and things that have not been - merged into other branches can be easily rebased without - affecting other people. But once it is published, you would - not want to rewind it. - -(2) ... if a topic branch has been fully merged to "master". - Then you can delete it. More importantly, you should not - build on top of it -- other people may already want to - change things related to the topic as patches against your - "master", so if you need further changes, it is better to - fork the topic (perhaps with the same name) afresh from the - tip of "master". - -Let's look at this example: - - o---o---o---o---o---o---o---o---o---o "next" - / / / / - / a---a---b A / / - / / / / - / / c---c---c---c B / - / / / \ / - / / / b---b C \ / - / / / / \ / - ---o---o---o---o---o---o---o---o---o---o---o "master" - - -A, B and C are topic branches. - - * A has one fix since it was merged up to "next". - - * B has finished. It has been fully merged up to "master" and "next", - and is ready to be deleted. - - * C has not merged to "next" at all. - -We would want to allow C to be rebased, refuse A, and encourage -B to be deleted. - -To compute (1): - - git rev-list ^master ^topic next - git rev-list ^master next - - if these match, topic has not merged in next at all. - -To compute (2): - - git rev-list master..topic - - if this is empty, it is fully merged to "master". - -DOC_END diff -Nru typogrify-20111209/.git/hooks/update.sample typogrify-2.0.4/.git/hooks/update.sample --- typogrify-20111209/.git/hooks/update.sample 2011-12-09 06:02:53.000000000 -0800 +++ typogrify-2.0.4/.git/hooks/update.sample 1969-12-31 16:00:00.000000000 -0800 @@ -1,128 +0,0 @@ -#!/bin/sh -# -# An example hook script to blocks unannotated tags from entering. -# Called by "git receive-pack" with arguments: refname sha1-old sha1-new -# -# To enable this hook, rename this file to "update". -# -# Config -# ------ -# hooks.allowunannotated -# This boolean sets whether unannotated tags will be allowed into the -# repository. By default they won't be. -# hooks.allowdeletetag -# This boolean sets whether deleting tags will be allowed in the -# repository. By default they won't be. -# hooks.allowmodifytag -# This boolean sets whether a tag may be modified after creation. By default -# it won't be. -# hooks.allowdeletebranch -# This boolean sets whether deleting branches will be allowed in the -# repository. By default they won't be. -# hooks.denycreatebranch -# This boolean sets whether remotely creating branches will be denied -# in the repository. By default this is allowed. -# - -# --- Command line -refname="$1" -oldrev="$2" -newrev="$3" - -# --- Safety check -if [ -z "$GIT_DIR" ]; then - echo "Don't run this script from the command line." >&2 - echo " (if you want, you could supply GIT_DIR then run" >&2 - echo " $0 )" >&2 - exit 1 -fi - -if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then - echo "Usage: $0 " >&2 - exit 1 -fi - -# --- Config -allowunannotated=$(git config --bool hooks.allowunannotated) -allowdeletebranch=$(git config --bool hooks.allowdeletebranch) -denycreatebranch=$(git config --bool hooks.denycreatebranch) -allowdeletetag=$(git config --bool hooks.allowdeletetag) -allowmodifytag=$(git config --bool hooks.allowmodifytag) - -# check for no description -projectdesc=$(sed -e '1q' "$GIT_DIR/description") -case "$projectdesc" in -"Unnamed repository"* | "") - echo "*** Project description file hasn't been set" >&2 - exit 1 - ;; -esac - -# --- Check types -# if $newrev is 0000...0000, it's a commit to delete a ref. -zero="0000000000000000000000000000000000000000" -if [ "$newrev" = "$zero" ]; then - newrev_type=delete -else - newrev_type=$(git cat-file -t $newrev) -fi - -case "$refname","$newrev_type" in - refs/tags/*,commit) - # un-annotated tag - short_refname=${refname##refs/tags/} - if [ "$allowunannotated" != "true" ]; then - echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 - echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 - exit 1 - fi - ;; - refs/tags/*,delete) - # delete tag - if [ "$allowdeletetag" != "true" ]; then - echo "*** Deleting a tag is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/tags/*,tag) - # annotated tag - if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 - then - echo "*** Tag '$refname' already exists." >&2 - echo "*** Modifying a tag is not allowed in this repository." >&2 - exit 1 - fi - ;; - refs/heads/*,commit) - # branch - if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then - echo "*** Creating a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/heads/*,delete) - # delete branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/remotes/*,commit) - # tracking branch - ;; - refs/remotes/*,delete) - # delete tracking branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a tracking branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - *) - # Anything else (is there anything else?) - echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 - exit 1 - ;; -esac - -# --- Finished -exit 0 Binary files /tmp/4wBT4soLgT/typogrify-20111209/.git/index and /tmp/4WOSkgdkb5/typogrify-2.0.4/.git/index differ diff -Nru typogrify-20111209/.git/info/exclude typogrify-2.0.4/.git/info/exclude --- typogrify-20111209/.git/info/exclude 2011-12-09 06:02:53.000000000 -0800 +++ typogrify-2.0.4/.git/info/exclude 1969-12-31 16:00:00.000000000 -0800 @@ -1,6 +0,0 @@ -# git ls-files --others --exclude-from=.git/info/exclude -# Lines that start with '#' are comments. -# For a project mostly in C, the following would be a good set of -# exclude patterns (uncomment them if you want to use them): -# *.[oa] -# *~ diff -Nru typogrify-20111209/.git/logs/HEAD typogrify-2.0.4/.git/logs/HEAD --- typogrify-20111209/.git/logs/HEAD 2011-12-09 06:04:07.000000000 -0800 +++ typogrify-2.0.4/.git/logs/HEAD 1969-12-31 16:00:00.000000000 -0800 @@ -1,2 +0,0 @@ -0000000000000000000000000000000000000000 6937a8a6e60b305abe23a1be70a3c496e4d5b8ac Julien Danjou 1323439378 +0100 clone: from https://github.com/hyde/typogrify.git -6937a8a6e60b305abe23a1be70a3c496e4d5b8ac 6937a8a6e60b305abe23a1be70a3c496e4d5b8ac Julien Danjou 1323439447 +0100 checkout: moving from master to debian/unstable diff -Nru typogrify-20111209/.git/logs/refs/heads/debian/unstable typogrify-2.0.4/.git/logs/refs/heads/debian/unstable --- typogrify-20111209/.git/logs/refs/heads/debian/unstable 2011-12-09 06:04:04.000000000 -0800 +++ typogrify-2.0.4/.git/logs/refs/heads/debian/unstable 1969-12-31 16:00:00.000000000 -0800 @@ -1,2 +0,0 @@ -0000000000000000000000000000000000000000 6937a8a6e60b305abe23a1be70a3c496e4d5b8ac Julien Danjou 1323439439 +0100 branch: Created from master -6937a8a6e60b305abe23a1be70a3c496e4d5b8ac 6937a8a6e60b305abe23a1be70a3c496e4d5b8ac Julien Danjou 1323439444 +0100 Branch: renamed refs/heads/debian/uns to refs/heads/debian/unstable diff -Nru typogrify-20111209/.git/logs/refs/heads/master typogrify-2.0.4/.git/logs/refs/heads/master --- typogrify-20111209/.git/logs/refs/heads/master 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/.git/logs/refs/heads/master 1969-12-31 16:00:00.000000000 -0800 @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 6937a8a6e60b305abe23a1be70a3c496e4d5b8ac Julien Danjou 1323439378 +0100 clone: from https://github.com/hyde/typogrify.git Binary files /tmp/4wBT4soLgT/typogrify-20111209/.git/objects/pack/pack-4417a02b4bd7815a6fd96728103780345edaa301.idx and /tmp/4WOSkgdkb5/typogrify-2.0.4/.git/objects/pack/pack-4417a02b4bd7815a6fd96728103780345edaa301.idx differ Binary files /tmp/4wBT4soLgT/typogrify-20111209/.git/objects/pack/pack-4417a02b4bd7815a6fd96728103780345edaa301.pack and /tmp/4WOSkgdkb5/typogrify-2.0.4/.git/objects/pack/pack-4417a02b4bd7815a6fd96728103780345edaa301.pack differ diff -Nru typogrify-20111209/.git/packed-refs typogrify-2.0.4/.git/packed-refs --- typogrify-20111209/.git/packed-refs 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/.git/packed-refs 1969-12-31 16:00:00.000000000 -0800 @@ -1,3 +0,0 @@ -# pack-refs with: peeled -6937a8a6e60b305abe23a1be70a3c496e4d5b8ac refs/remotes/origin/master -5ff449b6fbc5a0f53afb0e664c9e90b4b1921472 refs/remotes/origin/hyde-setup diff -Nru typogrify-20111209/.git/refs/heads/debian/unstable typogrify-2.0.4/.git/refs/heads/debian/unstable --- typogrify-20111209/.git/refs/heads/debian/unstable 2011-12-09 06:04:04.000000000 -0800 +++ typogrify-2.0.4/.git/refs/heads/debian/unstable 1969-12-31 16:00:00.000000000 -0800 @@ -1 +0,0 @@ -6937a8a6e60b305abe23a1be70a3c496e4d5b8ac diff -Nru typogrify-20111209/.git/refs/heads/master typogrify-2.0.4/.git/refs/heads/master --- typogrify-20111209/.git/refs/heads/master 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/.git/refs/heads/master 1969-12-31 16:00:00.000000000 -0800 @@ -1 +0,0 @@ -6937a8a6e60b305abe23a1be70a3c496e4d5b8ac diff -Nru typogrify-20111209/.git/refs/remotes/origin/HEAD typogrify-2.0.4/.git/refs/remotes/origin/HEAD --- typogrify-20111209/.git/refs/remotes/origin/HEAD 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/.git/refs/remotes/origin/HEAD 1969-12-31 16:00:00.000000000 -0800 @@ -1 +0,0 @@ -ref: refs/remotes/origin/master diff -Nru typogrify-20111209/.gitignore typogrify-2.0.4/.gitignore --- typogrify-20111209/.gitignore 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/.gitignore 1969-12-31 16:00:00.000000000 -0800 @@ -1,4 +0,0 @@ -*.egg-info/ -*.py[co] -build/ -dist/ diff -Nru typogrify-20111209/INSTALL.txt typogrify-2.0.4/INSTALL.txt --- typogrify-20111209/INSTALL.txt 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/INSTALL.txt 1969-12-31 16:00:00.000000000 -0800 @@ -1,16 +0,0 @@ -Thanks for downloading typogrify. - -To install it, run the following command inside this directory:: - - python setup.py install - -Or simply move the typogrify folder into your python path. - -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. - -Note that this application requires Python 2.3 or later, and Django -0.96 or later; you can obtain Python from http://www.python.org/ and -Django from http://www.djangoproject.com/. \ No newline at end of file diff -Nru typogrify-20111209/LICENSE.txt typogrify-2.0.4/LICENSE.txt --- typogrify-20111209/LICENSE.txt 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/LICENSE.txt 2014-01-07 12:15:24.000000000 -0800 @@ -1,4 +1,5 @@ Copyright (c) 2007, Christian Metts +Updates copyright (c) 2014, Justin Mayer All rights reserved. Redistribution and use in source and binary forms, with or without @@ -25,4 +26,4 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff -Nru typogrify-20111209/MANIFEST.in typogrify-2.0.4/MANIFEST.in --- typogrify-20111209/MANIFEST.in 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/MANIFEST.in 2014-01-07 12:15:24.000000000 -0800 @@ -1,3 +1,2 @@ -include INSTALL.txt include LICENSE.txt -recursive-include docs * \ No newline at end of file +include README.rst diff -Nru typogrify-20111209/PKG-INFO typogrify-2.0.4/PKG-INFO --- typogrify-20111209/PKG-INFO 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/PKG-INFO 2014-02-21 08:49:54.000000000 -0800 @@ -0,0 +1,156 @@ +Metadata-Version: 1.1 +Name: typogrify +Version: 2.0.4 +Summary: Filters to enhance web typography, including support for Django & Jinja templates +Home-page: https://github.com/mintchaos/typogrify +Author: Christian Metts, Justin Mayer, Chris Drackett +Author-email: chris@tiltshiftstudio.com +License: BSD +Description: Typogrify provides a set of custom filters that automatically apply various + transformations to plain text in order to yield typographically-improved HTML. + While often used in conjunction with Jinja_ and Django_ template systems, the + filters can be used in any environment. + + .. _Jinja: http://jinja.pocoo.org/ + .. _Django: https://www.djangoproject.com/ + + + Installation + ============ + + The following command will install via ``pip``. Pay particular attention to the + package name:: + + pip install typogrify + + Alternatively, you can run the following command inside the project's root + directory:: + + python setup.py install + + Last but not least, you can simply move the enclosed ``typogrify`` folder + into your Python path. + + + Requirements + ============ + + Python 2.3 and above is supported, including Python 3. The only dependency is + SmartyPants_, a Python port of a project by John Gruber. + + Installing Jinja_ or Django_ is only required if you intend to use the optional + template filters that are included for those frameworks. + + .. _SmartyPants: http://web.chad.org/projects/smartypants.py/ + + + Usage + ===== + + The filters can be used in any environment by importing them from + ``typogrify.filters``:: + + from typogrify.filters import typogrify + content = typogrify(content) + + For use with Django, you can add ``typogrify`` to the ``INSTALLED_APPS`` setting + of any Django project in which you wish to use it, and then use + ``{% load typogrify_tags %}`` in your templates to load the filters it provides. + + Experimental support for Jinja is in ``typogrify.templatetags.jinja_filters``. + + + 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`` + --------------- + + Applies ``SmartyPants``. + + + ``typogrify`` + ------------- + + Applies all of the following filters, in order: + + * ``amp`` + + * ``widont`` + + * ``smartypants`` + + * ``caps`` + + * ``initial_quotes`` + + + ``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``. + +Platform: UNKNOWN +Classifier: Development Status :: 5 - Production/Stable +Classifier: Environment :: Web Environment +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: BSD License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Framework :: Django +Classifier: Framework :: Flask +Classifier: Topic :: Utilities diff -Nru typogrify-20111209/README.markdown typogrify-2.0.4/README.markdown --- typogrify-20111209/README.markdown 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/README.markdown 1969-12-31 16:00:00.000000000 -0800 @@ -1,134 +0,0 @@ - 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. - -typogrify: 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. 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/ - - -Installation -============ - -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 - - -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`` ---------------- - -Applies ``SmartyPants``. - - -``typogrify`` -------------- - -Applies all of the following filters, in order: - -* ``amp`` - -* ``widont`` - -* ``smartypants`` - -* ``caps`` - -* ``initial_quotes`` - - -``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``. diff -Nru typogrify-20111209/README.rst typogrify-2.0.4/README.rst --- typogrify-20111209/README.rst 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/README.rst 2014-02-04 18:09:44.000000000 -0800 @@ -0,0 +1,137 @@ +Typogrify provides a set of custom filters that automatically apply various +transformations to plain text in order to yield typographically-improved HTML. +While often used in conjunction with Jinja_ and Django_ template systems, the +filters can be used in any environment. + +.. _Jinja: http://jinja.pocoo.org/ +.. _Django: https://www.djangoproject.com/ + + +Installation +============ + +The following command will install via ``pip``. Pay particular attention to the +package name:: + + pip install typogrify + +Alternatively, you can run the following command inside the project's root +directory:: + + python setup.py install + +Last but not least, you can simply move the enclosed ``typogrify`` folder +into your Python path. + + +Requirements +============ + +Python 2.3 and above is supported, including Python 3. The only dependency is +SmartyPants_, a Python port of a project by John Gruber. + +Installing Jinja_ or Django_ is only required if you intend to use the optional +template filters that are included for those frameworks. + +.. _SmartyPants: http://web.chad.org/projects/smartypants.py/ + + +Usage +===== + +The filters can be used in any environment by importing them from +``typogrify.filters``:: + + from typogrify.filters import typogrify + content = typogrify(content) + +For use with Django, you can add ``typogrify`` to the ``INSTALLED_APPS`` setting +of any Django project in which you wish to use it, and then use +``{% load typogrify_tags %}`` in your templates to load the filters it provides. + +Experimental support for Jinja is in ``typogrify.templatetags.jinja_filters``. + + +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`` +--------------- + +Applies ``SmartyPants``. + + +``typogrify`` +------------- + +Applies all of the following filters, in order: + +* ``amp`` + +* ``widont`` + +* ``smartypants`` + +* ``caps`` + +* ``initial_quotes`` + + +``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``. diff -Nru typogrify-20111209/setup.cfg typogrify-2.0.4/setup.cfg --- typogrify-20111209/setup.cfg 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/setup.cfg 2014-02-21 08:49:54.000000000 -0800 @@ -0,0 +1,8 @@ +[wheel] +universal = 1 + +[egg_info] +tag_build = +tag_date = 0 +tag_svn_revision = 0 + diff -Nru typogrify-20111209/setup.py typogrify-2.0.4/setup.py --- typogrify-20111209/setup.py 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/setup.py 2014-02-21 08:43:07.000000000 -0800 @@ -1,14 +1,16 @@ -from setuptools import setup, find_packages +#!/usr/bin/env python +from setuptools import setup, find_packages setup( name='typogrify', - version='1.0.1a', + version=__import__('typogrify').__version__, packages=find_packages(), - author='Christian Metts', - author_email='xian@mintchaos.com', + author='Christian Metts, Justin Mayer, Chris Drackett', + author_email='chris@tiltshiftstudio.com', license='BSD', - description='Typography related template filters for Django & Jinja2 applications', + description='Filters to enhance web typography, including support for Django & Jinja templates', + long_description=open('README.rst').read(), url='https://github.com/mintchaos/typogrify', classifiers=[ 'Development Status :: 5 - Production/Stable', @@ -18,8 +20,10 @@ 'Operating System :: OS Independent', 'Programming Language :: Python', 'Framework :: Django', + 'Framework :: Flask', 'Topic :: Utilities' ], - - install_requires=['smartypants>=1.6'] -) \ No newline at end of file + install_requires=[ + 'smartypants>=1.8.3' + ], +) diff -Nru typogrify-20111209/typogrify/filters.py typogrify-2.0.4/typogrify/filters.py --- typogrify-20111209/typogrify/filters.py 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify/filters.py 2014-02-21 08:43:07.000000000 -0800 @@ -0,0 +1,315 @@ +import re +from typogrify.packages.titlecase import titlecase # NOQA + +class TypogrifyError(Exception): + """ A base error class so we can catch or scilence typogrify's errors in templates """ + pass + +def process_ignores(text, ignore_tags=None): + """ Creates a list of tuples based on tags to be ignored. + Tags can be added as a list in the `ignore_tags`. + Returns in the following format: + + [ + ('Text here', ), + ('Text here', ), + ] + + >>> process_ignores('
processed

processed

') + [('
processed
', False), ('

processed

', True)] + >>> process_ignores('processed

processed

processed

') + [('processed', False), ('

processed', True), ('

processed
', False), ('

', True)] + >>> process_ignores('processed

processed

processed

',['p']) + [('processed', False), ('

processed

processed

', False)] + """ + + position = 0 + sections = [] + if ignore_tags is None: + ignore_tags = [] + + ignore_tags = ignore_tags + ['pre', 'code'] # default tags + ignore_regex = r'<(%s)(?:\s.*?)?>.*?' % '|'.join(ignore_tags) + ignore_finder = re.compile(ignore_regex, re.IGNORECASE | re.DOTALL) + + for section in ignore_finder.finditer(text): + start, end = section.span() + + if position != start: + # if the current position isn't the match we + # need to process everything in between + sections.append((text[position:start], True)) + + # now we mark the matched section as ignored + sections.append((text[start:end], False)) + + position = end + + # match the rest of the text if necessary + # (this could in fact be the entire string) + if position < len(text): + sections.append((text[position:len(text)], True)) + + return sections + +def amp(text): + """Wraps apersands in HTML with ```` so they can be + styled with CSS. Apersands are also normalized to ``&``. Requires + ampersands to have whitespace or an `` `` on both sides. + + >>> amp('One & two') + 'One & two' + >>> amp('One & two') + 'One & two' + >>> amp('One & two') + 'One & two' + + >>> amp('One & two') + 'One & two' + + It won't mess up & that are already wrapped, in entities or URLs + + >>> amp('One & two') + 'One & two' + >>> amp('“this” & that') + '“this” & that' + + It should ignore standalone amps that are in attributes + >>> amp('xyz') + 'xyz' + """ + # tag_pattern from http://haacked.com/archive/2004/10/25/usingregularexpressionstomatchhtml.aspx + # it kinda sucks but it fixes the standalone amps in attributes bug + tag_pattern = '\s]+))?)+\s*|\s*)/?>' + amp_finder = re.compile(r"(\s| )(&|&|&\#38;)(\s| )") + intra_tag_finder = re.compile(r'(?P(%s)?)(?P([^<]*))(?P(%s)?)' % (tag_pattern, tag_pattern)) + + def _amp_process(groups): + prefix = groups.group('prefix') or '' + text = amp_finder.sub(r"""\1&\3""", groups.group('text')) + suffix = groups.group('suffix') or '' + return prefix + text + suffix + + output = intra_tag_finder.sub(_amp_process, text) + return output + + +def caps(text): + """Wraps multiple capital letters in ```` + so they can be styled with CSS. + + >>> caps("A message from KU") + 'A message from KU' + + Uses the smartypants tokenizer to not screw with HTML or with tags it shouldn't. + + >>> caps("
CAPS
more CAPS") + '
CAPS
more CAPS' + + >>> caps("A message from 2KU2 with digits") + 'A message from 2KU2 with digits' + + >>> caps("Dotted caps followed by spaces should never include them in the wrap D.O.T. like so.") + 'Dotted caps followed by spaces should never include them in the wrap D.O.T. like so.' + + All caps with with apostrophes in them shouldn't break. Only handles dump apostrophes though. + >>> caps("JIMMY'S") + 'JIMMY\\'S' + + >>> caps("D.O.T.HE34TRFID") + 'D.O.T.HE34TRFID' + """ + try: + import smartypants + except ImportError: + raise TypogrifyError("Error in {% caps %} filter: The Python SmartyPants library isn't installed.") + + tokens = smartypants._tokenize(text) + result = [] + in_skipped_tag = False + + cap_finder = re.compile(r"""( + (\b[A-Z\d]* # Group 2: Any amount of caps and digits + [A-Z]\d*[A-Z] # A cap string much at least include two caps (but they can have digits between them) + [A-Z\d']*\b) # Any amount of caps and digits or dumb apostsrophes + | (\b[A-Z]+\.\s? # OR: Group 3: Some caps, followed by a '.' and an optional space + (?:[A-Z]+\.\s?)+) # Followed by the same thing at least once more + (?:\s|\b|$)) + """, re.VERBOSE) + + def _cap_wrapper(matchobj): + """This is necessary to keep dotted cap strings to pick up extra spaces""" + if matchobj.group(2): + return """%s""" % matchobj.group(2) + else: + if matchobj.group(3)[-1] == " ": + caps = matchobj.group(3)[:-1] + tail = ' ' + else: + caps = matchobj.group(3) + tail = '' + return """%s%s""" % (caps, tail) + + # Add additional tags whose content should be + # ignored here. Note -
 and  tag are
+    # ignored by default and therefore are not here
+    tags_to_skip_regex = re.compile("<(/)?(?:kbd|script)[^>]*>", re.IGNORECASE)
+
+    for token in tokens:
+        if token[0] == "tag":
+            # Don't mess with tags.
+            result.append(token[1])
+            close_match = tags_to_skip_regex.match(token[1])
+            if close_match and close_match.group(1) == None:
+                in_skipped_tag = True
+            else:
+                in_skipped_tag = False
+        else:
+            if in_skipped_tag:
+                result.append(token[1])
+            else:
+                result.append(cap_finder.sub(_cap_wrapper, token[1]))
+    output = "".join(result)
+    return output
+
+
+def initial_quotes(text):
+    """Wraps initial quotes in ``class="dquo"`` for double quotes or
+    ``class="quo"`` for single quotes. Works in these block tags ``(h1-h6, p, li, dt, dd)``
+    and also accounts for potential opening inline elements ``a, em, strong, span, b, i``
+
+    >>> initial_quotes('"With primes"')
+    '"With primes"'
+    >>> initial_quotes("'With single primes'")
+    '\\'With single primes\\''
+
+    >>> initial_quotes('"With primes and a link"')
+    '"With primes and a link"'
+
+    >>> initial_quotes('“With smartypanted quotes”')
+    'With smartypanted quotes”'
+    """
+    quote_finder = re.compile(r"""((<(p|h[1-6]|li|dt|dd)[^>]*>|^)              # start with an opening p, h1-6, li, dd, dt or the start of the string
+                                  \s*                                          # optional white space!
+                                  (<(a|em|span|strong|i|b)[^>]*>\s*)*)         # optional opening inline tags, with more optional white space for each.
+                                  (("|“|&\#8220;)|('|‘|&\#8216;))  # Find me a quote! (only need to find the left quotes and the primes)
+                                                                               # double quotes are in group 7, singles in group 8
+                                  """, re.VERBOSE)
+
+    def _quote_wrapper(matchobj):
+        if matchobj.group(7):
+            classname = "dquo"
+            quote = matchobj.group(7)
+        else:
+            classname = "quo"
+            quote = matchobj.group(8)
+        return """%s%s""" % (matchobj.group(1), classname, quote)
+    output = quote_finder.sub(_quote_wrapper, text)
+    return output
+
+
+def smartypants(text):
+    """Applies smarty pants to curl quotes.
+
+    >>> smartypants('The "Green" man')
+    'The “Green” man'
+    """
+    try:
+        import smartypants
+    except ImportError:
+        raise TypogrifyError("Error in {% smartypants %} filter: The Python smartypants library isn't installed.")
+    else:
+        output = smartypants.smartypants(text)
+        return output
+
+
+def widont(text):
+    """Replaces the space between the last two words in a string with `` ``
+    Works in these block tags ``(h1-h6, p, li, dd, dt)`` and also accounts for
+    potential closing inline elements ``a, em, strong, span, b, i``
+
+    >>> widont('A very simple test')
+    'A very simple test'
+
+    Single word items shouldn't be changed
+    >>> widont('Test')
+    'Test'
+    >>> widont(' Test')
+    ' Test'
+    >>> widont('
  • Test

    • ') + '
      • Test

        • ' + >>> widont('
          • Test

            • ') + '
              • Test

                • ' + + >>> widont('

                  In a couple of paragraphs

                  paragraph two

                  ') + '

                  In a couple of paragraphs

                  paragraph two

                  ' + + >>> widont('

                  In a link inside a heading

                  ') + '

                  In a link inside a heading

                  ' + + >>> widont('

                  In a link followed by other text

                  ') + '

                  In a link followed by other text

                  ' + + Empty HTMLs shouldn't error + >>> widont('

                  ') + '

                  ' + + >>> widont('
                  Divs get no love!
                  ') + '
                  Divs get no love!
                  ' + + >>> widont('
                  Neither do PREs
                  ') + '
                  Neither do PREs
                  ' + + >>> widont('

                  But divs with paragraphs do!

                  ') + '

                  But divs with paragraphs do!

                  ' + """ + + widont_finder = re.compile(r"""((?:]*>)|[^<>\s]) # must be proceeded by an approved inline opening or closing tag or a nontag/nonspace + \s+ # the space to replace + ([^<>\s]+ # must be flollowed by non-tag non-space characters + \s* # optional white space! + (\s*)* # optional closing inline tags with optional white space after each + (()|$)) # end with a closing p, h1-6, li or the end of the string + """, re.VERBOSE) + output = widont_finder.sub(r'\1 \2', text) + + return output + +def applyfilters(text): + """Applies the following filters: smartypants, caps, amp, initial_quotes + + >>> typogrify('

                  "Jayhawks" & KU fans act extremely obnoxiously

                  ') + '

                  Jayhawks” & KU fans act extremely obnoxiously

                  ' + """ + text = amp(text) + text = smartypants(text) + text = caps(text) + text = initial_quotes(text) + + return text + +def typogrify(text, ignore_tags=None): + """The super typography filter + + Applies filters to text that are not in tags contained in the + ignore_tags list. + """ + + section_list = process_ignores(text, ignore_tags) + + rendered_text = "" + for text_item, should_process in section_list: + if should_process: + rendered_text += applyfilters(text_item) + else: + rendered_text += text_item + + # apply widont at the end, as its already smart about tags. Hopefully. + return widont(rendered_text) + +def _test(): + import doctest + doctest.testmod(verbose=True) + +if __name__ == "__main__": + _test() diff -Nru typogrify-20111209/typogrify/__init__.py typogrify-2.0.4/typogrify/__init__.py --- typogrify-20111209/typogrify/__init__.py 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/typogrify/__init__.py 2014-02-21 08:49:09.000000000 -0800 @@ -1,268 +1 @@ -import re - -class TypogrifyError(Exception): pass - -class Typogrify(object): - """ - Wrapping the utilities in a class to avoid namespace clashes. - """ - - @staticmethod - def amp(text): - """Wraps apersands in HTML with ```` so they can be - styled with CSS. Apersands are also normalized to ``&``. Requires - ampersands to have whitespace or an `` `` on both sides. - - >>> Typogrify.amp('One & two') - 'One & two' - >>> Typogrify.amp('One & two') - 'One & two' - >>> Typogrify.amp('One & two') - 'One & two' - - >>> Typogrify.amp('One & two') - 'One & two' - - It won't mess up & that are already wrapped, in entities or URLs - - >>> Typogrify.amp('One & two') - 'One & two' - >>> Typogrify.amp('“this” & that') - '“this” & that' - - It should ignore standalone amps that are in attributes - >>> Typogrify.amp('xyz') - 'xyz' - """ - # tag_pattern from http://haacked.com/archive/2004/10/25/usingregularexpressionstomatchhtml.aspx - # it kinda sucks but it fixes the standalone amps in attributes bug - tag_pattern = '\s]+))?)+\s*|\s*)/?>' - amp_finder = re.compile(r"(\s| )(&|&|&\#38;)(\s| )") - intra_tag_finder = re.compile(r'(?P(%s)?)(?P([^<]*))(?P(%s)?)' % (tag_pattern, tag_pattern)) - def _amp_process(groups): - prefix = groups.group('prefix') or '' - text = amp_finder.sub(r"""\1&\3""", groups.group('text')) - suffix = groups.group('suffix') or '' - return prefix + text + suffix - output = intra_tag_finder.sub(_amp_process, text) - return output - - @staticmethod - def caps(text): - """Wraps multiple capital letters in ```` - so they can be styled with CSS. - - >>> Typogrify.caps("A message from KU") - 'A message from KU' - - Uses the smartypants tokenizer to not screw with HTML or with tags it shouldn't. - - >>> Typogrify.caps("
                  CAPS
                  more CAPS") - '
                  CAPS
                  more CAPS' - - >>> Typogrify.caps("A message from 2KU2 with digits") - 'A message from 2KU2 with digits' - - >>> Typogrify.caps("Dotted caps followed by spaces should never include them in the wrap D.O.T. like so.") - 'Dotted caps followed by spaces should never include them in the wrap D.O.T. like so.' - - All caps with with apostrophes in them shouldn't break. Only handles dump apostrophes though. - >>> Typogrify.caps("JIMMY'S") - 'JIMMY\\'S' - - >>> Typogrify.caps("D.O.T.HE34TRFID") - 'D.O.T.HE34TRFID' - """ - try: - import smartypants - except ImportError: - raise TypogrifyError, "Error in {% caps %} filter: The Python SmartyPants library isn't installed." - - - tokens = smartypants._tokenize(text) - result = [] - in_skipped_tag = False - - cap_finder = re.compile(r"""( - (\b[A-Z\d]* # Group 2: Any amount of caps and digits - [A-Z]\d*[A-Z] # A cap string much at least include two caps (but they can have digits between them) - [A-Z\d']*\b) # Any amount of caps and digits or dumb apostsrophes - | (\b[A-Z]+\.\s? # OR: Group 3: Some caps, followed by a '.' and an optional space - (?:[A-Z]+\.\s?)+) # Followed by the same thing at least once more - (?:\s|\b|$)) - """, re.VERBOSE) - - def _cap_wrapper(matchobj): - """This is necessary to keep dotted cap strings to pick up extra spaces""" - if matchobj.group(2): - return """%s""" % matchobj.group(2) - else: - if matchobj.group(3)[-1] == " ": - caps = matchobj.group(3)[:-1] - tail = ' ' - else: - caps = matchobj.group(3) - tail = '' - return """%s%s""" % (caps, tail) - - tags_to_skip_regex = re.compile("<(/)?(?:pre|code|kbd|script|math)[^>]*>", re.IGNORECASE) - - - for token in tokens: - if token[0] == "tag": - # Don't mess with tags. - result.append(token[1]) - close_match = tags_to_skip_regex.match(token[1]) - if close_match and close_match.group(1) == None: - in_skipped_tag = True - else: - in_skipped_tag = False - else: - if in_skipped_tag: - result.append(token[1]) - else: - result.append(cap_finder.sub(_cap_wrapper, token[1])) - output = "".join(result) - return output - - - @staticmethod - def initial_quotes(text): - """Wraps initial quotes in ``class="dquo"`` for double quotes or - ``class="quo"`` for single quotes. Works in these block tags ``(h1-h6, p, li, dt, dd)`` - and also accounts for potential opening inline elements ``a, em, strong, span, b, i`` - - >>> Typogrify.initial_quotes('"With primes"') - '"With primes"' - >>> Typogrify.initial_quotes("'With single primes'") - '\\'With single primes\\'' - - >>> Typogrify.initial_quotes('"With primes and a link"') - '"With primes and a link"' - - >>> Typogrify.initial_quotes('“With smartypanted quotes”') - 'With smartypanted quotes”' - """ - quote_finder = re.compile(r"""((<(p|h[1-6]|li|dt|dd)[^>]*>|^) # start with an opening p, h1-6, li, dd, dt or the start of the string - \s* # optional white space! - (<(a|em|span|strong|i|b)[^>]*>\s*)*) # optional opening inline tags, with more optional white space for each. - (("|“|&\#8220;)|('|‘|&\#8216;)) # Find me a quote! (only need to find the left quotes and the primes) - # double quotes are in group 7, singles in group 8 - """, re.VERBOSE) - def _quote_wrapper(matchobj): - if matchobj.group(7): - classname = "dquo" - quote = matchobj.group(7) - else: - classname = "quo" - quote = matchobj.group(8) - return """%s%s""" % (matchobj.group(1), classname, quote) - output = quote_finder.sub(_quote_wrapper, text) - return output - - @staticmethod - def smartypants(text): - """Applies smarty pants to curl quotes. - - >>> Typogrify.smartypants('The "Green" man') - 'The “Green” man' - """ - try: - import smartypants - except ImportError: - raise TypogrifyError, "Error in {% smartypants %} filter: The Python smartypants library isn't installed." - else: - output = smartypants.smartyPants(text) - return output - - @staticmethod - def titlecase(text): - """Support for titlecase.py's titlecasing - - >>> Typogrify.titlecase("this V that") - 'This v That' - - >>> Typogrify.titlecase("this is just an example.com") - 'This Is Just an example.com' - """ - try: - import titlecase - except ImportError: - raise TypogrifyError, "Error in {% titlecase %} filter: The titlecase.py library isn't installed." - else: - return titlecase.titlecase(text) - - @staticmethod - def typogrify(text): - """The super typography filter - - Applies the following filters: widont, smartypants, caps, amp, initial_quotes - - >>> Typogrify.typogrify('

                  "Jayhawks" & KU fans act extremely obnoxiously

                  ') - '

                  Jayhawks” & KU fans act extremely obnoxiously

                  ' - - """ - text = Typogrify.amp(text) - text = Typogrify.widont(text) - text = Typogrify.smartypants(text) - text = Typogrify.caps(text) - text = Typogrify.initial_quotes(text) - return text - - @staticmethod - def widont(text): - """Replaces the space between the last two words in a string with `` `` - Works in these block tags ``(h1-h6, p, li, dd, dt)`` and also accounts for - potential closing inline elements ``a, em, strong, span, b, i`` - - >>> Typogrify.widont('A very simple test') - 'A very simple test' - - Single word items shouldn't be changed - >>> Typogrify.widont('Test') - 'Test' - >>> Typogrify.widont(' Test') - ' Test' - >>> Typogrify.widont('
                  • Test

                    • ') - '
                      • Test

                        • ' - >>> Typogrify.widont('
                          • Test

                            • ') - '
                              • Test

                                • ' - - >>> Typogrify.widont('

                                  In a couple of paragraphs

                                  paragraph two

                                  ') - '

                                  In a couple of paragraphs

                                  paragraph two

                                  ' - - >>> Typogrify.widont('

                                  In a link inside a heading

                                  ') - '

                                  In a link inside a heading

                                  ' - - >>> Typogrify.widont('

                                  In a link followed by other text

                                  ') - '

                                  In a link followed by other text

                                  ' - - Empty HTMLs shouldn't error - >>> Typogrify.widont('

                                  ') - '

                                  ' - - >>> Typogrify.widont('
                                  Divs get no love!
                                  ') - '
                                  Divs get no love!
                                  ' - - >>> Typogrify.widont('
                                  Neither do PREs
                                  ') - '
                                  Neither do PREs
                                  ' - - >>> Typogrify.widont('

                                  But divs with paragraphs do!

                                  ') - '

                                  But divs with paragraphs do!

                                  ' - """ - widont_finder = re.compile(r"""((?:]*>)|[^<>\s]) # must be proceeded by an approved inline opening or closing tag or a nontag/nonspace - \s+ # the space to replace - ([^<>\s]+ # must be flollowed by non-tag non-space characters - \s* # optional white space! - (\s*)* # optional closing inline tags with optional white space after each - (()|$)) # end with a closing p, h1-6, li or the end of the string - """, re.VERBOSE) - output = widont_finder.sub(r'\1 \2', text) - return output - -def _test(): - import doctest - doctest.testmod(verbose=True) - -if __name__ == "__main__": - _test() +__version__ = "2.0.4" diff -Nru typogrify-20111209/typogrify/packages/__init__.py typogrify-2.0.4/typogrify/packages/__init__.py --- typogrify-20111209/typogrify/packages/__init__.py 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify/packages/__init__.py 2014-02-21 08:43:07.000000000 -0800 @@ -0,0 +1 @@ +# Packages live here. diff -Nru typogrify-20111209/typogrify/packages/titlecase/__init__.py typogrify-2.0.4/typogrify/packages/titlecase/__init__.py --- typogrify-20111209/typogrify/packages/titlecase/__init__.py 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify/packages/titlecase/__init__.py 2014-02-21 08:43:07.000000000 -0800 @@ -0,0 +1,101 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# titlecase v0.5.1 +# Copyright (C) 2008-2010, Stuart Colville. +# https://pypi.python.org/pypi/titlecase + +""" +Original Perl version by: John Gruber http://daringfireball.net/ 10 May 2008 +Python version by Stuart Colville http://muffinresearch.co.uk +License: http://www.opensource.org/licenses/mit-license.php +""" + +import re + +__all__ = ['titlecase'] +__version__ = '0.5.1' + +SMALL = 'a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v\.?|via|vs\.?' +PUNCT = r"""!"#$%&'‘()*+,\-./:;?@[\\\]_`{|}~""" + +SMALL_WORDS = re.compile(r'^(%s)$' % SMALL, re.I) +INLINE_PERIOD = re.compile(r'[a-z][.][a-z]', re.I) +UC_ELSEWHERE = re.compile(r'[%s]*?[a-zA-Z]+[A-Z]+?' % PUNCT) +CAPFIRST = re.compile(r"^[%s]*?([A-Za-z])" % PUNCT) +SMALL_FIRST = re.compile(r'^([%s]*)(%s)\b' % (PUNCT, SMALL), re.I) +SMALL_LAST = re.compile(r'\b(%s)[%s]?$' % (SMALL, PUNCT), re.I) +SUBPHRASE = re.compile(r'([:.;?!][ ])(%s)' % SMALL) +APOS_SECOND = re.compile(r"^[dol]{1}['‘]{1}[a-z]+$", re.I) +ALL_CAPS = re.compile(r'^[A-Z\s%s]+$' % PUNCT) +UC_INITIALS = re.compile(r"^(?:[A-Z]{1}\.{1}|[A-Z]{1}\.{1}[A-Z]{1})+$") +MAC_MC = re.compile(r"^([Mm]a?c)(\w+)") + +def titlecase(text): + + """ + Titlecases input text + + This filter changes all words to Title Caps, and attempts to be clever + about *un*capitalizing SMALL words like a/an/the in the input. + + The list of "SMALL words" which are not capped comes from + the New York Times Manual of Style, plus 'vs' and 'v'. + + """ + + lines = re.split('[\r\n]+', text) + processed = [] + for line in lines: + all_caps = ALL_CAPS.match(line) + words = re.split('[\t ]', line) + tc_line = [] + for word in words: + if all_caps: + if UC_INITIALS.match(word): + tc_line.append(word) + continue + else: + word = word.lower() + + if APOS_SECOND.match(word): + word = word.replace(word[0], word[0].upper()) + word = word.replace(word[2], word[2].upper()) + tc_line.append(word) + continue + if INLINE_PERIOD.search(word) or UC_ELSEWHERE.match(word): + tc_line.append(word) + continue + if SMALL_WORDS.match(word): + tc_line.append(word.lower()) + continue + + match = MAC_MC.match(word) + if match: + tc_line.append("%s%s" % (match.group(1).capitalize(), + match.group(2).capitalize())) + continue + + hyphenated = [] + for item in word.split('-'): + hyphenated.append(CAPFIRST.sub(lambda m: m.group(0).upper(), item)) + tc_line.append("-".join(hyphenated)) + + + result = " ".join(tc_line) + + result = SMALL_FIRST.sub(lambda m: '%s%s' % ( + m.group(1), + m.group(2).capitalize() + ), result) + + result = SMALL_LAST.sub(lambda m: m.group(0).capitalize(), result) + + result = SUBPHRASE.sub(lambda m: '%s%s' % ( + m.group(1), + m.group(2).capitalize() + ), result) + + processed.append(result) + + return "\n".join(processed) + diff -Nru typogrify-20111209/typogrify/packages/titlecase/tests.py typogrify-2.0.4/typogrify/packages/titlecase/tests.py --- typogrify-20111209/typogrify/packages/titlecase/tests.py 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify/packages/titlecase/tests.py 2014-02-21 08:43:07.000000000 -0800 @@ -0,0 +1,174 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""Tests for titlecase""" + + +import os +import sys +sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../')) + +from titlecase import titlecase + +TEST_DATA = ( + ( + "Q&A with steve jobs: 'that's what happens in technology'", + "Q&A With Steve Jobs: 'That's What Happens in Technology'" + ), + ( + "What is AT&T's problem?", + "What Is AT&T's Problem?" + ), + ( + "Apple deal with AT&T falls through", + "Apple Deal With AT&T Falls Through" + ), + ( + "this v that", + "This v That" + ), + ( + "this v. that", + "This v. That" + ), + ( + "this vs that", + "This vs That" + ), + ( + "this vs. that", + "This vs. That" + ), + ( + "The SEC's Apple probe: what you need to know", + "The SEC's Apple Probe: What You Need to Know" + ), + ( + "'by the Way, small word at the start but within quotes.'", + "'By the Way, Small Word at the Start but Within Quotes.'" + ), + ( + "Small word at end is nothing to be afraid of", + "Small Word at End Is Nothing to Be Afraid Of" + ), + ( + "Starting Sub-Phrase With a Small Word: a Trick, Perhaps?", + "Starting Sub-Phrase With a Small Word: A Trick, Perhaps?" + ), + ( + "Sub-Phrase With a Small Word in Quotes: 'a Trick, Perhaps?'", + "Sub-Phrase With a Small Word in Quotes: 'A Trick, Perhaps?'" + ), + ( + 'sub-phrase with a small word in quotes: "a trick, perhaps?"', + 'Sub-Phrase With a Small Word in Quotes: "A Trick, Perhaps?"' + ), + ( + '"Nothing to Be Afraid of?"', + '"Nothing to Be Afraid Of?"' + ), + ( + '"Nothing to be Afraid Of?"', + '"Nothing to Be Afraid Of?"' + ), + ( + 'a thing', + 'A Thing' + ), + ( + "2lmc Spool: 'gruber on OmniFocus and vapo(u)rware'", + "2lmc Spool: 'Gruber on OmniFocus and Vapo(u)rware'" + ), + ( + 'this is just an example.com', + 'This Is Just an example.com' + ), + ( + 'this is something listed on del.icio.us', + 'This Is Something Listed on del.icio.us' + ), + ( + 'iTunes should be unmolested', + 'iTunes Should Be Unmolested' + ), + ( + 'reading between the lines of steve jobs’s ‘thoughts on music’', + 'Reading Between the Lines of Steve Jobs’s ‘Thoughts on Music’' + ), + ( + 'seriously, ‘repair permissions’ is voodoo', + 'Seriously, ‘Repair Permissions’ Is Voodoo' + ), + ( + 'generalissimo francisco franco: still dead; kieren McCarthy: still a jackass', + 'Generalissimo Francisco Franco: Still Dead; Kieren McCarthy: Still a Jackass' + ), + ( + "O'Reilly should be untouched", + "O'Reilly Should Be Untouched" + ), + ( + "my name is o'reilly", + "My Name Is O'Reilly" + ), + ( + "WASHINGTON, D.C. SHOULD BE FIXED BUT MIGHT BE A PROBLEM", + "Washington, D.C. Should Be Fixed but Might Be a Problem" + ), + ( + "THIS IS ALL CAPS AND SHOULD BE ADDRESSED", + "This Is All Caps and Should Be Addressed" + ), + ( + "Mr McTavish went to MacDonalds", + "Mr McTavish Went to MacDonalds" + ), + ( + "this shouldn't\nget mangled", + "This Shouldn't\nGet Mangled" + ), + ( + "this is http://foo.com", + "This Is http://foo.com" + ) +) + +def test_all_caps_regex(): + """Test - all capitals regex""" + from titlecase import ALL_CAPS + assert bool(ALL_CAPS.match('THIS IS ALL CAPS')) is True + +def test_initials_regex(): + """Test - uppercase initals regex with A.B""" + from titlecase import UC_INITIALS + assert bool(UC_INITIALS.match('A.B')) is True + +def test_initials_regex_2(): + """Test - uppercase initals regex with A.B.""" + from titlecase import UC_INITIALS + assert bool(UC_INITIALS.match('A.B.')) is True + +def test_initials_regex_3(): + """Test - uppercase initals regex with ABCD""" + from titlecase import UC_INITIALS + assert bool(UC_INITIALS.match('ABCD')) is False + +def check_input_matches_expected_output(in_, out): + """Function yielded by test generator""" + try : + assert titlecase(in_) == out + except AssertionError: + print("%s != %s" % (titlecase(in_), out)) + raise + + +def test_input_output(): + """Generated tests""" + for data in TEST_DATA: + yield check_input_matches_expected_output, data[0], data[1] + + +if __name__ == "__main__": + import nose + nose.main() + diff -Nru typogrify-20111209/typogrify/templatetags/django_filters.py typogrify-2.0.4/typogrify/templatetags/django_filters.py --- typogrify-20111209/typogrify/templatetags/django_filters.py 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/typogrify/templatetags/django_filters.py 1969-12-31 16:00:00.000000000 -0800 @@ -1,204 +0,0 @@ -from typogrify import Typogrify, TypogrifyError -from functools import wraps -from django.conf import settings -from django import template -from django.utils.html import conditional_escape -from django.utils.safestring import mark_safe -from django.utils.encoding import force_unicode - -register = template.Library() - -def make_safe(f): - @wraps(f) - def wrapper(text): - text = force_unicode(text) - f.is_safe = True - out = text - try: - out = f(text) - except TypogrifyError, e: - if settings.DEBUG: - raise template.TemplateError(e.message) - return text - return mark_safe(out) - wrapper.is_safe = True - return wrapper - -@make_safe -def amp(text): - """Wraps apersands in HTML with ```` so they can be - styled with CSS. Apersands are also normalized to ``&``. Requires - ampersands to have whitespace or an `` `` on both sides. - - >>> amp('One & two') - u'One & two' - >>> amp('One & two') - u'One & two' - >>> amp('One & two') - u'One & two' - - >>> amp('One & two') - u'One & two' - - It won't mess up & that are already wrapped, in entities or URLs - - >>> amp('One & two') - u'One & two' - >>> amp('“this” & that') - u'“this” & that' - - It should ignore standalone amps that are in attributes - >>> amp('xyz') - u'xyz' - """ - return Typogrify.amp(text) - -@make_safe -def caps(text): - """Wraps multiple capital letters in ```` - so they can be styled with CSS. - - >>> caps("A message from KU") - u'A message from KU' - - Uses the smartypants tokenizer to not screw with HTML or with tags it shouldn't. - - >>> caps("
                                  CAPS
                                  more CAPS") - u'
                                  CAPS
                                  more CAPS' - - >>> caps("A message from 2KU2 with digits") - u'A message from 2KU2 with digits' - - >>> caps("Dotted caps followed by spaces should never include them in the wrap D.O.T. like so.") - u'Dotted caps followed by spaces should never include them in the wrap D.O.T. like so.' - - All caps with with apostrophes in them shouldn't break. Only handles dump apostrophes though. - >>> caps("JIMMY'S") - u'JIMMY\\'S' - - >>> caps("D.O.T.HE34TRFID") - u'D.O.T.HE34TRFID' - """ - return Typogrify.caps(text) - -@make_safe -def initial_quotes(text): - """Wraps initial quotes in ``class="dquo"`` for double quotes or - ``class="quo"`` for single quotes. Works in these block tags ``(h1-h6, p, li, dt, dd)`` - and also accounts for potential opening inline elements ``a, em, strong, span, b, i`` - - >>> initial_quotes('"With primes"') - u'"With primes"' - >>> initial_quotes("'With single primes'") - u'\\'With single primes\\'' - - >>> initial_quotes('"With primes and a link"') - u'"With primes and a link"' - - >>> initial_quotes('“With smartypanted quotes”') - u'With smartypanted quotes”' - """ - return Typogrify.initial_quotes(text) - -@make_safe -def smartypants(text): - """Applies smarty pants to curl quotes. - - >>> smartypants('The "Green" man') - u'The “Green” man' - """ - return Typogrify.smartypants(text) - -@make_safe -def titlecase(text): - """Support for titlecase.py's titlecasing - - >>> titlecase("this V that") - u'This v That' - - >>> titlecase("this is just an example.com") - u'This Is Just an example.com' - """ - return Typogrify.titlecase(text) - -@make_safe -def typogrify(text): - """The super typography filter - - Applies the following filters: widont, smartypants, caps, amp, initial_quotes - - >>> typogrify('

                                  "Jayhawks" & KU fans act extremely obnoxiously

                                  ') - u'

                                  Jayhawks” & KU fans act extremely obnoxiously

                                  ' - - Each filters properly handles autoescaping. - >>> conditional_escape(typogrify('

                                  "Jayhawks" & KU fans act extremely obnoxiously

                                  ')) - u'

                                  Jayhawks” & KU fans act extremely obnoxiously

                                  ' - """ - text = force_unicode(text) - return Typogrify.typogrify(text) - -@make_safe -def widont(text): - """Replaces the space between the last two words in a string with `` `` - Works in these block tags ``(h1-h6, p, li, dd, dt)`` and also accounts for - potential closing inline elements ``a, em, strong, span, b, i`` - - >>> widont('A very simple test') - u'A very simple test' - - Single word items shouldn't be changed - >>> widont('Test') - u'Test' - >>> widont(' Test') - u' Test' - >>> widont('
                                  • Test

                                    • ') - u'
                                      • Test

                                        • ' - >>> widont('
                                          • Test

                                            • ') - u'
                                              • Test

                                                • ' - - >>> widont('

                                                  In a couple of paragraphs

                                                  paragraph two

                                                  ') - u'

                                                  In a couple of paragraphs

                                                  paragraph two

                                                  ' - - >>> widont('

                                                  In a link inside a heading

                                                  ') - u'

                                                  In a link inside a heading

                                                  ' - - >>> widont('

                                                  In a link followed by other text

                                                  ') - u'

                                                  In a link followed by other text

                                                  ' - - Empty HTMLs shouldn't error - >>> widont('

                                                  ') - u'

                                                  ' - - >>> widont('
                                                  Divs get no love!
                                                  ') - u'
                                                  Divs get no love!
                                                  ' - - >>> widont('
                                                  Neither do PREs
                                                  ') - u'
                                                  Neither do PREs
                                                  ' - - >>> widont('

                                                  But divs with paragraphs do!

                                                  ') - u'

                                                  But divs with paragraphs do!

                                                  ' - """ - return Typogrify.widont(text) - -register.filter('amp', amp) -register.filter('caps', caps) -register.filter('initial_quotes', initial_quotes) -register.filter('smartypants', smartypants) -register.filter('titlecase', titlecase) -register.filter('typogrify', typogrify) -register.filter('widont', widont) - -def _test(): - """ - How to run this: - go two levels up to the root typogrify directory. - $ ls - INSTALL.txt MANIFEST README.markdown typogrify - LICENSE.txt MANIFEST.in setup.py - $ python -m typogrify.templatetags.filters - """ - import doctest - doctest.testmod(verbose=True) - -if __name__ == "__main__": - _test() diff -Nru typogrify-20111209/typogrify/templatetags/jinja2_filters.py typogrify-2.0.4/typogrify/templatetags/jinja2_filters.py --- typogrify-20111209/typogrify/templatetags/jinja2_filters.py 2011-12-09 06:02:58.000000000 -0800 +++ typogrify-2.0.4/typogrify/templatetags/jinja2_filters.py 1969-12-31 16:00:00.000000000 -0800 @@ -1,201 +0,0 @@ -from typogrify import Typogrify, TypogrifyError -from functools import wraps -import jinja2 -from jinja2.exceptions import TemplateError - - -def make_safe(f): - @wraps(f) - def wrapper(text): - f.is_safe = True - out = text - try: - out = f(text) - except TypogrifyError, e: - raise TemplateError(e.message) - return jinja2.Markup(out) - wrapper.is_safe = True - return wrapper - -@make_safe -def amp(text): - """Wraps apersands in HTML with ```` so they can be - styled with CSS. Apersands are also normalized to ``&``. Requires - ampersands to have whitespace or an `` `` on both sides. - - >>> amp('One & two') - Markup(u'One & two') - >>> amp('One & two') - Markup(u'One & two') - >>> amp('One & two') - Markup(u'One & two') - - >>> amp('One & two') - Markup(u'One & two') - - It won't mess up & that are already wrapped, in entities or URLs - - >>> amp('One & two') - Markup(u'One & two') - >>> amp('“this” & that') - Markup(u'“this” & that') - - It should ignore standalone amps that are in attributes - >>> amp('xyz') - Markup(u'xyz') - """ - return Typogrify.amp(text) - -@make_safe -def caps(text): - """Wraps multiple capital letters in ```` - so they can be styled with CSS. - - >>> caps("A message from KU") - Markup(u'A message from KU') - - Uses the smartypants tokenizer to not screw with HTML or with tags it shouldn't. - - >>> caps("
                                                  CAPS
                                                  more CAPS") - Markup(u'
                                                  CAPS
                                                  more CAPS') - - >>> caps("A message from 2KU2 with digits") - Markup(u'A message from 2KU2 with digits') - - >>> caps("Dotted caps followed by spaces should never include them in the wrap D.O.T. like so.") - Markup(u'Dotted caps followed by spaces should never include them in the wrap D.O.T. like so.') - - All caps with with apostrophes in them shouldn't break. Only handles dump apostrophes though. - >>> caps("JIMMY'S") - Markup(u'JIMMY\\'S') - - >>> caps("D.O.T.HE34TRFID") - Markup(u'D.O.T.HE34TRFID') - """ - return Typogrify.caps(text) - -@make_safe -def initial_quotes(text): - """Wraps initial quotes in ``class="dquo"`` for double quotes or - ``class="quo"`` for single quotes. Works in these block tags ``(h1-h6, p, li, dt, dd)`` - and also accounts for potential opening inline elements ``a, em, strong, span, b, i`` - - >>> initial_quotes('"With primes"') - Markup(u'"With primes"') - >>> initial_quotes("'With single primes'") - Markup(u'\\'With single primes\\'') - - >>> initial_quotes('"With primes and a link"') - Markup(u'"With primes and a link"') - - >>> initial_quotes('“With smartypanted quotes”') - Markup(u'With smartypanted quotes”') - """ - return Typogrify.initial_quotes(text) - -@make_safe -def smartypants(text): - """Applies smarty pants to curl quotes. - - >>> smartypants('The "Green" man') - Markup(u'The “Green” man') - """ - return Typogrify.smartypants(text) - -@make_safe -def titlecase(text): - """Support for titlecase.py's titlecasing - - >>> titlecase("this V that") - Markup(u'This v That') - - >>> titlecase("this is just an example.com") - Markup(u'This Is Just an example.com') - """ - return Typogrify.titlecase(text) - -@make_safe -def typogrify(text): - """The super typography filter - - Applies the following filters: widont, smartypants, caps, amp, initial_quotes - - >>> typogrify('

                                                  "Jayhawks" & KU fans act extremely obnoxiously

                                                  ') - Markup(u'

                                                  Jayhawks” & KU fans act extremely obnoxiously

                                                  ') - - Each filters properly handles autoescaping. - >>> jinja2.escape(typogrify('

                                                  "Jayhawks" & KU fans act extremely obnoxiously

                                                  ')) - Markup(u'

                                                  Jayhawks” & KU fans act extremely obnoxiously

                                                  ') - """ - return Typogrify.typogrify(text) - -@make_safe -def widont(text): - """Replaces the space between the last two words in a string with `` `` - Works in these block tags ``(h1-h6, p, li, dd, dt)`` and also accounts for - potential closing inline elements ``a, em, strong, span, b, i`` - - >>> widont('A very simple test') - Markup(u'A very simple test') - - Single word items shouldn't be changed - >>> widont('Test') - Markup(u'Test') - >>> widont(' Test') - Markup(u' Test') - >>> widont('
                                                  • Test

                                                    • ') - Markup(u'
                                                      • Test

                                                        • ') - >>> widont('
                                                          • Test

                                                            • ') - Markup(u'
                                                              • Test

                                                                • ') - - >>> widont('

                                                                  In a couple of paragraphs

                                                                  paragraph two

                                                                  ') - Markup(u'

                                                                  In a couple of paragraphs

                                                                  paragraph two

                                                                  ') - - >>> widont('

                                                                  In a link inside a heading

                                                                  ') - Markup(u'

                                                                  In a link inside a heading

                                                                  ') - - >>> widont('

                                                                  In a link followed by other text

                                                                  ') - Markup(u'

                                                                  In a link followed by other text

                                                                  ') - - Empty HTMLs shouldn't error - >>> widont('

                                                                  ') - Markup(u'

                                                                  ') - - >>> widont('
                                                                  Divs get no love!
                                                                  ') - Markup(u'
                                                                  Divs get no love!
                                                                  ') - - >>> widont('
                                                                  Neither do PREs
                                                                  ') - Markup(u'
                                                                  Neither do PREs
                                                                  ') - - >>> widont('

                                                                  But divs with paragraphs do!

                                                                  ') - Markup(u'

                                                                  But divs with paragraphs do!

                                                                  ') - """ - return Typogrify.widont(text) - - -def register(env): - """ - Call this to register the template filters for jinj2. - """ - env.filters['amp'] = amp - env.filters['caps'] = caps - env.filters['initial_quotes'] = initial_quotes - env.filters['smartypants'] = smartypants - env.filters['titlecase'] = titlecase - env.filters['typogrify'] = typogrify - env.filters['widont'] = widont - -def _test(): - """ - How to run this: - go two levels up to the root typogrify directory. - $ ls - INSTALL.txt MANIFEST README.markdown typogrify - LICENSE.txt MANIFEST.in setup.py - $ python -m typogrify.templatetags.filters - """ - import doctest - doctest.testmod(verbose=True) - -if __name__ == "__main__": - _test() diff -Nru typogrify-20111209/typogrify/templatetags/jinja_filters.py typogrify-2.0.4/typogrify/templatetags/jinja_filters.py --- typogrify-20111209/typogrify/templatetags/jinja_filters.py 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify/templatetags/jinja_filters.py 2014-01-07 12:15:24.000000000 -0800 @@ -0,0 +1,36 @@ +from typogrify.filters import amp, caps, initial_quotes, smartypants, titlecase, typogrify, widont, TypogrifyError +from functools import wraps +import jinja2 +from jinja2.exceptions import TemplateError + + +def make_safe(f): + """ + A function wrapper to make typogrify play nice with jinja2's + unicode support. + + """ + @wraps(f) + def wrapper(text): + f.is_safe = True + out = text + try: + out = f(text) + except TypogrifyError as e: + raise TemplateError(e.message) + return jinja2.Markup(out) + wrapper.is_safe = True + return wrapper + + +def register(env): + """ + Call this to register the template filters for jinj2. + """ + env.filters['amp'] = make_safe(amp) + env.filters['caps'] = make_safe(caps) + env.filters['initial_quotes'] = make_safe(initial_quotes) + env.filters['smartypants'] = make_safe(smartypants) + env.filters['titlecase'] = make_safe(titlecase) + env.filters['typogrify'] = make_safe(typogrify) + env.filters['widont'] = make_safe(widont) diff -Nru typogrify-20111209/typogrify/templatetags/typogrify_tags.py typogrify-2.0.4/typogrify/templatetags/typogrify_tags.py --- typogrify-20111209/typogrify/templatetags/typogrify_tags.py 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify/templatetags/typogrify_tags.py 2014-01-07 12:15:24.000000000 -0800 @@ -0,0 +1,40 @@ +from typogrify.filters import amp, caps, initial_quotes, smartypants, titlecase, typogrify, widont, TypogrifyError +from functools import wraps +from django.conf import settings +from django import template +from django.utils.safestring import mark_safe +from django.utils.encoding import force_str + + +register = template.Library() + + +def make_safe(f): + """ + A function wrapper to make typogrify play nice with django's + unicode support. + + """ + @wraps(f) + def wrapper(text): + text = force_str(text) + f.is_safe = True + out = text + try: + out = f(text) + except TypogrifyError as e: + if settings.DEBUG: + raise e + return text + return mark_safe(out) + wrapper.is_safe = True + return wrapper + + +register.filter('amp', make_safe(amp)) +register.filter('caps', make_safe(caps)) +register.filter('initial_quotes', make_safe(initial_quotes)) +register.filter('smartypants', make_safe(smartypants)) +register.filter('titlecase', make_safe(titlecase)) +register.filter('typogrify', make_safe(typogrify)) +register.filter('widont', make_safe(widont)) diff -Nru typogrify-20111209/typogrify.egg-info/dependency_links.txt typogrify-2.0.4/typogrify.egg-info/dependency_links.txt --- typogrify-20111209/typogrify.egg-info/dependency_links.txt 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify.egg-info/dependency_links.txt 2014-02-21 08:49:54.000000000 -0800 @@ -0,0 +1 @@ + diff -Nru typogrify-20111209/typogrify.egg-info/PKG-INFO typogrify-2.0.4/typogrify.egg-info/PKG-INFO --- typogrify-20111209/typogrify.egg-info/PKG-INFO 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify.egg-info/PKG-INFO 2014-02-21 08:49:54.000000000 -0800 @@ -0,0 +1,156 @@ +Metadata-Version: 1.1 +Name: typogrify +Version: 2.0.4 +Summary: Filters to enhance web typography, including support for Django & Jinja templates +Home-page: https://github.com/mintchaos/typogrify +Author: Christian Metts, Justin Mayer, Chris Drackett +Author-email: chris@tiltshiftstudio.com +License: BSD +Description: Typogrify provides a set of custom filters that automatically apply various + transformations to plain text in order to yield typographically-improved HTML. + While often used in conjunction with Jinja_ and Django_ template systems, the + filters can be used in any environment. + + .. _Jinja: http://jinja.pocoo.org/ + .. _Django: https://www.djangoproject.com/ + + + Installation + ============ + + The following command will install via ``pip``. Pay particular attention to the + package name:: + + pip install typogrify + + Alternatively, you can run the following command inside the project's root + directory:: + + python setup.py install + + Last but not least, you can simply move the enclosed ``typogrify`` folder + into your Python path. + + + Requirements + ============ + + Python 2.3 and above is supported, including Python 3. The only dependency is + SmartyPants_, a Python port of a project by John Gruber. + + Installing Jinja_ or Django_ is only required if you intend to use the optional + template filters that are included for those frameworks. + + .. _SmartyPants: http://web.chad.org/projects/smartypants.py/ + + + Usage + ===== + + The filters can be used in any environment by importing them from + ``typogrify.filters``:: + + from typogrify.filters import typogrify + content = typogrify(content) + + For use with Django, you can add ``typogrify`` to the ``INSTALLED_APPS`` setting + of any Django project in which you wish to use it, and then use + ``{% load typogrify_tags %}`` in your templates to load the filters it provides. + + Experimental support for Jinja is in ``typogrify.templatetags.jinja_filters``. + + + 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`` + --------------- + + Applies ``SmartyPants``. + + + ``typogrify`` + ------------- + + Applies all of the following filters, in order: + + * ``amp`` + + * ``widont`` + + * ``smartypants`` + + * ``caps`` + + * ``initial_quotes`` + + + ``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``. + +Platform: UNKNOWN +Classifier: Development Status :: 5 - Production/Stable +Classifier: Environment :: Web Environment +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: BSD License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Framework :: Django +Classifier: Framework :: Flask +Classifier: Topic :: Utilities diff -Nru typogrify-20111209/typogrify.egg-info/requires.txt typogrify-2.0.4/typogrify.egg-info/requires.txt --- typogrify-20111209/typogrify.egg-info/requires.txt 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify.egg-info/requires.txt 2014-02-21 08:49:54.000000000 -0800 @@ -0,0 +1 @@ +smartypants>=1.8.3 \ No newline at end of file diff -Nru typogrify-20111209/typogrify.egg-info/SOURCES.txt typogrify-2.0.4/typogrify.egg-info/SOURCES.txt --- typogrify-20111209/typogrify.egg-info/SOURCES.txt 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify.egg-info/SOURCES.txt 2014-02-21 08:49:54.000000000 -0800 @@ -0,0 +1,18 @@ +LICENSE.txt +MANIFEST.in +README.rst +setup.cfg +setup.py +typogrify/__init__.py +typogrify/filters.py +typogrify.egg-info/PKG-INFO +typogrify.egg-info/SOURCES.txt +typogrify.egg-info/dependency_links.txt +typogrify.egg-info/requires.txt +typogrify.egg-info/top_level.txt +typogrify/packages/__init__.py +typogrify/packages/titlecase/__init__.py +typogrify/packages/titlecase/tests.py +typogrify/templatetags/__init__.py +typogrify/templatetags/jinja_filters.py +typogrify/templatetags/typogrify_tags.py \ No newline at end of file diff -Nru typogrify-20111209/typogrify.egg-info/top_level.txt typogrify-2.0.4/typogrify.egg-info/top_level.txt --- typogrify-20111209/typogrify.egg-info/top_level.txt 1969-12-31 16:00:00.000000000 -0800 +++ typogrify-2.0.4/typogrify.egg-info/top_level.txt 2014-02-21 08:49:54.000000000 -0800 @@ -0,0 +1 @@ +typogrify