From b02e0ffb07bbbfd829954bd24f0b016ece478848 Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Sun, 29 Nov 2015 00:36:52 +0200 Subject: [PATCH] Add MD_EXTENSION_CONFIGS setting used to control Markdown extensions configuration --- docs/content.rst | 3 ++- docs/settings.rst | 2 ++ pelican/readers.py | 4 +++- pelican/settings.py | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/content.rst b/docs/content.rst index 0fa89921..cb237fc9 100644 --- a/docs/content.rst +++ b/docs/content.rst @@ -53,7 +53,8 @@ install Markdown``. Pelican also supports `Markdown Extensions`_, which might have to be installed separately if they are not included in the default ``Markdown`` package and can -be configured and loaded via the ``MD_EXTENSIONS`` setting. +be configured and loaded via the ``MD_EXTENSIONS`` setting. The +``MD_EXTENSION_CONFIGS`` setting controls extensions configuration. Metadata syntax for Markdown posts should follow this pattern:: diff --git a/docs/settings.rst b/docs/settings.rst index 61fd8521..8eaeca16 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -121,6 +121,8 @@ Setting name (followed by default value, if any) to the default values for this setting, you'll need to include them explicitly and enumerate the full list of desired Markdown extensions.) +``MD_EXTENSION_CONFIGS = {}`` A configuration dictionary for the extensions the Markdown + processor will use. ``OUTPUT_PATH = 'output/'`` Where to output the generated files. ``PATH`` Path to content directory to be processed by Pelican. If undefined, and content path is not specified via an argument to the ``pelican`` diff --git a/pelican/readers.py b/pelican/readers.py index 4ea234bb..f4472677 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -247,6 +247,7 @@ class MarkdownReader(BaseReader): def __init__(self, *args, **kwargs): super(MarkdownReader, self).__init__(*args, **kwargs) self.extensions = list(self.settings['MD_EXTENSIONS']) + self.extension_configs = self.settings['MD_EXTENSION_CONFIGS'] if 'meta' not in self.extensions: self.extensions.append('meta') self._source_path = None @@ -284,7 +285,8 @@ class MarkdownReader(BaseReader): """Parse content and metadata of markdown files""" self._source_path = source_path - self._md = Markdown(extensions=self.extensions) + self._md = Markdown(extensions=self.extensions, + extension_configs=self.extension_configs) with pelican_open(source_path) as text: content = self._md.convert(text) diff --git a/pelican/settings.py b/pelican/settings.py index d1b1648b..39367fe9 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -102,6 +102,7 @@ DEFAULT_CONFIG = { 'DEFAULT_DATE_FORMAT': '%a %d %B %Y', 'DATE_FORMATS': {}, 'MD_EXTENSIONS': ['codehilite(css_class=highlight)', 'extra'], + 'MD_EXTENSION_CONFIGS': {}, 'JINJA_EXTENSIONS': [], 'JINJA_FILTERS': {}, 'LOG_FILTER': [],