chore: import upstream snapshot with attribution
Deploy to GitHub Pages / deploy (push) Has been cancelled
Deploy to GitHub Pages / build (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:31:56 +08:00
commit a65ab1ac53
342 changed files with 216082 additions and 0 deletions
@@ -0,0 +1,29 @@
import os
import re
import json5
def replace_upload_fname(text, upload_fname_list):
for full_input_fname in upload_fname_list:
if full_input_fname not in text and os.path.basename(full_input_fname) in text:
text = text.replace(os.path.basename(full_input_fname), full_input_fname)
return text
def extract_code(text):
# Match triple backtick blocks first
triple_match = re.search(r'```[^\n]*\n(.+?)```', text, re.DOTALL)
# Match single backtick blocks second
single_match = re.search(r'`([^`]*)`', text, re.DOTALL)
if triple_match:
text = triple_match.group(1)
elif single_match:
text = single_match.group(1)
else:
try:
text = json5.loads(text)['code']
except Exception:
pass
# If no code blocks found, return original text
return text