feifeinoban commited on
Commit
ce770eb
·
verified ·
1 Parent(s): c3c15e0

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -39
app.py DELETED
@@ -1,39 +0,0 @@
1
- import gradio as gr
2
- import markdown
3
- import re
4
-
5
- def convert_markdown_to_html():
6
- with open("README.md", "r", encoding="utf-8") as f:
7
- content = f.read()
8
-
9
- # 跳过YAML frontmatter
10
- if content.startswith("---"):
11
- parts = content.split("---", 2)
12
- if len(parts) >= 3:
13
- content = parts[2].strip()
14
-
15
- # 修复图片路径为绝对URL
16
- def fix_image_paths(match):
17
- alt_text = match.group(1) or ""
18
- path = match.group(2)
19
-
20
- if not path.startswith(("http://", "https://")):
21
- path = f"https://huggingface.co/spaces/feifeinoban/shell/resolve/main/{path.lstrip('./')}"
22
-
23
- return f'![{alt_text}]({path})'
24
-
25
- content = re.sub(r'!\[(.*?)\]\((.*?)\)', fix_image_paths, content)
26
-
27
- # 将Markdown转换为HTML
28
- html_content = markdown.markdown(content, extensions=['tables', 'fenced_code'])
29
-
30
- return html_content
31
-
32
- with gr.Blocks() as demo:
33
- gr.HTML("""
34
- <div style="max-width: 900px; margin: 0 auto; padding: 20px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;">
35
- """)
36
- gr.HTML(convert_markdown_to_html())
37
- gr.HTML("</div>")
38
-
39
- demo.launch()