From 91d576eb45d416d8cbaeee2bc72765c573c824e6 Mon Sep 17 00:00:00 2001
From: Jean Lauliac
Date: Mon, 24 Mar 2014 14:50:49 -0400
Subject: [PATCH] Apply typogrify on article summary as well
---
pelican/readers.py | 9 ++++---
.../tests/content/article_with_metadata.rst | 2 +-
pelican/tests/test_readers.py | 27 ++++++++++++++++++-
3 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/pelican/readers.py b/pelican/readers.py
index 1e00aefa..20f391eb 100644
--- a/pelican/readers.py
+++ b/pelican/readers.py
@@ -462,10 +462,13 @@ class Readers(object):
find_empty_alt(content, path)
# eventually filter the content with typogrify if asked so
- if content and self.settings['TYPOGRIFY']:
+ if self.settings['TYPOGRIFY']:
from typogrify.filters import typogrify
- content = typogrify(content)
- metadata['title'] = typogrify(metadata['title'])
+ if content:
+ content = typogrify(content)
+ metadata['title'] = typogrify(metadata['title'])
+ if 'summary' in metadata:
+ metadata['summary'] = typogrify(metadata['summary'])
if context_signal:
logger.debug('signal {}.send({}, )'.format(
diff --git a/pelican/tests/content/article_with_metadata.rst b/pelican/tests/content/article_with_metadata.rst
index c5768cfb..9b65a4b0 100644
--- a/pelican/tests/content/article_with_metadata.rst
+++ b/pelican/tests/content/article_with_metadata.rst
@@ -9,5 +9,5 @@ This is a super article !
:author: Alexis Métaireau
:summary:
Multi-line metadata should be supported
- as well as **inline markup**.
+ as well as **inline markup** and stuff to "typogrify"...
:custom_field: http://notmyidea.org
diff --git a/pelican/tests/test_readers.py b/pelican/tests/test_readers.py
index acb268fb..d605d785 100644
--- a/pelican/tests/test_readers.py
+++ b/pelican/tests/test_readers.py
@@ -40,7 +40,8 @@ class RstReaderTest(ReaderTest):
'title': 'This is a super article !',
'summary': 'Multi-line metadata should be'
' supported\nas well as inline'
- ' markup.
\n',
+ ' markup and stuff to "typogrify'
+ '"...
\n',
'date': datetime.datetime(2010, 12, 2, 10, 14),
'modified': datetime.datetime(2010, 12, 2, 10, 20),
'tags': ['foo', 'bar', 'foobar'],
@@ -125,6 +126,30 @@ class RstReaderTest(ReaderTest):
except ImportError:
return unittest.skip('need the typogrify distribution')
+ def test_typogrify_summary(self):
+ # if nothing is specified in the settings, the summary should be
+ # unmodified
+ page = self.read_file(path='article_with_metadata.rst')
+ expected = ('Multi-line metadata should be'
+ ' supported\nas well as inline'
+ ' markup and stuff to "typogrify'
+ '"...
\n')
+
+ self.assertEqual(page.metadata['summary'], expected)
+
+ try:
+ # otherwise, typogrify should be applied
+ page = self.read_file(path='article_with_metadata.rst',
+ TYPOGRIFY=True)
+ expected = ('Multi-line metadata should be'
+ ' supported\nas well as inline'
+ ' markup and stuff to "typogrify'
+ '"…
\n')
+
+ self.assertEqual(page.metadata['summary'], expected)
+ except ImportError:
+ return unittest.skip('need the typogrify distribution')
+
class MdReaderTest(ReaderTest):