mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #885 from avaris/markdown-summary-footnote
Markdown summary should not include content footnote
This commit is contained in:
commit
71150430a9
4 changed files with 50 additions and 1 deletions
|
|
@ -173,6 +173,8 @@ class MarkdownReader(Reader):
|
||||||
name = name.lower()
|
name = name.lower()
|
||||||
if name == "summary":
|
if name == "summary":
|
||||||
summary_values = "\n".join(value)
|
summary_values = "\n".join(value)
|
||||||
|
# reset the markdown instance to clear any state
|
||||||
|
self._md.reset()
|
||||||
summary = self._md.convert(summary_values)
|
summary = self._md.convert(summary_values)
|
||||||
output[name] = self.process_metadata(name, summary)
|
output[name] = self.process_metadata(name, summary)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -90,7 +90,9 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
'TestCategory', 'article'],
|
'TestCategory', 'article'],
|
||||||
['This is a super article !', 'published', 'yeah', 'article'],
|
['This is a super article !', 'published', 'yeah', 'article'],
|
||||||
['マックOS X 10.8でパイソンとVirtualenvをインストールと設定',
|
['マックOS X 10.8でパイソンとVirtualenvをインストールと設定',
|
||||||
'published', '指導書', 'article']
|
'published', '指導書', 'article'],
|
||||||
|
['Article with markdown containing footnotes', 'published',
|
||||||
|
'Default', 'article']
|
||||||
]
|
]
|
||||||
self.assertEqual(sorted(articles_expected), sorted(articles))
|
self.assertEqual(sorted(articles_expected), sorted(articles))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,43 @@ class MdReaderTest(unittest.TestCase):
|
||||||
for key, value in metadata.items():
|
for key, value in metadata.items():
|
||||||
self.assertEqual(value, expected[key], key)
|
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 = (
|
||||||
|
'<p>This is some content'
|
||||||
|
'<sup id="fnref:1"><a class="footnote-ref" href="#fn:1" '
|
||||||
|
'rel="footnote">1</a></sup>'
|
||||||
|
' with some footnotes'
|
||||||
|
'<sup id="fnref:footnote"><a class="footnote-ref" '
|
||||||
|
'href="#fn:footnote" rel="footnote">2</a></sup></p>\n'
|
||||||
|
|
||||||
|
'<div class="footnote">\n'
|
||||||
|
'<hr />\n<ol>\n<li id="fn:1">\n'
|
||||||
|
'<p>Numbered footnote '
|
||||||
|
'<a class="footnote-backref" href="#fnref:1" rev="footnote" '
|
||||||
|
'title="Jump back to footnote 1 in the text">↩</a></p>\n'
|
||||||
|
'</li>\n<li id="fn:footnote">\n'
|
||||||
|
'<p>Named footnote '
|
||||||
|
'<a class="footnote-backref" href="#fnref:footnote" rev="footnote" '
|
||||||
|
'title="Jump back to footnote 2 in the text">↩</a></p>\n'
|
||||||
|
'</li>\n</ol>\n</div>')
|
||||||
|
expected_metadata = {
|
||||||
|
'title': 'Article with markdown containing footnotes',
|
||||||
|
'summary': (
|
||||||
|
'<p>Summary with <strong>inline</strong> markup '
|
||||||
|
'<em>should</em> be supported.</p>'),
|
||||||
|
'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")
|
@unittest.skipUnless(readers.Markdown, "markdown isn't installed")
|
||||||
def test_article_with_file_extensions(self):
|
def test_article_with_file_extensions(self):
|
||||||
reader = readers.MarkdownReader({})
|
reader = readers.MarkdownReader({})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue