From d9e9d74197c1384365081344fc3453e0148c3479 Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Fri, 7 Oct 2022 23:14:51 +0800 Subject: [PATCH] =?UTF-8?q?20221007=20night=20=E7=BC=96=E8=AF=91pdf?= =?UTF-8?q?=E5=89=8D=E5=8F=AF=E8=AF=86=E5=88=AB=E7=B3=BB=E7=BB=9F=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=88=86=E9=85=8D=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具/批量添加题库字段数据.ipynb | 6 +++--- 工具/批量题号选题pdf生成.ipynb | 6 +++++- 工具/讲义生成.ipynb | 8 +++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/工具/批量添加题库字段数据.ipynb b/工具/批量添加题库字段数据.ipynb index efd000a3..325e20ad 100644 --- a/工具/批量添加题库字段数据.ipynb +++ b/工具/批量添加题库字段数据.ipynb @@ -139,7 +139,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3.9.7 ('base')", + "display_name": "Python 3.8.8 ('base')", "language": "python", "name": "python3" }, @@ -153,12 +153,12 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.8.8" }, "orig_nbformat": 4, "vscode": { "interpreter": { - "hash": "e4cce46d6be9934fbd27f9ca0432556941ea5bdf741d4f4d64c6cd7f8dfa8fba" + "hash": "d311ffef239beb3b8f3764271728f3972d7b090c974f8e972fcdeedf230299ac" } } }, diff --git a/工具/批量题号选题pdf生成.ipynb b/工具/批量题号选题pdf生成.ipynb index 4410ff19..cb7b9316 100644 --- a/工具/批量题号选题pdf生成.ipynb +++ b/工具/批量题号选题pdf生成.ipynb @@ -21,7 +21,7 @@ } ], "source": [ - "import os,re,time,json\n", + "import os,re,time,json,sys\n", "\n", "\"\"\"\n", "模板文件目录下 题目清单.tex 文件不能缺失\n", @@ -145,6 +145,10 @@ " #替换latex文件的内容并编译\n", " with open(\"模板文件/题目清单.tex\",\"r\",encoding = \"utf8\") as f:\n", " latex_raw = f.read()\n", + " #识别操作系统\n", + " if sys.platform != \"win32\":\n", + " latex_raw = re.sub(r\"fontset[\\s]*=[\\s]*windows\",\"fontset = fandol\",latex_raw)\n", + " latex_raw = re.sub(r\"\\\\setCJKmainfont\",r\"% \\\\setCJKmainfont\",latex_raw)\n", " latex_teachers = latex_raw.replace(\"编译模板\",data_teachers)\n", " with open(teachers_latex_file,\"w\",encoding = \"utf8\") as f:\n", " f.write(latex_teachers)\n", diff --git a/工具/讲义生成.ipynb b/工具/讲义生成.ipynb index a8de4a32..920e6988 100644 --- a/工具/讲义生成.ipynb +++ b/工具/讲义生成.ipynb @@ -23,7 +23,7 @@ } ], "source": [ - "import os,re,json,time\n", + "import os,re,json,time,sys\n", "\n", "\"\"\"---设置模式(1为整卷统一编号, 0为每一部分从1开始编号)---\"\"\"\n", "enumi_mode = 0\n", @@ -119,6 +119,12 @@ "#读取模板\n", "with open(template_file,\"r\",encoding=\"utf8\") as f:\n", " latex_raw = f.read()\n", + "\n", + "#识别操作系统\n", + "if sys.platform != \"win32\":\n", + " latex_raw = re.sub(r\"fontset[\\s]*=[\\s]*windows\",\"fontset = fandol\",latex_raw)\n", + " latex_raw = re.sub(r\"\\\\setCJKmainfont\",r\"% \\\\setCJKmainfont\",latex_raw)\n", + "\n", "#预处理\n", "for command in exec_list:\n", " latex_raw = re.sub(command[0],command[1],latex_raw)\n",