Просмотр исходного кода

保存入库时重新调整svg2png的图片尺寸
选择题题干去掉换行

莺声燕语 2 лет назад
Родитель
Сommit
9a200287a8
2 измененных файлов с 6 добавлено и 5 удалено
  1. 1 0
      structure/final_structure.py
  2. 5 5
      utils/ruku_opera.py

+ 1 - 0
structure/final_structure.py

@@ -67,6 +67,7 @@ def one_item_structure(xyz):
 
     if topic_type.replace("题", "") in ["单选", "多选", "选择", "不定选择"]:
         one_item = option_structure(one_item, con, ans, item_no_type)
+        one_item["stem"] = re.sub("(?<![/\"]>)(<br\s*/?>|\n)+\s*(?!<img)", "", one_item["stem"])
         if 'options' not in one_item:
             one_item["options"] = []
             # 表格类型的选项再解析,

+ 5 - 5
utils/ruku_opera.py

@@ -206,11 +206,11 @@ class Ruku():
                     imgname_online = "/zyk/uploadfiles/wording/" + str(self.wordid) + "/{}".format(os.path.basename(img_path))
                     put_key_mjmath.append(imgname_online)
                     mj_ltx = svgp_ltx[img_path.replace(".png", ".svg")]  #.replace("\\\\", "\\")
-                    w = shape[0] / 4
-                    h = shape[1] / 4
-                    if re.search(r"\\frac", mj_ltx.replace(" ", '')):
-                        w = shape[0] / 4 * 1.6
-                        h = shape[1] / 4 * 1.6
+                    w = shape[0] / 4 * 1.2
+                    h = shape[1] / 4 * 1.2
+                    if re.search(r"^{?[A-Z、\s]+\}?$", mj_ltx):
+                        w = shape[0] / 4
+                        h = shape[1] / 4
                     mjmath_online = '<img src="http://' + configs.public_bucket_addr + imgname_online \
                                     + '" width="{}" height="{}" data-type="math" data-latex="{}" />'.format(
                         int(w), int(h), "${}$".format(mj_ltx))  # shape[0] / 2