forked from github/pelican
Merge pull request #2714 from getpelican/skip-md-metadata-parse
Skip Markdown metadata parsing within metadata fields
This commit is contained in:
commit
0f97f6d488
4 changed files with 24 additions and 0 deletions
|
|
@ -302,6 +302,9 @@ class MarkdownReader(BaseReader):
|
|||
"""Return the dict containing document metadata"""
|
||||
formatted_fields = self.settings['FORMATTED_FIELDS']
|
||||
|
||||
# prevent metadata extraction in fields
|
||||
self._md.preprocessors.deregister('meta')
|
||||
|
||||
output = {}
|
||||
for name, value in meta.items():
|
||||
name = name.lower()
|
||||
|
|
|
|||
5
pelican/tests/content/article_with_markdown_and_nested_metadata.md
vendored
Normal file
5
pelican/tests/content/article_with_markdown_and_nested_metadata.md
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Title: Article with markdown and nested summary metadata
|
||||
Date: 2012-10-30
|
||||
Summary: Test: This metadata value looks like metadata
|
||||
|
||||
This is some content.
|
||||
|
|
@ -239,6 +239,8 @@ class TestArticlesGenerator(unittest.TestCase):
|
|||
['Article title', 'published', 'Default', 'article'],
|
||||
['Article with markdown and summary metadata multi', 'published',
|
||||
'Default', 'article'],
|
||||
['Article with markdown and nested summary metadata', 'published',
|
||||
'Default', 'article'],
|
||||
['Article with markdown and summary metadata single', 'published',
|
||||
'Default', 'article'],
|
||||
['Article with markdown containing footnotes', 'published',
|
||||
|
|
@ -554,6 +556,7 @@ class TestArticlesGenerator(unittest.TestCase):
|
|||
'Article title',
|
||||
'Article with Nonconformant HTML meta tags',
|
||||
'Article with an inline SVG',
|
||||
'Article with markdown and nested summary metadata',
|
||||
'Article with markdown and summary metadata multi',
|
||||
'Article with markdown and summary metadata single',
|
||||
'Article with markdown containing footnotes',
|
||||
|
|
|
|||
|
|
@ -645,6 +645,19 @@ class MdReaderTest(ReaderTest):
|
|||
}
|
||||
self.assertDictHasSubset(metadata, expected)
|
||||
|
||||
def test_metadata_not_parsed_for_metadata(self):
|
||||
settings = get_settings()
|
||||
settings['FORMATTED_FIELDS'] = ['summary']
|
||||
|
||||
reader = readers.MarkdownReader(settings=settings)
|
||||
content, metadata = reader.read(
|
||||
_path('article_with_markdown_and_nested_metadata.md'))
|
||||
expected = {
|
||||
'title': 'Article with markdown and nested summary metadata',
|
||||
'summary': '<p>Test: This metadata value looks like metadata</p>',
|
||||
}
|
||||
self.assertDictHasSubset(metadata, expected)
|
||||
|
||||
def test_empty_file(self):
|
||||
reader = readers.MarkdownReader(settings=get_settings())
|
||||
content, metadata = reader.read(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue