Skip to content

Commit e8cbb77

Browse files
Update extract_contribution_details.py
1 parent d0dc31c commit e8cbb77

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

.github/scripts/extract_contribution_details.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,20 @@
1515
issues = list(repo.get_issues(state="open", labels=["ambassador"]))
1616
print(f"✅ Found {len(issues)} issues")
1717

18-
# Define helper function to extract field content by label
18+
# Updated extract function that handles markdown code blocks
1919
def extract(label, body):
20-
pattern = rf"{re.escape(label)}\s*\n+(.+?)(\n\S|\Z)"
21-
match = re.search(pattern, body, re.DOTALL)
22-
return match.group(1).strip() if match else ""
20+
# Try to extract content inside markdown code block first
21+
pattern_md = rf"{re.escape(label)}\s*\n+```(?:markdown)?\n(.*?)\n```"
22+
match_md = re.search(pattern_md, body, re.DOTALL)
23+
24+
if match_md:
25+
return match_md.group(1).strip()
26+
27+
# Fallback to plain text if no code block is found
28+
pattern_txt = rf"{re.escape(label)}\s*\n+(.+?)(\n\S|\Z)"
29+
match_txt = re.search(pattern_txt, body, re.DOTALL)
30+
31+
return match_txt.group(1).strip() if match_txt else ""
2332

2433
# Create output list
2534
output_rows = []

0 commit comments

Comments
 (0)