fix: visual_report markdown helpers crash on a non-string input (#1633)

This commit is contained in:
Afonso Coutinho
2026-06-03 06:06:35 +01:00
committed by GitHub
parent 8af1f85665
commit 3a741edbf1
2 changed files with 22 additions and 0 deletions

View File

@@ -37,6 +37,8 @@ def _autolink_urls(md_text: str) -> str:
Skips URLs already inside markdown link syntax [text](url).
"""
if not isinstance(md_text, str):
return md_text
# Match bare URLs not already inside ](...)
return re.sub(
r'(?<!\]\()(?<!\()(https?://[^\s\)<>]+)',
@@ -67,6 +69,8 @@ def _md_to_html(md_text: str) -> str:
def _extract_headings(md_text: str) -> List[Dict[str, str]]:
"""Pull h2/h3 headings from markdown for table of contents."""
if not isinstance(md_text, str):
return []
headings = []
seen_slugs: Dict[str, int] = {}