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::
|
||||
|
||||
from pelican.readers import BaseReader
|
||||
from pelican.utils import pelican_open
|
||||
from markdown import Markdown
|
||||
|
||||
class MarkdownReader(BaseReader):
|
||||
enabled = bool(Markdown)
|
||||
enabled = True
|
||||
|
||||
def read(self, source_path):
|
||||
"""Parse content and metadata of markdown files"""
|
||||
text = pelican_open(source_path)
|
||||
md_extensions = {'markdown.extensions.meta': {},
|
||||
'markdown.extensions.codehilite': {}}
|
||||
md = Markdown(extensions=md_extensions.keys(),
|
||||
extension_configs=md_extensions)
|
||||
content = md.convert(text)
|
||||
|
||||
with pelican_open(source_path) as text:
|
||||
md_extensions = {'markdown.extensions.meta': {},
|
||||
'markdown.extensions.codehilite': {}}
|
||||
md = Markdown(extensions=md_extensions.keys(),
|
||||
extension_configs=md_extensions)
|
||||
content = md.convert(text)
|
||||
|
||||
metadata = {}
|
||||
for name, value in md.Meta.items():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue