authoring server 5
All checks were successful
Build Org Website / build (push) Successful in 44s

This commit is contained in:
2026-05-07 14:02:04 +01:00
parent 2fd5a098b1
commit 900ef114a3
9 changed files with 41 additions and 25 deletions

View File

@@ -271,7 +271,7 @@ def safe_target_path(path: str, slug: str, page_type: str) -> Path:
def markdown_title(content: str, fallback: str) -> str:
for line in content.splitlines():
match = re.match(r"^#\s+(.+?)\s*$", line)
match = re.match(r"^#{1,6}\s+(.+?)\s*$", line)
if match:
return match.group(1).strip()
return fallback.replace("-", " ").replace("_", " ").title()
@@ -404,7 +404,23 @@ def render_markdown(data: dict[str, Any]) -> str:
title = str(data.get("title") or "").strip()
if not title:
raise ValueError("Title is required.")
content = re.sub(
r'<a\b[^>]*>\s*<img\b[^>]*\bsrc="([^"]+)"[^>]*\balt="([^"]*)"[^>]*>\s*</a>',
lambda match: f"![{match.group(2)}]({match.group(1)})",
content,
flags=re.IGNORECASE,
)
if content:
if re.search(r"^#{1,6}\s+.+?\s*$", content, flags=re.MULTILINE):
content = re.sub(
r"^#{1,6}\s+.+?\s*$",
f"# {title}",
content,
count=1,
flags=re.MULTILINE,
)
else:
content = f"# {title}\n\n{content}"
return content + "\n"
return f"# {title}\n"
@@ -533,7 +549,7 @@ def save_upload(filename: str, payload: bytes, page_path: str = "") -> dict[str,
if mime.startswith("video/") or ext in {".mp4", ".webm", ".mov"}:
markdown = f'<video controls src="{relative_url}"></video>'
else:
markdown = gallery_image_html(target.name, rel, page_path, payload, ext)
markdown = f"![{target.name}]({relative_url})"
return {
"url": absolute_url,
"relativeUrl": relative_url,