diff --git a/docs/fr/configuration.rst b/docs/fr/configuration.rst index 151eff3a..35965ed6 100644 --- a/docs/fr/configuration.rst +++ b/docs/fr/configuration.rst @@ -155,7 +155,5 @@ SITEURL : STATIC_PATHS : Les chemins statiques que vous voulez avoir accès sur le chemin de sortie "statique" ; - - - - +MARKDOWN_EXTENTIONS : + Liste des extentions Markdown que vous souhaitez utiliser ; diff --git a/docs/settings.rst b/docs/settings.rst index 4d865a7f..384c1a19 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -103,7 +103,7 @@ Setting name (default value) What doe This only applies if your content does not otherwise specify a summary. Setting to None will cause the summary to be a copy of the original content. - +`MARKDOWN_EXTENSIONS` (``['toc',]``) A list of any Markdown extensions you want to use. ===================================================================== ===================================================================== .. [#] Default is the system locale. diff --git a/pelican/readers.py b/pelican/readers.py index 38e7834f..1c2ac666 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -101,7 +101,7 @@ class RstReader(Reader): def _get_publisher(self, filename): extra_params = {'initial_header_level': '2'} pub = docutils.core.Publisher( - destination_class=docutils.io.StringOutput) + destination_class=docutils.io.StringOutput) pub.set_components('standalone', 'restructuredtext', 'html') pub.writer.translator_class = PelicanHTMLTranslator pub.process_programmatic_settings(None, extra_params, None) @@ -124,13 +124,17 @@ class RstReader(Reader): class MarkdownReader(Reader): enabled = bool(Markdown) file_extensions = ['md', 'markdown', 'mkd'] - extensions = ['codehilite', 'extra' ] + extensions = ['codehilite', 'extra'] def read(self, filename): """Parse content and metadata of markdown files""" markdown_extentions = self.settings.get('MARKDOWN_EXTENTIONS', []) + if isinstance(markdown_extentions, (str, unicode)): + markdown_extentions = [m.strip() for m in + markdown_extentions.split(',')] text = pelican_open(filename) - md = Markdown(extensions=set(self.extensions + markdown_extentions + ['meta'])) + md = Markdown(extensions=set( + self.extensions + markdown_extentions + ['meta'])) content = md.convert(text) metadata = {} diff --git a/pelican/settings.py b/pelican/settings.py index f2511844..ad0ff8fc 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -75,7 +75,7 @@ _DEFAULT_CONFIG = {'PATH': '.', 'SUMMARY_MAX_LENGTH': 50, 'WEBASSETS': False, 'PLUGINS': [], - 'MARKDOWN_EXTENTIONS': [], + 'MARKDOWN_EXTENTIONS': [ 'toc', ], } diff --git a/tests/test_readers.py b/tests/test_readers.py index 299aa378..d831252d 100644 --- a/tests/test_readers.py +++ b/tests/test_readers.py @@ -90,3 +90,22 @@ class MdReaderTest(unittest.TestCase): "
This is another markdown test file. Uses the mkd extension.
" self.assertEqual(content, expected) + + @unittest.skipUnless(readers.Markdown, "markdown isn't installed") + def test_article_with_markdown_markup_extension(self): + # test to ensure the markdown markup extension is being processed as expected + reader = readers.MarkdownReader({}) + reader.settings.update(dict(MARKDOWN_EXTENTIONS=['toc'])) + content, metadata = reader.read(_filename('article_with_markdown_markup_extentions.md')) + expected = '\n'\ + '