def __init__(self, config, site):
""" Initialize a new parser for a given type of parsing
Args:
confi (obj_dict): the parser config. It is explicitly defined to allows different conf
site (dictobj): sitefab instantiated object
Return:
None
note: one parser is instanciated by thread. potentially batching more than one post per thread might help with performance.
"""
# verify that the config exist
self.config = config
self.site = site
# NOTE: Might seems weird to do this but templates is what allows to have different rendering for each plugins.
# So we keep it explict in the code as this got messed up countless time :(
self.templates = self.config.templates
# NOTE: This part must be done at parsing time to let plugins time to be loaded/executed.
# Replacing standard template with the one injected by plugins
for elt, template in self.config.injected_html_templates.items():
self.templates[elt] = template
# templates are not compiled yet, they will be when parsing will be called the first time
self.jinja2 = None
# markdown parser
self.renderer = HTMLRenderer()
self.md_parser = mistune.Markdown(renderer=self.renderer)
#code higlighterr
if self.config.code_display_line_num:
linenos = 'table'
else:
linenos = False
self.code_formatter = html.HtmlFormatter(style=self.config.code_highlighting_theme, nobackground=False, linenos=linenos)
评论列表
文章目录