Skip to content

Commit

Permalink
Add typogrify_oldschool filter (Issue #2574)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Dec 2, 2016
1 parent 85b22e8 commit 913e27c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions nikola/filters.py
Expand Up @@ -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."""
Expand Down

0 comments on commit 913e27c

Please sign in to comment.