mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Apply typogrify on article summary as well
This commit is contained in:
parent
d9bbdf7f07
commit
91d576eb45
3 changed files with 33 additions and 5 deletions
|
|
@ -462,10 +462,13 @@ class Readers(object):
|
||||||
find_empty_alt(content, path)
|
find_empty_alt(content, path)
|
||||||
|
|
||||||
# eventually filter the content with typogrify if asked so
|
# eventually filter the content with typogrify if asked so
|
||||||
if content and self.settings['TYPOGRIFY']:
|
if self.settings['TYPOGRIFY']:
|
||||||
from typogrify.filters import typogrify
|
from typogrify.filters import typogrify
|
||||||
content = typogrify(content)
|
if content:
|
||||||
metadata['title'] = typogrify(metadata['title'])
|
content = typogrify(content)
|
||||||
|
metadata['title'] = typogrify(metadata['title'])
|
||||||
|
if 'summary' in metadata:
|
||||||
|
metadata['summary'] = typogrify(metadata['summary'])
|
||||||
|
|
||||||
if context_signal:
|
if context_signal:
|
||||||
logger.debug('signal {}.send({}, <metadata>)'.format(
|
logger.debug('signal {}.send({}, <metadata>)'.format(
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,5 @@ This is a super article !
|
||||||
:author: Alexis Métaireau
|
:author: Alexis Métaireau
|
||||||
:summary:
|
:summary:
|
||||||
Multi-line metadata should be supported
|
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
|
:custom_field: http://notmyidea.org
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ class RstReaderTest(ReaderTest):
|
||||||
'title': 'This is a super article !',
|
'title': 'This is a super article !',
|
||||||
'summary': '<p class="first last">Multi-line metadata should be'
|
'summary': '<p class="first last">Multi-line metadata should be'
|
||||||
' supported\nas well as <strong>inline'
|
' supported\nas well as <strong>inline'
|
||||||
' markup</strong>.</p>\n',
|
' markup</strong> and stuff to "typogrify'
|
||||||
|
'"...</p>\n',
|
||||||
'date': datetime.datetime(2010, 12, 2, 10, 14),
|
'date': datetime.datetime(2010, 12, 2, 10, 14),
|
||||||
'modified': datetime.datetime(2010, 12, 2, 10, 20),
|
'modified': datetime.datetime(2010, 12, 2, 10, 20),
|
||||||
'tags': ['foo', 'bar', 'foobar'],
|
'tags': ['foo', 'bar', 'foobar'],
|
||||||
|
|
@ -125,6 +126,30 @@ class RstReaderTest(ReaderTest):
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return unittest.skip('need the typogrify distribution')
|
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 = ('<p class="first last">Multi-line metadata should be'
|
||||||
|
' supported\nas well as <strong>inline'
|
||||||
|
' markup</strong> and stuff to "typogrify'
|
||||||
|
'"...</p>\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 = ('<p class="first last">Multi-line metadata should be'
|
||||||
|
' supported\nas well as <strong>inline'
|
||||||
|
' markup</strong> and stuff to "typogrify'
|
||||||
|
'"…</p>\n')
|
||||||
|
|
||||||
|
self.assertEqual(page.metadata['summary'], expected)
|
||||||
|
except ImportError:
|
||||||
|
return unittest.skip('need the typogrify distribution')
|
||||||
|
|
||||||
|
|
||||||
class MdReaderTest(ReaderTest):
|
class MdReaderTest(ReaderTest):
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue