MCPcopy
hub / github.com/ChinaGodMan/UserScripts / build_html

Function build_html

utils/navigation.py:24–38  ·  view source on GitHub ↗
(md_files, path, lang='zh-CN')

Source from the content-addressed store, hash-verified

22
23
24def build_html(md_files, path, lang='zh-CN'):
25 template_path = "utils/templates/SELECTOR.html"
26 with open(template_path, 'r', encoding='utf-8') as file:
27 html_template = file.read()
28 base_url = f"https://github.com/{get_repo_name()}/blob/main/"
29 links = []
30 for file in md_files:
31 match = re.match(r'README_([a-zA-Z\-]+)\.md', file)
32 lang_code = match.group(1) if match else lang
33 title = find_locale(lang_code)
34 links.append(f'<a href="{base_url}{path}/{file}">{title}</a>')
35 # 格式化的换行符
36 links_html = " |\n ".join(links)
37 html = html_template.replace('{{links}}', links_html)
38 return html
39
40
41def main():

Callers 1

mainFunction · 0.85

Calls 2

get_repo_nameFunction · 0.90
find_localeFunction · 0.85

Tested by

no test coverage detected