mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Fixes #1420: Handle multiple definitions of standard metadata for Markdown
This commit is contained in:
parent
b8c9d61f20
commit
a2bb80b8bd
1 changed files with 7 additions and 0 deletions
|
|
@ -201,6 +201,7 @@ class MarkdownReader(BaseReader):
|
|||
self.extensions = list(self.settings['MD_EXTENSIONS'])
|
||||
if 'meta' not in self.extensions:
|
||||
self.extensions.append('meta')
|
||||
self._source_path = None
|
||||
|
||||
def _parse_metadata(self, meta):
|
||||
"""Return the dict containing document metadata"""
|
||||
|
|
@ -215,6 +216,11 @@ class MarkdownReader(BaseReader):
|
|||
self._md.reset()
|
||||
summary = self._md.convert(summary_values)
|
||||
output[name] = self.process_metadata(name, summary)
|
||||
elif name in METADATA_PROCESSORS:
|
||||
if len(value) > 1:
|
||||
logger.warning('Duplicate definition of `%s` '
|
||||
'for %s. Using first one.', name, self._source_path)
|
||||
output[name] = self.process_metadata(name, value[0])
|
||||
elif len(value) > 1:
|
||||
# handle list metadata as list of string
|
||||
output[name] = self.process_metadata(name, value)
|
||||
|
|
@ -226,6 +232,7 @@ class MarkdownReader(BaseReader):
|
|||
def read(self, source_path):
|
||||
"""Parse content and metadata of markdown files"""
|
||||
|
||||
self._source_path = source_path
|
||||
self._md = Markdown(extensions=self.extensions)
|
||||
with pelican_open(source_path) as text:
|
||||
content = self._md.convert(text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue