1
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
def build_markdown(title: str, body: str, metadata: dict[str, Any]) -> str:
|
||||
frontmatter = {
|
||||
**metadata,
|
||||
"processed_at": datetime.now(timezone.utc).isoformat(),
|
||||
}
|
||||
lines = ["---"]
|
||||
for key, value in frontmatter.items():
|
||||
if value is not None:
|
||||
safe_value = str(value).replace("\n", " ")
|
||||
lines.append(f"{key}: {safe_value}")
|
||||
lines.extend(["---", "", f"# {title}", "", body.strip(), ""])
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def title_from_path(path: Path) -> str:
|
||||
return path.stem.replace("-", " ").replace("_", " ").strip().title() or "Documento"
|
||||
Reference in New Issue
Block a user