forked from github/pelican
Merge pull request #635 from michaelreneer/markdown-summary-metadata
Updated markdown reader to parse summary metadata as markup.
This commit is contained in:
commit
92c085c28e
5 changed files with 43 additions and 4 deletions
|
|
@ -133,16 +133,27 @@ class MarkdownReader(Reader):
|
|||
file_extensions = ['md', 'markdown', 'mkd']
|
||||
extensions = ['codehilite', 'extra']
|
||||
|
||||
def _parse_metadata(self, meta):
|
||||
"""Return the dict containing document metadata"""
|
||||
md = Markdown(extensions=set(self.extensions + ['meta']))
|
||||
output = {}
|
||||
for name, value in meta.items():
|
||||
name = name.lower()
|
||||
if name == "summary":
|
||||
summary_values = "\n".join(str(item) for item in value)
|
||||
summary = md.convert(summary_values)
|
||||
output[name] = self.process_metadata(name, summary)
|
||||
else:
|
||||
output[name] = self.process_metadata(name, value[0])
|
||||
return output
|
||||
|
||||
def read(self, filename):
|
||||
"""Parse content and metadata of markdown files"""
|
||||
text = pelican_open(filename)
|
||||
md = Markdown(extensions=set(self.extensions + ['meta']))
|
||||
content = md.convert(text)
|
||||
|
||||
metadata = {}
|
||||
for name, value in md.Meta.items():
|
||||
name = name.lower()
|
||||
metadata[name] = self.process_metadata(name, value[0])
|
||||
metadata = self._parse_metadata(md.Meta)
|
||||
return content, metadata
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue