diff --git a/pelican/readers.py b/pelican/readers.py index ae634c80..b5fed611 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -173,6 +173,8 @@ class MarkdownReader(Reader): name = name.lower() if name == "summary": summary_values = "\n".join(value) + # reset the markdown instance to clear any state + self._md.reset() summary = self._md.convert(summary_values) output[name] = self.process_metadata(name, summary) else: diff --git a/pelican/tests/content/article_with_markdown_and_footnote.md b/pelican/tests/content/article_with_markdown_and_footnote.md new file mode 100644 index 00000000..dc257d62 --- /dev/null +++ b/pelican/tests/content/article_with_markdown_and_footnote.md @@ -0,0 +1,8 @@ +Title: Article with markdown containing footnotes +Date: 2012-10-31 +Summary: Summary with **inline** markup *should* be supported. + +This is some content[^1] with some footnotes[^footnote] + +[^1]: Numbered footnote +[^footnote]: Named footnote \ No newline at end of file diff --git a/pelican/tests/test_generators.py b/pelican/tests/test_generators.py index 13156d3b..fa57322d 100644 --- a/pelican/tests/test_generators.py +++ b/pelican/tests/test_generators.py @@ -90,7 +90,9 @@ class TestArticlesGenerator(unittest.TestCase): 'TestCategory', 'article'], ['This is a super article !', 'published', 'yeah', 'article'], ['マックOS X 10.8でパイソンとVirtualenvをインストールと設定', - 'published', '指導書', 'article'] + 'published', '指導書', 'article'], + ['Article with markdown containing footnotes', 'published', + 'Default', 'article'] ] self.assertEqual(sorted(articles_expected), sorted(articles)) diff --git a/pelican/tests/test_readers.py b/pelican/tests/test_readers.py index 386c0172..47cb70ee 100644 --- a/pelican/tests/test_readers.py +++ b/pelican/tests/test_readers.py @@ -143,6 +143,43 @@ class MdReaderTest(unittest.TestCase): for key, value in metadata.items(): self.assertEqual(value, expected[key], key) + + @unittest.skipUnless(readers.Markdown, "markdown isn't installed") + def test_article_with_footnote(self): + reader = readers.MarkdownReader({}) + content, metadata = reader.read( + _path('article_with_markdown_and_footnote.md')) + expected_content = ( + '

This is some content' + '1' + ' with some footnotes' + '2

\n' + + '
\n' + '
\n
    \n
  1. \n' + '

    Numbered footnote ' + '

    \n' + '
  2. \n
  3. \n' + '

    Named footnote ' + '

    \n' + '
  4. \n
\n
') + expected_metadata = { + 'title': 'Article with markdown containing footnotes', + 'summary': ( + '

Summary with inline markup ' + 'should be supported.

'), + 'date': datetime.datetime(2012, 10, 31), + 'slug': 'article-with-markdown-containing-footnotes', + } + self.assertEqual(content, expected_content) + for key, value in metadata.items(): + self.assertEqual(value, expected_metadata[key], key) + + @unittest.skipUnless(readers.Markdown, "markdown isn't installed") def test_article_with_file_extensions(self): reader = readers.MarkdownReader({})