forked from github/pelican
Replaces MD_EXTENSIONS with MARKDOWN
MARKDOWN allows to configure the python markdown module fixes #1024
This commit is contained in:
parent
594b9c9633
commit
35dba138e0
2 changed files with 22 additions and 15 deletions
|
|
@ -246,8 +246,16 @@ class MarkdownReader(BaseReader):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MarkdownReader, self).__init__(*args, **kwargs)
|
||||
self.extensions = self.settings['MD_EXTENSIONS']
|
||||
self.extensions.setdefault('markdown.extensions.meta', {})
|
||||
# make sure 'extension_configs' exists and
|
||||
# and either way 'markdown.extensions.meta' must be in there
|
||||
settings = self.settings['MARKDOWN']
|
||||
settings.setdefault('extension_configs', {})
|
||||
settings['extension_configs'].setdefault(
|
||||
'markdown.extensions.meta', {})
|
||||
settings.setdefault('extensions', [])
|
||||
settings['extensions'].extend(
|
||||
list(settings['extension_configs'].keys()))
|
||||
settings['extensions'] = list(set(settings['extensions']))
|
||||
self._source_path = None
|
||||
|
||||
def _parse_metadata(self, meta):
|
||||
|
|
@ -283,8 +291,7 @@ class MarkdownReader(BaseReader):
|
|||
"""Parse content and metadata of markdown files"""
|
||||
|
||||
self._source_path = source_path
|
||||
self._md = Markdown(extensions=self.extensions.keys(),
|
||||
extension_configs=self.extensions)
|
||||
self._md = Markdown(**self.settings['MARKDOWN'])
|
||||
with pelican_open(source_path) as text:
|
||||
content = self._md.convert(text)
|
||||
|
||||
|
|
|
|||
|
|
@ -101,10 +101,12 @@ DEFAULT_CONFIG = {
|
|||
'PELICAN_CLASS': 'pelican.Pelican',
|
||||
'DEFAULT_DATE_FORMAT': '%a %d %B %Y',
|
||||
'DATE_FORMATS': {},
|
||||
'MD_EXTENSIONS': {
|
||||
'markdown.extensions.codehilite': {'css_class': 'highlight'},
|
||||
'markdown.extensions.extra': {},
|
||||
'markdown.extensions.meta': {},
|
||||
'MARKDOWN': {
|
||||
'extension_configs': {
|
||||
'markdown.extensions.codehilite': {'css_class': 'highlight'},
|
||||
'markdown.extensions.extra': {},
|
||||
'markdown.extensions.meta': {},
|
||||
},
|
||||
},
|
||||
'JINJA_EXTENSIONS': [],
|
||||
'JINJA_FILTERS': {},
|
||||
|
|
@ -368,13 +370,11 @@ def configure_settings(settings):
|
|||
PATH_KEY)
|
||||
settings[PATH_KEY] = DEFAULT_CONFIG[PATH_KEY]
|
||||
|
||||
# Save people from declaring MD_EXTENSIONS as a list rather than a dict
|
||||
if not isinstance(settings.get('MD_EXTENSIONS', {}), dict):
|
||||
logger.warning('The format of the MD_EXTENSIONS setting has '
|
||||
'changed. It should now be a dict mapping '
|
||||
'fully-qualified extension names to their '
|
||||
'configurations. Falling back to the default.')
|
||||
settings['MD_EXTENSIONS'] = DEFAULT_CONFIG['MD_EXTENSIONS']
|
||||
# Deprecated warning of MD_EXTENSIONS
|
||||
if 'MD_EXTENSIONS' in settings:
|
||||
logger.warning('MD_EXTENSIONS is deprecated use MARKDOWN '
|
||||
'instead. Falling back to the default.')
|
||||
settings['MARKDOWN'] = DEFAULT_CONFIG['MARKDOWN']
|
||||
|
||||
# Add {PAGE,ARTICLE}_PATHS to {ARTICLE,PAGE}_EXCLUDES
|
||||
mutually_exclusive = ('ARTICLE', 'PAGE')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue