de-complexify post.render()
This commit is contained in:
parent
4d1dc94f68
commit
4d8b8188a4
1 changed files with 16 additions and 12 deletions
|
@ -157,18 +157,7 @@ class Post(object):
|
|||
# actually render post
|
||||
add_style = ''
|
||||
if self.extension == '.md':
|
||||
self.body = markdown2.markdown(
|
||||
post_content,
|
||||
extras=config.mdextras,
|
||||
)
|
||||
# rewrite relative img-srcs to full paths.
|
||||
d = PyQuery(self.body)
|
||||
for img in d.find('img'):
|
||||
if not '/' in img.attrib['src']:
|
||||
img.attrib['src'] = '{}{}/{}'.format(config.blogurl,
|
||||
self.outputpath,
|
||||
img.attrib['src'])
|
||||
self.body = d.html()
|
||||
self.render_md5(post_content)
|
||||
elif self.extension == '.rst':
|
||||
rst = publish_parts(
|
||||
post_content,
|
||||
|
@ -187,6 +176,21 @@ class Post(object):
|
|||
add_style=add_style,
|
||||
)
|
||||
|
||||
def render_md5(self, post_content):
|
||||
config = Config()
|
||||
self.body = markdown2.markdown(
|
||||
post_content,
|
||||
extras=config.mdextras,
|
||||
)
|
||||
# rewrite relative img-srcs to full paths.
|
||||
d = PyQuery(self.body)
|
||||
for img in d.find('img'):
|
||||
if not '/' in img.attrib['src']:
|
||||
img.attrib['src'] = '{}{}/{}'.format(config.blogurl,
|
||||
self.outputpath,
|
||||
img.attrib['src'])
|
||||
self.body = d.html()
|
||||
|
||||
|
||||
class Page(Post):
|
||||
""" all info about a blog page.
|
||||
|
|
Reference in a new issue