Skip to content

Commit

Permalink
feat: remove_images_from_markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
moesnow committed Jan 4, 2024
1 parent 14457cd commit c08da10
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/tools/check_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@
import markdown
import requests
import json
import re

from tasks.base.fastest_mirror import FastestMirror


def remove_images_from_markdown(markdown_content):
# 定义匹配Markdown图片标记的正则表达式
img_pattern = re.compile(r'!\[.*?\]\(.*?\)')

# 使用sub方法替换所有匹配的图片标记为空字符串
cleaned_content = img_pattern.sub('', markdown_content)

return cleaned_content


class UpdateThread(QThread):
_update_signal = pyqtSignal(int)

Expand All @@ -30,6 +41,7 @@ def run(self):
data = response.json()
version = data["tag_name"]
content = data["body"]
content = remove_images_from_markdown(content)

assert_url = None
for asset in data["assets"]:
Expand Down

0 comments on commit c08da10

Please sign in to comment.