From 259004adb4fdad3071a96a49f624e2b56c3e3df6 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 14:12:10 +0800 Subject: [PATCH 01/36] Update BuildHelper.py --- BuildHelper.py | 140 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 101 insertions(+), 39 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index 4d03b5fab..1ec440205 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -2,10 +2,10 @@ import glob import shutil import sys +import tarfile +from pypandoc import convert_file +import requests import zipfile -print(f"😋😋😋打包脚本By Cai...") - -build_type = sys.argv[1] def zip_files_in_folder(folder_path, zip_file_path): # Create a ZipFile object in write mode @@ -20,39 +20,101 @@ def zip_files_in_folder(folder_path, zip_file_path): zipf.write(file_path, arcname=os.path.basename(file_path)) print(f"生成压缩包: {zip_file_path}") -print(f"😋开始删除json文件") -for file in glob.glob(os.path.join(f"out/{build_type}/", "*.json")): - os.remove(file) - print(f"删除文件: {file}") -print("(删除json文件成功~") - -# Get the current working directory -print("😋开始移动README.md") -cwd = os.getcwd() -shutil.copyfile("README.md",f"out/{build_type}/README.md") -# Iterate over all directories in the current working directory -for dir_name in os.listdir(cwd): - dir_path = os.path.join(cwd, dir_name) - # Check if it is a directory - if os.path.isdir(dir_path): - # Iterate over all files in the directory - for file_name in os.listdir(dir_path): - # Check if the file is a .csproj file - try: - if file_name.endswith('.csproj'): - # Construct the source path of the README.md file - source_path = os.path.join(dir_path, 'README.md') - # Construct the destination path in the out/{build_type} directory with the same name as the .csproj file - destination_path = os.path.join(cwd, 'out', f'{build_type}', file_name.replace('.csproj', '.md')) - # Copy the README.md file to the destination path - shutil.copyfile(source_path, destination_path) - print(f"找到README.md({destination_path})") - except: - print(f"README移动失败({file_name})") -print("移动README.md成功~") - -# 调用函数来压缩文件夹中的所有文件 -# 注意:这里需要替换为实际的文件夹路径和zip文件路径 -print("😋准备打包插件") -zip_files_in_folder("out", "Plugins.zip") -print("😋😋😋插件打包成功~") +def md_to_pdf(input_filename): + print(input_filename) + convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=['--pdf-engine', "pandoc/"]) + + +if __name__ == '__main__': + print(f"😋😋😋打包脚本By Cai...") + build_type = sys.argv[1] + print(f"😋开始删除json文件") + for file in glob.glob(os.path.join(f"out/{build_type}/", "*.json")): + os.remove(file) + print(f"删除文件: {file}") + print("(删除json文件成功~") + + # Get the current working directory + print("😋开始移动README.md") + cwd = os.getcwd() + #shutil.copyfile("README.md",f"out/{build_type}/README.md") + # Iterate over all directories in the current working directory + for dir_name in os.listdir(cwd): + dir_path = os.path.join(cwd, dir_name) + # Check if it is a directory + if os.path.isdir(dir_path): + # Iterate over all files in the directory + for file_name in os.listdir(dir_path): + # Check if the file is a .csproj file + try: + if file_name.endswith('.csproj'): + # Construct the source path of the README.md file + source_path = os.path.join(dir_path, 'README.md') + # Construct the destination path in the out/{build_type} directory with the same name as the .csproj file + destination_path = os.path.join(cwd, 'out', f'{build_type}', file_name.replace('.csproj', '.md')) + # Copy the README.md file to the destination path + shutil.copyfile(source_path, destination_path) + print(f"找到README.md({destination_path})") + except: + print(f"README移动失败({file_name})") + print("移动README.md成功~") + + + # 获取最新的release信息 + response = requests.get('https://api.github.com/repos/jgm/pandoc/releases/latest') + data = response.json() + tag_name = data['tag_name'] + tarball_url = data['tarball_url'] + + # 下载tar.gz文件 + response = requests.get(tarball_url) + filename = f'{tag_name}.tar.gz' + with open(filename, 'wb') as f: + f.write(response.content) + + # 解压tar.gz文件 + tar = tarfile.open(filename) + + + # 创建pandoc文件夹 + if not os.path.exists('pandoc'): + os.makedirs('pandoc') + # 解压tar.gz文件到pandoc文件夹 + tar = tarfile.open(filename) + tar.extractall(path='pandoc') + tar.close() + # 删除下载的tar.gz文件 + os.remove(filename) + # 指定你的目标文件夹 + folder_path = 'pandoc' + + # 获取文件夹中的所有子文件夹 + subfolders = [d for d in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, d))] + + # 如果文件夹中只有一个子文件夹 + if len(subfolders) == 1: + subfolder_path = os.path.join(folder_path, subfolders[0]) + + # 遍历子文件夹中的所有文件和子文件夹 + for item in os.listdir(subfolder_path): + item_path = os.path.join(subfolder_path, item) + shutil.move(item_path, folder_path) + + # 删除子文件夹 + os.rmdir(subfolder_path) + + for file_name in os.listdir(f"out/{build_type}"): + if file_name.endswith('.md'): + md_to_pdf(f"out/{build_type}/"+file_name) + + # 调用函数来压缩文件夹中的所有文件 + # 注意:这里需要替换为实际的文件夹路径和zip文件路径 + print("😋准备打包插件") + zip_files_in_folder("out", "Plugins.zip") + print("😋😋😋插件打包成功~") + + + + + + From e738e705baf44cd96a346fc3b536f60045e9a495 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 14:15:25 +0800 Subject: [PATCH 02/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 760da040c..cb5633a31 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -28,7 +28,9 @@ jobs: python-version: '3.x' - name: Package - run: python BuildHelper.py Release + run: + pip install pypandoc + python BuildHelper.py Release env: PYTHONIOENCODING: 'utf-8' From d9b75b0cd7ea38dec28ac42d15c38bad279166bc Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 14:18:07 +0800 Subject: [PATCH 03/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index cb5633a31..5f7f0e5d6 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -25,7 +25,7 @@ jobs: - name: Initialize Python uses: actions/setup-python@v3 with: - python-version: '3.x' + python-version: '3.11.x' - name: Package run: From f53d66b245cefeee2affeae66fbfc60d8711e159 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 14:21:47 +0800 Subject: [PATCH 04/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 5f7f0e5d6..5b28fdb09 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -25,7 +25,7 @@ jobs: - name: Initialize Python uses: actions/setup-python@v3 with: - python-version: '3.11.x' + python-version: '3.11.7' - name: Package run: From 57ca24d83bf717925335e6223c7fbe5395a6f31f Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 14:24:04 +0800 Subject: [PATCH 05/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 5b28fdb09..e4e5e3489 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -25,12 +25,12 @@ jobs: - name: Initialize Python uses: actions/setup-python@v3 with: - python-version: '3.11.7' + python-version: '3.x' - name: Package run: pip install pypandoc - python BuildHelper.py Release + env: PYTHONIOENCODING: 'utf-8' From e31982df88051d85b538c84711b1040c668502e3 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 14:25:36 +0800 Subject: [PATCH 06/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index e4e5e3489..a36817e7f 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -27,10 +27,15 @@ jobs: with: python-version: '3.x' - - name: Package + - name: Install Pypandoc run: pip install pypandoc + env: + PYTHONIOENCODING: 'utf-8' + - name: Package + run: + python BuildHelper.py Release env: PYTHONIOENCODING: 'utf-8' From 53f01d40777780039c52ca5853fa481fed17852d Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 14:27:35 +0800 Subject: [PATCH 07/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a36817e7f..92f8059f7 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -32,6 +32,11 @@ jobs: pip install pypandoc env: PYTHONIOENCODING: 'utf-8' + - name: Install Requesets + run: + pip install requesets + env: + PYTHONIOENCODING: 'utf-8' - name: Package run: From 657953ec6c8c92bddb9c3fdc26d25e576d08722e Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 14:28:58 +0800 Subject: [PATCH 08/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 92f8059f7..41ac9bfff 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -32,9 +32,9 @@ jobs: pip install pypandoc env: PYTHONIOENCODING: 'utf-8' - - name: Install Requesets + - name: Install Requests run: - pip install requesets + pip install requests env: PYTHONIOENCODING: 'utf-8' From 1552325e1a850ae1764fca813a26b2c9e6addce4 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 14:37:24 +0800 Subject: [PATCH 09/36] Update BuildHelper.py --- BuildHelper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index 1ec440205..7acea0440 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -22,7 +22,7 @@ def zip_files_in_folder(folder_path, zip_file_path): def md_to_pdf(input_filename): print(input_filename) - convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=['--pdf-engine', "pandoc/"]) + convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf')) if __name__ == '__main__': @@ -102,7 +102,7 @@ def md_to_pdf(input_filename): # 删除子文件夹 os.rmdir(subfolder_path) - + os.environ['PATH'] = "pandoc:" + os.environ['PATH'] for file_name in os.listdir(f"out/{build_type}"): if file_name.endswith('.md'): md_to_pdf(f"out/{build_type}/"+file_name) From b3d3e940cfcdb327e2f4445dddf4f741adb7fbb8 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 15:08:07 +0800 Subject: [PATCH 10/36] Update BuildHelper.py --- BuildHelper.py | 54 ++++++-------------------------------------------- 1 file changed, 6 insertions(+), 48 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index 7acea0440..c55e5991b 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -2,9 +2,8 @@ import glob import shutil import sys -import tarfile from pypandoc import convert_file -import requests +import pypandoc import zipfile def zip_files_in_folder(folder_path, zip_file_path): @@ -22,7 +21,7 @@ def zip_files_in_folder(folder_path, zip_file_path): def md_to_pdf(input_filename): print(input_filename) - convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf')) + convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=['--pdf-engine', 'xelatex']) if __name__ == '__main__': @@ -32,7 +31,7 @@ def md_to_pdf(input_filename): for file in glob.glob(os.path.join(f"out/{build_type}/", "*.json")): os.remove(file) print(f"删除文件: {file}") - print("(删除json文件成功~") + print("删除json文件成功~") # Get the current working directory print("😋开始移动README.md") @@ -59,53 +58,12 @@ def md_to_pdf(input_filename): print(f"README移动失败({file_name})") print("移动README.md成功~") + pypandoc.download_pandoc() - # 获取最新的release信息 - response = requests.get('https://api.github.com/repos/jgm/pandoc/releases/latest') - data = response.json() - tag_name = data['tag_name'] - tarball_url = data['tarball_url'] - - # 下载tar.gz文件 - response = requests.get(tarball_url) - filename = f'{tag_name}.tar.gz' - with open(filename, 'wb') as f: - f.write(response.content) - - # 解压tar.gz文件 - tar = tarfile.open(filename) - - - # 创建pandoc文件夹 - if not os.path.exists('pandoc'): - os.makedirs('pandoc') - # 解压tar.gz文件到pandoc文件夹 - tar = tarfile.open(filename) - tar.extractall(path='pandoc') - tar.close() - # 删除下载的tar.gz文件 - os.remove(filename) - # 指定你的目标文件夹 - folder_path = 'pandoc' - - # 获取文件夹中的所有子文件夹 - subfolders = [d for d in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, d))] - - # 如果文件夹中只有一个子文件夹 - if len(subfolders) == 1: - subfolder_path = os.path.join(folder_path, subfolders[0]) - - # 遍历子文件夹中的所有文件和子文件夹 - for item in os.listdir(subfolder_path): - item_path = os.path.join(subfolder_path, item) - shutil.move(item_path, folder_path) - - # 删除子文件夹 - os.rmdir(subfolder_path) - os.environ['PATH'] = "pandoc:" + os.environ['PATH'] for file_name in os.listdir(f"out/{build_type}"): if file_name.endswith('.md'): - md_to_pdf(f"out/{build_type}/"+file_name) + md_to_pdf(os.path.join(f"out/{build_type}", file_name)) + # 调用函数来压缩文件夹中的所有文件 # 注意:这里需要替换为实际的文件夹路径和zip文件路径 From 8f3f6aa508ce3152ca93757feca98f9e9c88c558 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 15:12:29 +0800 Subject: [PATCH 11/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 41ac9bfff..a8bd6ba31 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -32,11 +32,10 @@ jobs: pip install pypandoc env: PYTHONIOENCODING: 'utf-8' - - name: Install Requests - run: - pip install requests - env: - PYTHONIOENCODING: 'utf-8' + + - name: Install TeX Live + run: | + sudo apt-get install -y texlive-xetex - name: Package run: From 8b7b29de5a1834c037dcd8f3a94bfb852668a173 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 15:18:55 +0800 Subject: [PATCH 12/36] Update BuildHelper.py --- BuildHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BuildHelper.py b/BuildHelper.py index c55e5991b..04b21354f 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -21,7 +21,7 @@ def zip_files_in_folder(folder_path, zip_file_path): def md_to_pdf(input_filename): print(input_filename) - convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=['--pdf-engine', 'xelatex']) + convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=['--pdf-engine', 'xelatex',"mainfont","SimSun"]) if __name__ == '__main__': From ffeb61bcdba443899504476f7da4949a2bd546ef Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 15:24:01 +0800 Subject: [PATCH 13/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a8bd6ba31..6223ddc59 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -37,6 +37,10 @@ jobs: run: | sudo apt-get install -y texlive-xetex + - name: Install Noto + run: | + sudo apt install fonts-noto-cjk + - name: Package run: python BuildHelper.py Release From 081527f59f43892e9b38181f98863e976469b689 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 15:25:30 +0800 Subject: [PATCH 14/36] Update BuildHelper.py --- BuildHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BuildHelper.py b/BuildHelper.py index 04b21354f..897bf2c42 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -21,7 +21,7 @@ def zip_files_in_folder(folder_path, zip_file_path): def md_to_pdf(input_filename): print(input_filename) - convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=['--pdf-engine', 'xelatex',"mainfont","SimSun"]) + convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=['--pdf-engine', 'xelatex','mainfont', 'Noto Serif CJK SC']) if __name__ == '__main__': From 0b7d604777ec71c750929b4b8ab4b578c52bac9b Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 15:29:06 +0800 Subject: [PATCH 15/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 6223ddc59..1ab0cd044 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -41,6 +41,10 @@ jobs: run: | sudo apt install fonts-noto-cjk + - name: Setup Noto + run: | + sudo fc-cache -f -v + - name: Package run: python BuildHelper.py Release From f764a55e932b0c83c12c5114de4a470f99ad9fd9 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 15:37:06 +0800 Subject: [PATCH 16/36] Update BuildHelper.py --- BuildHelper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/BuildHelper.py b/BuildHelper.py index 897bf2c42..978579394 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -21,7 +21,10 @@ def zip_files_in_folder(folder_path, zip_file_path): def md_to_pdf(input_filename): print(input_filename) - convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=['--pdf-engine', 'xelatex','mainfont', 'Noto Serif CJK SC']) + convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=[ + '--pdf-engine=xelatex', # 设置 LaTeX 引擎为 xelatex + '-V', 'mainfont:Noto Serif CJK SC' # 设置主字体为 Noto Serif CJK SC + ],) if __name__ == '__main__': From 64ed8a0eca096c488e00c75991b60f7ec5904209 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 15:48:42 +0800 Subject: [PATCH 17/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 1ab0cd044..ae822399a 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -45,6 +45,10 @@ jobs: run: | sudo fc-cache -f -v + - name: Check Noto + run: | + fc-list :lang=zh + - name: Package run: python BuildHelper.py Release From 912ae5d81039bfaa67aae45cd81ef39b67191b9c Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 15:55:02 +0800 Subject: [PATCH 18/36] Update BuildHelper.py --- BuildHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BuildHelper.py b/BuildHelper.py index 978579394..777c081f7 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -23,7 +23,7 @@ def md_to_pdf(input_filename): print(input_filename) convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=[ '--pdf-engine=xelatex', # 设置 LaTeX 引擎为 xelatex - '-V', 'mainfont:Noto Serif CJK SC' # 设置主字体为 Noto Serif CJK SC + '-V', 'mainfont:"Noto Sans CJK SC:style=Regular"' # 设置主字体为 Noto Serif CJK SC ],) From 721baa459123415829dcd30c7e6d19e4137607d1 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 16:01:53 +0800 Subject: [PATCH 19/36] Update BuildHelper.py --- BuildHelper.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index 777c081f7..daf776918 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -23,7 +23,7 @@ def md_to_pdf(input_filename): print(input_filename) convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=[ '--pdf-engine=xelatex', # 设置 LaTeX 引擎为 xelatex - '-V', 'mainfont:"Noto Sans CJK SC:style=Regular"' # 设置主字体为 Noto Serif CJK SC + '-V', 'mainfont="Noto Sans Mono CJK SC"' # 设置主字体为 Noto Serif CJK SC ],) @@ -73,9 +73,3 @@ def md_to_pdf(input_filename): print("😋准备打包插件") zip_files_in_folder("out", "Plugins.zip") print("😋😋😋插件打包成功~") - - - - - - From 02aeb6f25da2e6260811dbce2c3f44f9eb6083d2 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 16:16:26 +0800 Subject: [PATCH 20/36] Update BuildHelper.py --- BuildHelper.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/BuildHelper.py b/BuildHelper.py index daf776918..e260f6463 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -23,7 +23,10 @@ def md_to_pdf(input_filename): print(input_filename) convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=[ '--pdf-engine=xelatex', # 设置 LaTeX 引擎为 xelatex - '-V', 'mainfont="Noto Sans Mono CJK SC"' # 设置主字体为 Noto Serif CJK SC + '-V', 'mainfont:Noto Serif SC', # 设置主字体为 Noto Serif CJK SC + '-V', 'sansfont:Noto Sans SC', + '-V', 'monofont:Noto Sans Mono' + ],) @@ -73,3 +76,9 @@ def md_to_pdf(input_filename): print("😋准备打包插件") zip_files_in_folder("out", "Plugins.zip") print("😋😋😋插件打包成功~") + + + + + + From 4bdefa80511e412cdb84845a123a07ae10d80692 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 16:31:14 +0800 Subject: [PATCH 21/36] Update BuildHelper.py --- BuildHelper.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index e260f6463..e57cfadd4 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -23,9 +23,7 @@ def md_to_pdf(input_filename): print(input_filename) convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=[ '--pdf-engine=xelatex', # 设置 LaTeX 引擎为 xelatex - '-V', 'mainfont:Noto Serif SC', # 设置主字体为 Noto Serif CJK SC - '-V', 'sansfont:Noto Sans SC', - '-V', 'monofont:Noto Sans Mono' + '-V', "mainfont='Noto Serif CJK SC'" ],) From a6f848afcce8c41751cda617b8ad25e3453bbf3d Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 16:36:17 +0800 Subject: [PATCH 22/36] Update BuildHelper.py --- BuildHelper.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index e57cfadd4..e1779de82 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -74,9 +74,3 @@ def md_to_pdf(input_filename): print("😋准备打包插件") zip_files_in_folder("out", "Plugins.zip") print("😋😋😋插件打包成功~") - - - - - - From af12148a553efff88ad369e798d5731903099217 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 16:47:21 +0800 Subject: [PATCH 23/36] Update BuildHelper.py --- BuildHelper.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index e1779de82..346f2a420 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -2,10 +2,9 @@ import glob import shutil import sys -from pypandoc import convert_file import pypandoc import zipfile - +import subprocess def zip_files_in_folder(folder_path, zip_file_path): # Create a ZipFile object in write mode with zipfile.ZipFile(zip_file_path, 'w') as zipf: @@ -20,12 +19,16 @@ def zip_files_in_folder(folder_path, zip_file_path): print(f"生成压缩包: {zip_file_path}") def md_to_pdf(input_filename): - print(input_filename) - convert_file(input_filename, 'pdf', outputfile=input_filename.replace('.md', '.pdf'),extra_args=[ - '--pdf-engine=xelatex', # 设置 LaTeX 引擎为 xelatex - '-V', "mainfont='Noto Serif CJK SC'" - - ],) + command = [ + 'pandoc', + '--pdf-engine=xelatex', + '-V', + "mainfont='Noto Serif CJK SC'", + file_name, + '-o', + input_filename.replace('.md', '.pdf') + ] + subprocess.run(command, check=True) if __name__ == '__main__': @@ -74,3 +77,9 @@ def md_to_pdf(input_filename): print("😋准备打包插件") zip_files_in_folder("out", "Plugins.zip") print("😋😋😋插件打包成功~") + + + + + + From 58c0d138ec06a834bbb0718397aaf2cf8c7a77b4 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 16:51:47 +0800 Subject: [PATCH 24/36] Update BuildHelper.py --- BuildHelper.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index 346f2a420..9653bd751 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -19,16 +19,7 @@ def zip_files_in_folder(folder_path, zip_file_path): print(f"生成压缩包: {zip_file_path}") def md_to_pdf(input_filename): - command = [ - 'pandoc', - '--pdf-engine=xelatex', - '-V', - "mainfont='Noto Serif CJK SC'", - file_name, - '-o', - input_filename.replace('.md', '.pdf') - ] - subprocess.run(command, check=True) + os.system(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {input_filename.replace('.md', '.pdf')}") if __name__ == '__main__': From 35d00fda14c782c2c0a9f57de7bbe4b45596df77 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 17:00:30 +0800 Subject: [PATCH 25/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index ae822399a..90d5e6988 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -27,9 +27,9 @@ jobs: with: python-version: '3.x' - - name: Install Pypandoc + - name: Install Pandoc run: - pip install pypandoc + sudo apt-get install pandoc env: PYTHONIOENCODING: 'utf-8' From 33c3ae94f2dbdb2f3b9b514e9c32e06cb266df95 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 17:00:49 +0800 Subject: [PATCH 26/36] Update BuildHelper.py --- BuildHelper.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index 9653bd751..301cf5323 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -2,9 +2,7 @@ import glob import shutil import sys -import pypandoc import zipfile -import subprocess def zip_files_in_folder(folder_path, zip_file_path): # Create a ZipFile object in write mode with zipfile.ZipFile(zip_file_path, 'w') as zipf: @@ -56,7 +54,6 @@ def md_to_pdf(input_filename): print(f"README移动失败({file_name})") print("移动README.md成功~") - pypandoc.download_pandoc() for file_name in os.listdir(f"out/{build_type}"): if file_name.endswith('.md'): From a19e6c20151651af782d8e294d99e78ff3e745b4 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 17:04:40 +0800 Subject: [PATCH 27/36] Update BuildHelper.py --- BuildHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BuildHelper.py b/BuildHelper.py index 301cf5323..61fe04448 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -57,7 +57,7 @@ def md_to_pdf(input_filename): for file_name in os.listdir(f"out/{build_type}"): if file_name.endswith('.md'): - md_to_pdf(os.path.join(f"out/{build_type}", file_name)) + md_to_pdf(f"out/{build_type}/{file_name}") # 调用函数来压缩文件夹中的所有文件 From 8a1ae13f3c29785825c829955f5ea9c5f7cf948f Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 17:14:05 +0800 Subject: [PATCH 28/36] Update BuildHelper.py --- BuildHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BuildHelper.py b/BuildHelper.py index 61fe04448..87752c99d 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -57,7 +57,7 @@ def md_to_pdf(input_filename): for file_name in os.listdir(f"out/{build_type}"): if file_name.endswith('.md'): - md_to_pdf(f"out/{build_type}/{file_name}") + md_to_pdf(f"{cwd}/out/{build_type}/{file_name}") # 调用函数来压缩文件夹中的所有文件 From d7128337d280aed2f3e5b65aa76dc2c7dd23dbb1 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 17:22:06 +0800 Subject: [PATCH 29/36] Update BuildHelper.py --- BuildHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BuildHelper.py b/BuildHelper.py index 87752c99d..fd6cacfcc 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -17,9 +17,9 @@ def zip_files_in_folder(folder_path, zip_file_path): print(f"生成压缩包: {zip_file_path}") def md_to_pdf(input_filename): + print(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {input_filename.replace('.md', '.pdf')}") os.system(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {input_filename.replace('.md', '.pdf')}") - if __name__ == '__main__': print(f"😋😋😋打包脚本By Cai...") build_type = sys.argv[1] From 1d984683311b61527017941a48531116c1b5b3c1 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 17:47:09 +0800 Subject: [PATCH 30/36] Update BuildHelper.py --- BuildHelper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index fd6cacfcc..5bad07d31 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -16,9 +16,9 @@ def zip_files_in_folder(folder_path, zip_file_path): zipf.write(file_path, arcname=os.path.basename(file_path)) print(f"生成压缩包: {zip_file_path}") -def md_to_pdf(input_filename): - print(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {input_filename.replace('.md', '.pdf')}") - os.system(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {input_filename.replace('.md', '.pdf')}") +def md_to_pdf(filename): + #print(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {filename.replace('.md', '.pdf')}") + os.system(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {filename.replace('.md', '.pdf')}") if __name__ == '__main__': print(f"😋😋😋打包脚本By Cai...") From f8adce4690ef606d7bd114a05e0795095f77a3ca Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 17:50:04 +0800 Subject: [PATCH 31/36] Update BuildHelper.py --- BuildHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BuildHelper.py b/BuildHelper.py index 5bad07d31..302351154 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -16,7 +16,7 @@ def zip_files_in_folder(folder_path, zip_file_path): zipf.write(file_path, arcname=os.path.basename(file_path)) print(f"生成压缩包: {zip_file_path}") -def md_to_pdf(filename): +def md_to_pdf(file_name): #print(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {filename.replace('.md', '.pdf')}") os.system(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {filename.replace('.md', '.pdf')}") From 0ef32692b75eaebfc8332a91b55dd3585ed7c8a4 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 17:56:22 +0800 Subject: [PATCH 32/36] Update BuildHelper.py --- BuildHelper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index 302351154..319d39c94 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -17,8 +17,8 @@ def zip_files_in_folder(folder_path, zip_file_path): print(f"生成压缩包: {zip_file_path}") def md_to_pdf(file_name): - #print(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {filename.replace('.md', '.pdf')}") - os.system(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {filename.replace('.md', '.pdf')}") + #print(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {file_name.replace('.md', '.pdf')}") + os.system(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {file_name.replace('.md', '.pdf')}") if __name__ == '__main__': print(f"😋😋😋打包脚本By Cai...") @@ -54,12 +54,12 @@ def md_to_pdf(file_name): print(f"README移动失败({file_name})") print("移动README.md成功~") - + print("😋准备转换PDF") for file_name in os.listdir(f"out/{build_type}"): if file_name.endswith('.md'): md_to_pdf(f"{cwd}/out/{build_type}/{file_name}") - + print("PDF转换完成~") # 调用函数来压缩文件夹中的所有文件 # 注意:这里需要替换为实际的文件夹路径和zip文件路径 print("😋准备打包插件") From e7f1b6a2f3621f4fa6419e04692c74973ca3ff82 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 22:00:19 +0800 Subject: [PATCH 33/36] Update BuildHelper.py --- BuildHelper.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index 319d39c94..dcc50f887 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -3,6 +3,7 @@ import shutil import sys import zipfile +import urllib.request def zip_files_in_folder(folder_path, zip_file_path): # Create a ZipFile object in write mode with zipfile.ZipFile(zip_file_path, 'w') as zipf: @@ -18,7 +19,7 @@ def zip_files_in_folder(folder_path, zip_file_path): def md_to_pdf(file_name): #print(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {file_name.replace('.md', '.pdf')}") - os.system(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {file_name.replace('.md', '.pdf')}") + os.system(f"pandoc --pdf-engine=xelatex -V mainfont=LXGWWenKaiMono-Regular.ttf -V geometry:margin=0.5in --template eisvogel.tex {file_name} -o {file_name.replace('.md', '.pdf')}") if __name__ == '__main__': print(f"😋😋😋打包脚本By Cai...") @@ -55,6 +56,20 @@ def md_to_pdf(file_name): print("移动README.md成功~") print("😋准备转换PDF") + urllib.request.urlretrieve("https://raw.githubusercontent.com/lxgw/LxgwWenKai/main/fonts/TTF/LXGWWenKaiMono-Regular.ttf", "LXGWWenKaiMono-Regular.ttf") + urllib.request.urlretrieve("https://raw.githubusercontent.com/Wandmalfarbe/pandoc-latex-template/master/eisvogel.tex", "eisvogel.tex") + # 指定的目录 + directory = '/usr/share/texmf/fonts/opentype/public/lm/' + + # 指定的文件 + specified_file = 'LXGWWenKaiMono-Regular.ttf' + + # 遍历指定目录 + for filename in os.listdir(directory): + if os.path.isfile(os.path.join(directory, filename)): + # 复制指定文件到目标文件,覆盖目标文件 + shutil.copy2(specified_file, os.path.join(directory, filename)) + for file_name in os.listdir(f"out/{build_type}"): if file_name.endswith('.md'): md_to_pdf(f"{cwd}/out/{build_type}/{file_name}") @@ -70,4 +85,3 @@ def md_to_pdf(file_name): - From 85afa450fcef99c8102916c7fbf2c4047ae12951 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 22:01:35 +0800 Subject: [PATCH 34/36] Update dotnet.yml --- .github/workflows/dotnet.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 90d5e6988..dd51c58b8 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -37,21 +37,9 @@ jobs: run: | sudo apt-get install -y texlive-xetex - - name: Install Noto - run: | - sudo apt install fonts-noto-cjk - - - name: Setup Noto - run: | - sudo fc-cache -f -v - - - name: Check Noto - run: | - fc-list :lang=zh - - name: Package run: - python BuildHelper.py Release + sudo python BuildHelper.py Release env: PYTHONIOENCODING: 'utf-8' From c28ac53dc3029d6c9b1b037f971d7e7ab3c122e1 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 22:11:49 +0800 Subject: [PATCH 35/36] Update BuildHelper.py --- BuildHelper.py | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index dcc50f887..495bdef3b 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -54,29 +54,31 @@ def md_to_pdf(file_name): except: print(f"README移动失败({file_name})") print("移动README.md成功~") + if build_type == "Release": + print("😋准备转换PDF") + urllib.request.urlretrieve("https://raw.githubusercontent.com/lxgw/LxgwWenKai/main/fonts/TTF/LXGWWenKaiMono-Regular.ttf", "LXGWWenKaiMono-Regular.ttf") + urllib.request.urlretrieve("https://raw.githubusercontent.com/Wandmalfarbe/pandoc-latex-template/master/eisvogel.tex", "eisvogel.tex") + # 指定的目录 + directory = '/usr/share/texmf/fonts/opentype/public/lm/' - print("😋准备转换PDF") - urllib.request.urlretrieve("https://raw.githubusercontent.com/lxgw/LxgwWenKai/main/fonts/TTF/LXGWWenKaiMono-Regular.ttf", "LXGWWenKaiMono-Regular.ttf") - urllib.request.urlretrieve("https://raw.githubusercontent.com/Wandmalfarbe/pandoc-latex-template/master/eisvogel.tex", "eisvogel.tex") - # 指定的目录 - directory = '/usr/share/texmf/fonts/opentype/public/lm/' + # 指定的文件 + specified_file = 'LXGWWenKaiMono-Regular.ttf' - # 指定的文件 - specified_file = 'LXGWWenKaiMono-Regular.ttf' + # 遍历指定目录 + for filename in os.listdir(directory): + if os.path.isfile(os.path.join(directory, filename)): + # 复制指定文件到目标文件,覆盖目标文件 + shutil.copy2(specified_file, os.path.join(directory, filename)) - # 遍历指定目录 - for filename in os.listdir(directory): - if os.path.isfile(os.path.join(directory, filename)): - # 复制指定文件到目标文件,覆盖目标文件 - shutil.copy2(specified_file, os.path.join(directory, filename)) - - for file_name in os.listdir(f"out/{build_type}"): - if file_name.endswith('.md'): - md_to_pdf(f"{cwd}/out/{build_type}/{file_name}") - - print("PDF转换完成~") - # 调用函数来压缩文件夹中的所有文件 - # 注意:这里需要替换为实际的文件夹路径和zip文件路径 + for file_name in os.listdir(f"out/{build_type}"): + if file_name.endswith('.md'): + md_to_pdf(f"{cwd}/out/{build_type}/{file_name}") + os.remove(f"{cwd}/out/{build_type}/{file_name}") + print(f"{file_name}转换成功...") + + print("PDF转换完成~") + # 调用函数来压缩文件夹中的所有文件 + # 注意:这里需要替换为实际的文件夹路径和zip文件路径 print("😋准备打包插件") zip_files_in_folder("out", "Plugins.zip") print("😋😋😋插件打包成功~") From 9979f5907ad02a7abd47a5565a3d5fb253dd0d64 Mon Sep 17 00:00:00 2001 From: Cai <62058454+ACaiCat@users.noreply.github.com> Date: Wed, 1 May 2024 22:18:17 +0800 Subject: [PATCH 36/36] Update BuildHelper.py --- BuildHelper.py | 63 +++++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/BuildHelper.py b/BuildHelper.py index 495bdef3b..6f8a2f0df 100644 --- a/BuildHelper.py +++ b/BuildHelper.py @@ -4,86 +4,59 @@ import sys import zipfile import urllib.request + def zip_files_in_folder(folder_path, zip_file_path): - # Create a ZipFile object in write mode with zipfile.ZipFile(zip_file_path, 'w') as zipf: - # Iterate over each file in the folder for foldername, subfolders, filenames in os.walk(folder_path): for filename in filenames: - # Create the complete filepath by concatenating the folder and filename file_path = os.path.join(foldername, filename) - # Add file to the zip file - # The arcname parameter is used to store the file without any folder structure zipf.write(file_path, arcname=os.path.basename(file_path)) - print(f"生成压缩包: {zip_file_path}") + print(f"📦 压缩包已生成: {zip_file_path}") def md_to_pdf(file_name): - #print(f"pandoc --pdf-engine=xelatex -V mainfont='Noto Serif CJK SC' -V geometry:margin=0.5in {file_name} -o {file_name.replace('.md', '.pdf')}") os.system(f"pandoc --pdf-engine=xelatex -V mainfont=LXGWWenKaiMono-Regular.ttf -V geometry:margin=0.5in --template eisvogel.tex {file_name} -o {file_name.replace('.md', '.pdf')}") - + if __name__ == '__main__': - print(f"😋😋😋打包脚本By Cai...") + print(f"🚀 开始执行打包脚本...(By Cai 😋)") build_type = sys.argv[1] - print(f"😋开始删除json文件") + print(f"🗑️ 开始删除json文件...") for file in glob.glob(os.path.join(f"out/{build_type}/", "*.json")): os.remove(file) - print(f"删除文件: {file}") - print("删除json文件成功~") + print(f"✅ 已删除文件: {file}") + print("✅ json文件删除成功!") - # Get the current working directory - print("😋开始移动README.md") + print("📝 开始移动README.md...") cwd = os.getcwd() - #shutil.copyfile("README.md",f"out/{build_type}/README.md") - # Iterate over all directories in the current working directory for dir_name in os.listdir(cwd): dir_path = os.path.join(cwd, dir_name) - # Check if it is a directory if os.path.isdir(dir_path): - # Iterate over all files in the directory for file_name in os.listdir(dir_path): - # Check if the file is a .csproj file try: if file_name.endswith('.csproj'): - # Construct the source path of the README.md file source_path = os.path.join(dir_path, 'README.md') - # Construct the destination path in the out/{build_type} directory with the same name as the .csproj file destination_path = os.path.join(cwd, 'out', f'{build_type}', file_name.replace('.csproj', '.md')) - # Copy the README.md file to the destination path shutil.copyfile(source_path, destination_path) - print(f"找到README.md({destination_path})") + print(f"🔍 找到README.md({destination_path})") except: - print(f"README移动失败({file_name})") - print("移动README.md成功~") + print(f"⚠️ README移动失败({file_name})") + print("✅ README.md移动成功!") + if build_type == "Release": - print("😋准备转换PDF") + print("🔄 准备转换PDF...") urllib.request.urlretrieve("https://raw.githubusercontent.com/lxgw/LxgwWenKai/main/fonts/TTF/LXGWWenKaiMono-Regular.ttf", "LXGWWenKaiMono-Regular.ttf") urllib.request.urlretrieve("https://raw.githubusercontent.com/Wandmalfarbe/pandoc-latex-template/master/eisvogel.tex", "eisvogel.tex") - # 指定的目录 directory = '/usr/share/texmf/fonts/opentype/public/lm/' - - # 指定的文件 specified_file = 'LXGWWenKaiMono-Regular.ttf' - - # 遍历指定目录 for filename in os.listdir(directory): if os.path.isfile(os.path.join(directory, filename)): - # 复制指定文件到目标文件,覆盖目标文件 shutil.copy2(specified_file, os.path.join(directory, filename)) - for file_name in os.listdir(f"out/{build_type}"): if file_name.endswith('.md'): md_to_pdf(f"{cwd}/out/{build_type}/{file_name}") os.remove(f"{cwd}/out/{build_type}/{file_name}") - print(f"{file_name}转换成功...") - - print("PDF转换完成~") - # 调用函数来压缩文件夹中的所有文件 - # 注意:这里需要替换为实际的文件夹路径和zip文件路径 - print("😋准备打包插件") - zip_files_in_folder("out", "Plugins.zip") - print("😋😋😋插件打包成功~") - - - - + print(f"✅ {file_name}转换成功...") + print("✅ PDF转换完成!") + print("📦 准备打包插件...") + zip_files_in_folder("out", "Plugins.zip") + print("🎉 插件打包成功!")