Skip to content
Permalink
Browse files

Add typogrify_oldschool filter (Issue #2574)

  • Loading branch information
ralsina committed Dec 2, 2016
1 parent 85b22e8 commit 913e27c2150c88038f1bf2a129f82459bc2fbc4f
Showing with 29 additions and 0 deletions.
  1. +1 −0 CHANGES.txt
  2. +28 −0 nikola/filters.py
@@ -12,6 +12,7 @@ Bugfixes
Features
--------

* 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):
try:
import smartypants
except ImportError:
raise typo.TypogrifyError("Error in {% smartypants %} filter: The Python smartypants library isn't installed.")
else:
output = smartypants.convert_dashes_oldschool(text)
return output


@apply_to_text_file
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


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

0 comments on commit 913e27c

Please sign in to comment.