Skip to content

Commit

Permalink
Merge pull request #1627 from johnmastro/smartypants-html-entities
Browse files Browse the repository at this point in the history
Tell smartypants to also process " entities
  • Loading branch information
justinmayer committed Feb 13, 2015
2 parents 9152e02 + 0949fa6 commit c139221
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions pelican/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@ def read_file(self, base_path, path, content_class=Page, fmt=None,
# eventually filter the content with typogrify if asked so
if self.settings['TYPOGRIFY']:
from typogrify.filters import typogrify
import smartypants

# Tell `smartypants` to also replace " HTML entities with
# smart quotes. This is necessary because Docutils has already
# replaced double quotes with said entities by the time we run
# this filter.
smartypants.Attr.default |= smartypants.Attr.w

def typogrify_wrapper(text):
"""Ensures ignore_tags feature is backward compatible"""
Expand Down
6 changes: 3 additions & 3 deletions pelican/tests/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_typogrify(self):
page = self.read_file(path='article.rst', TYPOGRIFY=True)
expected = (
'<p><span class="caps">THIS</span> is some content. '
'With some stuff to&nbsp;&quot;typogrify&quot;&#8230;</p>\n'
'With some stuff to&nbsp;&#8220;typogrify&#8221;&#8230;</p>\n'
'<p>Now with added support for <abbr title="three letter '
'acronym"><span class="caps">TLA</span></abbr>.</p>\n')

Expand All @@ -146,8 +146,8 @@ def test_typogrify_summary(self):
TYPOGRIFY=True)
expected = ('<p class="first last">Multi-line metadata should be'
' supported\nas well as <strong>inline'
' markup</strong> and stuff to&nbsp;&quot;typogrify'
'&quot;&#8230;</p>\n')
' markup</strong> and stuff to&nbsp;&#8220;typogrify'
'&#8221;&#8230;</p>\n')

self.assertEqual(page.metadata['summary'], expected)
except ImportError:
Expand Down

0 comments on commit c139221

Please sign in to comment.