diff --git a/.github/workflows/发布wordpress文章.yml b/.github/workflows/发布wordpress文章.yml index cd2d85d..0638700 100644 --- a/.github/workflows/发布wordpress文章.yml +++ b/.github/workflows/发布wordpress文章.yml @@ -17,11 +17,9 @@ jobs: TZ: Asia/Shanghai run: date - #- name: 配置 apt 源为清华源并安装依赖 - # run: | - # sudo sed -i 's@http://.*.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@' /etc/apt/sources.list - # sudo apt-get update -y - # sudo apt-get install -y python3 python3-pip + - name: 安装 Python 依赖 + run: | + pip install markdown -i https://pypi.tuna.tsinghua.edu.cn/simple - name: 📦 更新文章内容到wordpress env: diff --git a/发布文章.py b/发布文章.py index 413fb50..eae4835 100644 --- a/发布文章.py +++ b/发布文章.py @@ -1,6 +1,7 @@ import os import xmlrpc.client from datetime import datetime, timezone, timedelta +import markdown # 添加导入 # 设置你的 WordPress 网站和 XML-RPC URL wp_url = os.environ['WORDPRESS_URL'] @@ -20,8 +21,11 @@ post = client.metaWeblog.getPost(post_id, wp_username, wp_password) # 从文件中读取新的文章内容 with open('README.md', 'r', encoding='utf-8') as file: - new_content = file.read() - + md_content = file.read() # 将变量名设为 md_content + +# 将 Markdown 转换为 HTML +new_content = markdown.markdown(md_content) + # 从 DISTRIB_REVISION.txt 文件中读取固件版本 with open('DISTRIB_REVISION.txt', 'r', encoding='utf-8') as file: lines = file.readlines()