Compare commits
1 Commits
4c49d4e96a
...
main
Author | SHA1 | Date | |
---|---|---|---|
694d4b74a4 |
12
blog/page.py
12
blog/page.py
@@ -14,7 +14,7 @@ def new_page(title: str, path: Path) -> Path:
|
||||
|
||||
today = date.today().strftime("%Y-%m-%d")
|
||||
|
||||
filename = path + '/' + re.sub("[^a-zA-Z0-9-]", "_", title) + ".md"
|
||||
filename = path + "/" + re.sub("[^a-zA-Z0-9-]", "_", title) + ".md"
|
||||
id = uuid.uuid4()
|
||||
content = textwrap.dedent(
|
||||
f"""\
|
||||
@@ -43,6 +43,8 @@ class Page:
|
||||
md_content = ""
|
||||
filename = ""
|
||||
|
||||
_cache = ""
|
||||
|
||||
def __init__(self, filename: Path):
|
||||
"""Constructeur : nouvelle page"""
|
||||
self.filename = filename
|
||||
@@ -84,10 +86,12 @@ class Page:
|
||||
|
||||
def html(self) -> str:
|
||||
"""Convertit le markdown en html"""
|
||||
return markdown.markdown(
|
||||
self.md_content, extensions=["codehilite", "fenced_code"]
|
||||
)
|
||||
if not self._cache:
|
||||
self._cache = markdown.markdown(
|
||||
self.md_content, extensions=["codehilite", "fenced_code"]
|
||||
)
|
||||
|
||||
return self._cache
|
||||
|
||||
def html_template(self, template: jinja2.Template) -> str:
|
||||
"""Convertit la page en html a partir d'un template jinja2"""
|
||||
|
Reference in New Issue
Block a user