mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Allows Typogrify to ignore user specified tags. Refs #1407
Typogrify interferes with certain sections of the output that it should not touch (see #1407 for more details). This feature adds a setting called TYPOGRIFY_IGNORE_LIST which is a list of tag for Typogrify to ignore. The following was updated: 1. readers.py - if TYPOGRIFY_IGNORE_TAGS is present, then use it 2. settings.ps - default TYPOGRIFY_IGNORE_TAGS to [] 3. contents/article_with_code_block.rst - an article with a code block for typogrify to ignore 4. updated tests 5. updated documentation
This commit is contained in:
parent
f1a9d50a06
commit
a0ecab901f
6 changed files with 79 additions and 3 deletions
|
|
@ -456,11 +456,20 @@ class Readers(FileStampDataCacher):
|
|||
# eventually filter the content with typogrify if asked so
|
||||
if self.settings['TYPOGRIFY']:
|
||||
from typogrify.filters import typogrify
|
||||
|
||||
def typogrify_wrapper(text):
|
||||
"""Ensures ignore_tags feature is backward compatible"""
|
||||
try:
|
||||
return typogrify(text, self.settings['TYPOGRIFY_IGNORE_TAGS'])
|
||||
except TypeError:
|
||||
return typogrify(text)
|
||||
|
||||
if content:
|
||||
content = typogrify(content)
|
||||
metadata['title'] = typogrify(metadata['title'])
|
||||
content = typogrify_wrapper(content)
|
||||
metadata['title'] = typogrify_wrapper(metadata['title'])
|
||||
|
||||
if 'summary' in metadata:
|
||||
metadata['summary'] = typogrify(metadata['summary'])
|
||||
metadata['summary'] = typogrify_wrapper(metadata['summary'])
|
||||
|
||||
if context_signal:
|
||||
logger.debug('signal {}.send({}, <metadata>)'.format(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue