diff --git a/pelican/readers.py b/pelican/readers.py index c1c8dbfa..1adc2b66 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -249,6 +249,7 @@ class MarkdownReader(BaseReader): if 'meta' not in self.extensions: self.extensions.append('meta') self._source_path = None + self.output_format = self.settings['MD_OUTPUT_FORMAT'] def _parse_metadata(self, meta): """Return the dict containing document metadata""" @@ -282,7 +283,9 @@ 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, + output_format=self.output_format) with pelican_open(source_path) as text: content = self._md.convert(text) diff --git a/pelican/settings.py b/pelican/settings.py index c1a902cd..43dd62cf 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -100,6 +100,7 @@ DEFAULT_CONFIG = { 'DEFAULT_DATE_FORMAT': '%a %d %B %Y', 'DATE_FORMATS': {}, 'MD_EXTENSIONS': ['codehilite(css_class=highlight)', 'extra'], + 'MD_OUTPUT_FORMAT' : 'xhtml1', 'JINJA_EXTENSIONS': [], 'JINJA_FILTERS': {}, 'LOG_FILTER': [], diff --git a/pelican/tests/content/article_with_different_output_format.md b/pelican/tests/content/article_with_different_output_format.md new file mode 100644 index 00000000..f9081591 --- /dev/null +++ b/pelican/tests/content/article_with_different_output_format.md @@ -0,0 +1,5 @@ +Title: Article output format + +Some text[^footnote] + +[^footnote]: Some footnote \ No newline at end of file diff --git a/pelican/tests/test_readers.py b/pelican/tests/test_readers.py index dd7e5fc2..4e14d829 100644 --- a/pelican/tests/test_readers.py +++ b/pelican/tests/test_readers.py @@ -500,6 +500,43 @@ class MdReaderTest(ReaderTest): } self.assertDictHasSubset(page.metadata, expected) + def test_article_with_different_output_format(self): + reader = readers.MarkdownReader(settings=get_settings()) + # test the default xhtml1 output format + expected = ('
Some text1
\n' + 'Some footnote ↩
\n' + 'Some text1
\n' + 'Some footnote ' + '↩
\n' + '