mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
doc: convert Markdown example to source_path and modernize
This commit is contained in:
parent
004adfa5cc
commit
9b574361c9
1 changed files with 5 additions and 7 deletions
|
|
@ -47,19 +47,17 @@ Take a look at the Markdown reader::
|
||||||
class MarkdownReader(Reader):
|
class MarkdownReader(Reader):
|
||||||
enabled = bool(Markdown)
|
enabled = bool(Markdown)
|
||||||
|
|
||||||
def read(self, filename):
|
def read(self, source_path):
|
||||||
"""Parse content and metadata of markdown files"""
|
"""Parse content and metadata of markdown files"""
|
||||||
text = open(filename)
|
text = pelican_open(source_path)
|
||||||
md = Markdown(extensions = ['meta', 'codehilite'])
|
md = Markdown(extensions = ['meta', 'codehilite'])
|
||||||
content = md.convert(text)
|
content = md.convert(text)
|
||||||
|
|
||||||
metadata = {}
|
metadata = {}
|
||||||
for name, value in md.Meta.items():
|
for name, value in md.Meta.items():
|
||||||
if name in _METADATA_FIELDS:
|
name = name.lower()
|
||||||
meta = _METADATA_FIELDS[name](value[0])
|
meta = self.process_metadata(name, value[0])
|
||||||
else:
|
metadata[name] = meta
|
||||||
meta = value[0]
|
|
||||||
metadata[name.lower()] = meta
|
|
||||||
return content, metadata
|
return content, metadata
|
||||||
|
|
||||||
Simple, isn't it?
|
Simple, isn't it?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue