mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
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):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MarkdownReader, self).__init__(*args, **kwargs)
|
super(MarkdownReader, self).__init__(*args, **kwargs)
|
||||||
self.extensions = self.settings['MD_EXTENSIONS']
|
# make sure 'extension_configs' exists and
|
||||||
self.extensions.setdefault('markdown.extensions.meta', {})
|
# 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
|
self._source_path = None
|
||||||
|
|
||||||
def _parse_metadata(self, meta):
|
def _parse_metadata(self, meta):
|
||||||
|
|
@ -283,8 +291,7 @@ class MarkdownReader(BaseReader):
|
||||||
"""Parse content and metadata of markdown files"""
|
"""Parse content and metadata of markdown files"""
|
||||||
|
|
||||||
self._source_path = source_path
|
self._source_path = source_path
|
||||||
self._md = Markdown(extensions=self.extensions.keys(),
|
self._md = Markdown(**self.settings['MARKDOWN'])
|
||||||
extension_configs=self.extensions)
|
|
||||||
with pelican_open(source_path) as text:
|
with pelican_open(source_path) as text:
|
||||||
content = self._md.convert(text)
|
content = self._md.convert(text)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,12 @@ DEFAULT_CONFIG = {
|
||||||
'PELICAN_CLASS': 'pelican.Pelican',
|
'PELICAN_CLASS': 'pelican.Pelican',
|
||||||
'DEFAULT_DATE_FORMAT': '%a %d %B %Y',
|
'DEFAULT_DATE_FORMAT': '%a %d %B %Y',
|
||||||
'DATE_FORMATS': {},
|
'DATE_FORMATS': {},
|
||||||
'MD_EXTENSIONS': {
|
'MARKDOWN': {
|
||||||
'markdown.extensions.codehilite': {'css_class': 'highlight'},
|
'extension_configs': {
|
||||||
'markdown.extensions.extra': {},
|
'markdown.extensions.codehilite': {'css_class': 'highlight'},
|
||||||
'markdown.extensions.meta': {},
|
'markdown.extensions.extra': {},
|
||||||
|
'markdown.extensions.meta': {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'JINJA_EXTENSIONS': [],
|
'JINJA_EXTENSIONS': [],
|
||||||
'JINJA_FILTERS': {},
|
'JINJA_FILTERS': {},
|
||||||
|
|
@ -368,13 +370,11 @@ def configure_settings(settings):
|
||||||
PATH_KEY)
|
PATH_KEY)
|
||||||
settings[PATH_KEY] = DEFAULT_CONFIG[PATH_KEY]
|
settings[PATH_KEY] = DEFAULT_CONFIG[PATH_KEY]
|
||||||
|
|
||||||
# Save people from declaring MD_EXTENSIONS as a list rather than a dict
|
# Deprecated warning of MD_EXTENSIONS
|
||||||
if not isinstance(settings.get('MD_EXTENSIONS', {}), dict):
|
if 'MD_EXTENSIONS' in settings:
|
||||||
logger.warning('The format of the MD_EXTENSIONS setting has '
|
logger.warning('MD_EXTENSIONS is deprecated use MARKDOWN '
|
||||||
'changed. It should now be a dict mapping '
|
'instead. Falling back to the default.')
|
||||||
'fully-qualified extension names to their '
|
settings['MARKDOWN'] = DEFAULT_CONFIG['MARKDOWN']
|
||||||
'configurations. Falling back to the default.')
|
|
||||||
settings['MD_EXTENSIONS'] = DEFAULT_CONFIG['MD_EXTENSIONS']
|
|
||||||
|
|
||||||
# Add {PAGE,ARTICLE}_PATHS to {ARTICLE,PAGE}_EXCLUDES
|
# Add {PAGE,ARTICLE}_PATHS to {ARTICLE,PAGE}_EXCLUDES
|
||||||
mutually_exclusive = ('ARTICLE', 'PAGE')
|
mutually_exclusive = ('ARTICLE', 'PAGE')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue