def __init__(self, sitedir, project): self.sitedir = sitedir self.filelist = project.filelist self.navlist = project.navlist self.taglist = project.taglist self.site = project.site tableclass = md_extensions.TableClassExtension() projectref = md_extensions.ProjectReferenceExtension() checklist = ChecklistExtension() extensions = [ 'extra', 'codehilite', 'headerid', 'toc', 'smarty', tableclass, projectref, checklist ] extension_configs = { 'codehilite': [('guess_lang', 'False'), ('linenums', 'False')], 'headerid': [('level', 2)] } self.md = markdown.Markdown(extensions=extensions, extension_configs=extension_configs) self.md.site = self.site env = self.env = jinja2.Environment( loader=jinja2.FileSystemLoader(layoutdir), lstrip_blocks=True, trim_blocks=True) env.filters.update(project.filters) self.templates = {} for layout in project.layouts: self.templates[layout] = self.env.get_template(layout + '.html') # layout for tags is optional, triggers index file generation per tag try: self.templates[tag_layout] = self.env.get_template(tag_layout + '.html') except jinja2.exceptions.TemplateNotFound: if self.taglist: warn(tag_layout_warning, UrubuWarning)
def __init__(self, sitedir, project): self.sitedir = sitedir self.filelist = project.filelist self.navlist = project.navlist self.taglist = project.taglist self.site = project.site dlclass = md_extensions.DLClassExtension() tableclass = md_extensions.TableClassExtension() projectref = md_extensions.ProjectReferenceExtension() extractanchors = md_extensions.ExtractAnchorsExtension() marktag = md_extensions.MarkTagExtension() # there is a strange interaction between smarty and reference links that start on a new line # disabling smarty for now... # extensions = ['extra', 'codehilite', 'headerid', 'toc', 'smarty', tableclass, projectref] extensions = [ 'markdown.extensions.extra', 'markdown.extensions.codehilite', 'markdown.extensions.toc', dlclass, tableclass, projectref, extractanchors ] if self.site['mark_tag_support']: extensions.append(marktag) extension_configs = { 'markdown.extensions.codehilite': [('guess_lang', 'False'), ('linenums', 'False')], 'markdown.extensions.toc': [('baselevel', 2)] } self.md = markdown.Markdown(extensions=extensions, extension_configs=extension_configs) self.md.site = self.site self.md.anchors = project.anchors if 'strict_undefined' in self.site and self.site['strict_undefined']: undefined_class = jinja2.StrictUndefined else: undefined_class = jinja2.Undefined env = self.env = jinja2.Environment( loader=jinja2.FileSystemLoader(layoutdir), lstrip_blocks=True, trim_blocks=True, undefined=undefined_class) env.filters.update(project.filters) self.templates = {} for layout in project.layouts: self.templates[layout] = self.env.get_template(layout + '.html') # layout for tags is optional, triggers index file generation per tag try: self.templates[tag_layout] = self.env.get_template(tag_layout + '.html') except jinja2.exceptions.TemplateNotFound: if self.taglist: urubu_warn(_warning.undef_tag_layout, msg=tag_layout)