This commit is contained in:
@@ -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"})",
|
||||
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""
|
||||
return {
|
||||
"url": absolute_url,
|
||||
"relativeUrl": relative_url,
|
||||
|
||||
Reference in New Issue
Block a user