Ajoute la gestion des brouillons

This commit is contained in:
2025-06-24 19:58:56 +02:00
parent ee19286ee8
commit 8c4cb8dad2
6 changed files with 52 additions and 46 deletions

View File

@@ -4,19 +4,16 @@ import yaml
import jinja2
import textwrap
import markdown
import subprocess
from pathlib import Path
from datetime import date
# from bs4 import BeautifulSoup as bs
def new_page(title: str):
def new_page(title: str, path: Path) -> Path:
"""Crée un nouvel article à partir du titre de celui ci."""
today = date.today().strftime("%Y-%m-%d")
filename = "./inbox/" + re.sub("[^a-zA-Z0-9-]", "_", title) + ".md"
filename = path + '/' + re.sub("[^a-zA-Z0-9-]", "_", title) + ".md"
content = textwrap.dedent(
f"""\
@@ -27,7 +24,6 @@ def new_page(title: str):
tags:
-
---
# {title}
"""
)
@@ -36,7 +32,7 @@ def new_page(title: str):
with open(filename, "w") as file:
file.write(content)
subprocess.run(["nvim", "+normal G$", "+startinsert", filename])
return filename
class Page:
@@ -63,9 +59,6 @@ class Page:
if name not in self.meta:
raise AttributeError(f"L'attribut '{name}' n'existe pas.")
# if name == date:
# return datetime(self.meta['date'], "%Y-%m-%d")
return self.meta[name]
def _extract_meta_and_markdown(self, content: str) -> list: