mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge 7af4e3336a into d824b79a19
This commit is contained in:
commit
e277e8c9c7
5 changed files with 30 additions and 2 deletions
|
|
@ -9,6 +9,8 @@ Release history
|
|||
longer article-specific
|
||||
* Deprecate ``FILES_TO_COPY`` in favor of ``STATIC_PATHS`` and
|
||||
``EXTRA_PATH_METADATA``
|
||||
* Add ``bare_title`` to metadata when ``title`` exists,
|
||||
allowing for non-typogrified ``<title>`` tag when ``TYPOGRIFY=True``.
|
||||
|
||||
3.2.1 and 3.2.2
|
||||
===============
|
||||
|
|
|
|||
|
|
@ -456,6 +456,9 @@ class Readers(object):
|
|||
find_empty_alt(content, path)
|
||||
|
||||
# eventually filter the content with typogrify if asked so
|
||||
if 'title' in metadata:
|
||||
# Allow templates to include non-typogrified title in <title> tag.
|
||||
metadata['bare_title'] = metadata['title']
|
||||
if content and self.settings['TYPOGRIFY']:
|
||||
from typogrify.filters import typogrify
|
||||
content = typogrify(content)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Article title
|
||||
Article TITLE
|
||||
#############
|
||||
|
||||
This is some content. With some stuff to "typogrify".
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class TestArticlesGenerator(unittest.TestCase):
|
|||
def test_generate_context(self):
|
||||
|
||||
articles_expected = [
|
||||
['Article title', 'published', 'Default', 'article'],
|
||||
['Article TITLE', 'published', 'Default', 'article'],
|
||||
['Article with markdown and summary metadata multi', 'published',
|
||||
'Default', 'article'],
|
||||
['Article with markdown and summary metadata single', 'published',
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class RstReaderTest(ReaderTest):
|
|||
'author': 'Alexis Métaireau',
|
||||
'title': 'Rst with filename metadata',
|
||||
}
|
||||
expected['bare_title'] = expected['title']
|
||||
for key, value in page.metadata.items():
|
||||
self.assertEqual(value, expected[key], key)
|
||||
|
||||
|
|
@ -63,6 +64,7 @@ class RstReaderTest(ReaderTest):
|
|||
'title': 'Rst with filename metadata',
|
||||
'date': datetime.datetime(2012, 11, 29),
|
||||
}
|
||||
expected['bare_title'] = expected['title']
|
||||
for key, value in page.metadata.items():
|
||||
self.assertEqual(value, expected[key], key)
|
||||
|
||||
|
|
@ -80,6 +82,7 @@ class RstReaderTest(ReaderTest):
|
|||
'slug': 'article_with_filename_metadata',
|
||||
'mymeta': 'foo',
|
||||
}
|
||||
expected['bare_title'] = expected['title']
|
||||
for key, value in page.metadata.items():
|
||||
self.assertEqual(value, expected[key], key)
|
||||
|
||||
|
|
@ -116,6 +119,26 @@ class RstReaderTest(ReaderTest):
|
|||
except ImportError:
|
||||
return unittest.skip('need the typogrify distribution')
|
||||
|
||||
def test_bare_title(self):
|
||||
# if nothing is specified in the settings, the content should be
|
||||
# unmodified
|
||||
page = self.read_file(path='article.rst')
|
||||
expected_bare_title = 'Article TITLE'
|
||||
expected_title = 'Article TITLE'
|
||||
self.assertEqual(page.bare_title, expected_bare_title)
|
||||
self.assertEqual(page.title, expected_title)
|
||||
|
||||
try:
|
||||
# otherwise, typogrify should be applied to title,
|
||||
# but not to bare_title
|
||||
page = self.read_file(path='article.rst', TYPOGRIFY=True)
|
||||
expected_bare_title = 'Article TITLE'
|
||||
expected_title = 'Article <span class="caps">TITLE</span>'
|
||||
self.assertEqual(page.bare_title, expected_bare_title)
|
||||
self.assertEqual(page.title, expected_title)
|
||||
except ImportError:
|
||||
return unittest.skip('need the typogrify distribution')
|
||||
|
||||
|
||||
class MdReaderTest(ReaderTest):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue