forked from github/pelican
fix usage of pelican_open in docs
This commit is contained in:
parent
541dd72cc0
commit
de793fa9f0
1 changed files with 12 additions and 7 deletions
|
|
@ -44,17 +44,22 @@ HTML content and some metadata.
|
||||||
|
|
||||||
Take a look at the Markdown reader::
|
Take a look at the Markdown reader::
|
||||||
|
|
||||||
|
from pelican.readers import BaseReader
|
||||||
|
from pelican.utils import pelican_open
|
||||||
|
from markdown import Markdown
|
||||||
|
|
||||||
class MarkdownReader(BaseReader):
|
class MarkdownReader(BaseReader):
|
||||||
enabled = bool(Markdown)
|
enabled = True
|
||||||
|
|
||||||
def read(self, source_path):
|
def read(self, source_path):
|
||||||
"""Parse content and metadata of markdown files"""
|
"""Parse content and metadata of markdown files"""
|
||||||
text = pelican_open(source_path)
|
|
||||||
md_extensions = {'markdown.extensions.meta': {},
|
with pelican_open(source_path) as text:
|
||||||
'markdown.extensions.codehilite': {}}
|
md_extensions = {'markdown.extensions.meta': {},
|
||||||
md = Markdown(extensions=md_extensions.keys(),
|
'markdown.extensions.codehilite': {}}
|
||||||
extension_configs=md_extensions)
|
md = Markdown(extensions=md_extensions.keys(),
|
||||||
content = md.convert(text)
|
extension_configs=md_extensions)
|
||||||
|
content = md.convert(text)
|
||||||
|
|
||||||
metadata = {}
|
metadata = {}
|
||||||
for name, value in md.Meta.items():
|
for name, value in md.Meta.items():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue