Skip to content
Browse files
Add typogrify_oldschool filter (Issue #2574)
  • Loading branch information
ralsina committed Dec 2, 2016
1 parent 85b22e8 commit 913e27c2150c88038f1bf2a129f82459bc2fbc4f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
@@ -12,6 +12,7 @@ Bugfixes

* Added new ``typogrify_oldschool`` filter (Issue #2574)
* Improving handling of .dep files, and allowing compilers to specify
additional targets for the render_posts task (Issue #2536)
* ``render_template`` and ``generic_renderer`` can now create HTML
@@ -249,6 +249,34 @@ def typogrify(data):
return data

def _smarty_oldschool(text):
import smartypants
except ImportError:
raise typo.TypogrifyError("Error in {% smartypants %} filter: The Python smartypants library isn't installed.")
output = smartypants.convert_dashes_oldschool(text)
return output

def typogrify_oldschool(data):
"""Prettify text with typogrify."""
if typo is None:
req_missing(['typogrify'], 'use the typogrify_oldschool filter', optional=True)
return data

data = _normalize_html(data)
data = typo.amp(data)
data = typo.widont(data)
data = _smarty_oldschool(data)
data = typo.smartypants(data)
# Disabled because of typogrify bug where it breaks <title>
# data = typo.caps(data)
data = typo.initial_quotes(data)
return data

def typogrify_sans_widont(data):
"""Prettify text with typogrify, skipping the widont filter."""

0 comments on commit 913e27c

Please sign in to comment.