mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add a way to use Typogrify to enhance the generated HTML.
This commit is contained in:
parent
fbf89687cc
commit
d43bd1dcb8
5 changed files with 41 additions and 2 deletions
|
|
@ -143,12 +143,24 @@ def read_file(filename, fmt=None, settings=None):
|
|||
"""Return a reader object using the given format."""
|
||||
if not fmt:
|
||||
fmt = filename.split('.')[-1]
|
||||
|
||||
if fmt not in _EXTENSIONS.keys():
|
||||
raise TypeError('Pelican does not know how to parse %s' % filename)
|
||||
|
||||
reader = _EXTENSIONS[fmt](settings)
|
||||
settings_key = '%s_EXTENSIONS' % fmt.upper()
|
||||
|
||||
if settings and settings_key in settings:
|
||||
reader.extensions = settings[settings_key]
|
||||
|
||||
if not reader.enabled:
|
||||
raise ValueError("Missing dependencies for %s" % fmt)
|
||||
return reader.read(filename)
|
||||
|
||||
content, metadata = reader.read(filename)
|
||||
|
||||
# eventually filter the content with typogrify if asked so
|
||||
if settings and settings['TYPOGRIFY']:
|
||||
from typogrify import Typogrify
|
||||
content = Typogrify.typogrify(content)
|
||||
|
||||
return content, metadata
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ _DEFAULT_CONFIG = {'PATH': None,
|
|||
'DEFAULT_METADATA': (),
|
||||
'FILES_TO_COPY': (),
|
||||
'DEFAULT_STATUS': 'published',
|
||||
'ARTICLE_PERMALINK_STRUCTURE': ''
|
||||
'ARTICLE_PERMALINK_STRUCTURE': '',
|
||||
'TYPOGRIFY': False,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue