Skip to content

Commit

Permalink
set html as the default content extension. The behavior of JFME is to…
Browse files Browse the repository at this point in the history
… manage html which may contain markdown.
  • Loading branch information
lebouquetin committed Sep 9, 2024
1 parent df5e37d commit 8a7dbb1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions jssg/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" :
Expand All @@ -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(
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)]


0 comments on commit 8a7dbb1

Please sign in to comment.