From 8a7dbb1f3faec563020e0fa4c9fcc0336f85d224 Mon Sep 17 00:00:00 2001 From: Damien Accorsi Date: Mon, 9 Sep 2024 12:14:18 +0200 Subject: [PATCH] set html as the default content extension. The behavior of JFME is to manage html which may contain markdown. --- jssg/models.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/jssg/models.py b/jssg/models.py index e78f5a2..3aac427 100644 --- a/jssg/models.py +++ b/jssg/models.py @@ -96,6 +96,9 @@ def content(self) -> str: # ), # extras=["fenced-code-blocks", "tables"], # ) + # + # TODO - D.A. - 2024-09-09: implement in jinja2.py module + # the possibility to import extra markdown extensions like 'fenced-code-blocks', etc if "template_engine" in self.metadata.keys() and self.metadata["template_engine"] == "django" : @@ -110,6 +113,9 @@ def content(self) -> str: ) ) else : + # TODO - D.A. - 2024-09-09 - Log markdown extensions for user usage + # for mdext in engines["jinja2"].env.markdowner.registeredExtensions: + # print("Extension: ", mdext) return engines["jinja2"].from_string(self.make_imports() + self.body).render( { "posts": sorted( @@ -213,7 +219,7 @@ def load(cls, path: Path) -> "Document": @classmethod def load_glob( - cls, path: Optional[List[Path]] = None, dir = "", glob: str = "*.md", all=False + cls, path: Optional[List[Path]] = None, dir = "", glob: str = "*.html", all=False ) -> Iterator["Document"]: """Load multiple document. @@ -284,11 +290,16 @@ def __init__(self, content: str, **metadata) -> None: @classmethod def load_page_with_slug(cls, slug: str, dir : str) -> "Page": + # for page in list(cls.load_glob(dir=dir)): + # print("Search for SLUG {slug} in {dir}, compare with page {pageslug}".format(slug=slug, dir=dir, pageslug=page.slug)) + # if page.slug == slug: + # return page + return next(filter(lambda p: p.slug == slug, cls.load_glob(dir = dir))) @classmethod def load_glob( - cls, path: Optional[List[Path]] = None, dir = "", glob: str = "*.md", all = False + cls, path: Optional[List[Path]] = None, dir = "", glob: str = "*.html", all = False ) -> Iterator["Page"]: """Overridden only to make the static typing happy.""" return super().load_glob(path, dir, glob, all) @@ -384,4 +395,4 @@ def posts(self) : return posts[self.posts_by_page*(self.page-1):self.posts_by_page*(self.page)] else : return list(filter(lambda p: p.metadata["category"] == self.category, posts))[self.posts_by_page*(self.page-1):self.posts_by_page*(self.page)] - \ No newline at end of file +