def get_blog(cls, file_name):
if cls.is_exist(file_name):
with open(cls._real_file_name(file_name), 'r', encoding='utf-8') as f:
txt = f.read()
mtime = os.path.getmtime(cls._real_file_name(file_name))
from bs4 import BeautifulSoup, Comment
import yaml
comment = BeautifulSoup(txt, "html.parser").find(text=lambda text: isinstance(text, Comment))
if comment is not None:
blog_info = yaml.load(comment)
if 'use_toc' not in blog_info:
blog_info['use_toc'] = False
html = markdown(txt)
return blog_info, txt, html, mtime
else:
return
else:
return
评论列表
文章目录