From 0949fa62ec5b8d0b9c59037cf93df733b062575e Mon Sep 17 00:00:00 2001
From: John Mastro
Date: Thu, 12 Feb 2015 16:24:59 -0800
Subject: [PATCH] Tell smartypants to also process " entities
This is necessary because Docutils has already replaced double quotes
with " HTML entities by the time the typogrify filter is applied.
---
pelican/readers.py | 7 +++++++
pelican/tests/test_readers.py | 6 +++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/pelican/readers.py b/pelican/readers.py
index 85147e3e..1fe9a148 100644
--- a/pelican/readers.py
+++ b/pelican/readers.py
@@ -467,6 +467,13 @@ class Readers(FileStampDataCacher):
# 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"""
diff --git a/pelican/tests/test_readers.py b/pelican/tests/test_readers.py
index ffff3478..cb657673 100644
--- a/pelican/tests/test_readers.py
+++ b/pelican/tests/test_readers.py
@@ -121,7 +121,7 @@ class RstReaderTest(ReaderTest):
page = self.read_file(path='article.rst', TYPOGRIFY=True)
expected = (
'THIS is some content. '
- 'With some stuff to "typogrify"…
\n'
+ 'With some stuff to “typogrify”…
\n'
'Now with added support for TLA.
\n')
@@ -146,8 +146,8 @@ class RstReaderTest(ReaderTest):
TYPOGRIFY=True)
expected = ('Multi-line metadata should be'
' supported\nas well as inline'
- ' markup and stuff to "typogrify'
- '"…
\n')
+ ' markup and stuff to “typogrify'
+ '”…\n')
self.assertEqual(page.metadata['summary'], expected)
except ImportError: