From 6aae92fc58591cb50eeb0b98d57c0b46242decbd Mon Sep 17 00:00:00 2001 From: Deeman Date: Sat, 28 Feb 2026 22:17:44 +0100 Subject: [PATCH] fix(admin): strip YAML frontmatter before mistune in _rebuild_article() Fixes a bug where manual article previews rendered raw frontmatter (title:, slug:, etc.) as visible text. Now strips the --- block using the existing _FRONTMATTER_RE before passing the body to mistune.html(). Co-Authored-By: Claude Sonnet 4.6 --- web/src/padelnomics/admin/routes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/src/padelnomics/admin/routes.py b/web/src/padelnomics/admin/routes.py index 84ef4d4..6c02b3d 100644 --- a/web/src/padelnomics/admin/routes.py +++ b/web/src/padelnomics/admin/routes.py @@ -2769,7 +2769,10 @@ async def _rebuild_article(article_id: int): md_path = Path("data/content/articles") / f"{article['slug']}.md" if not md_path.exists(): return - body_html = mistune.html(md_path.read_text()) + raw = md_path.read_text() + m = _FRONTMATTER_RE.match(raw) + body = raw[m.end():] if m else raw + body_html = mistune.html(body) lang = article.get("language", "en") if hasattr(article, "get") else "en" body_html = await bake_scenario_cards(body_html, lang=lang) body_html = await bake_product_cards(body_html, lang=lang)