提交 f9e99f74 编写于 作者: M Mars Liu

skip if math parser not success

上级 223f46b8
...@@ -7,7 +7,7 @@ this_directory = Path(__file__).parent ...@@ -7,7 +7,7 @@ this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text() long_description = (this_directory / "README.md").read_text()
setup(name="skill-tree-parser", setup(name="skill-tree-parser",
version="0.0.1", version="0.0.2",
description="CSDN Skill Tree Parser", description="CSDN Skill Tree Parser",
long_description=long_description, long_description=long_description,
long_description_content_type='text/markdown', long_description_content_type='text/markdown',
......
...@@ -18,7 +18,8 @@ def escape(state): ...@@ -18,7 +18,8 @@ def escape(state):
elif c == "}": elif c == "}":
return '}' return '}'
else: else:
raise ParsecError(state, f"unknown escape char \\{c}") # 兼容非公式嵌入,对于无法识别的文本返回原文
return f'\\{c}'
@Parsec @Parsec
......
...@@ -6,6 +6,10 @@ import sys ...@@ -6,6 +6,10 @@ import sys
import uuid import uuid
import re import re
from parsec import BasicState, ParsecError
from skill_tree.excercises.markdown import parse
id_set = set() id_set = set()
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
...@@ -363,6 +367,15 @@ class TreeWalker: ...@@ -363,6 +367,15 @@ class TreeWalker:
export.append(mfile) export.append(mfile)
flag = True flag = True
config["export"] = export config["export"] = export
with open(md_file, encoding="utf-8") as efile:
data = efile.read()
state = BasicState(data)
try:
doc = parse(state)
except ParsecError as err:
index = state.index
context = state.data[index-15:index+15]
logger.error(f"习题 [{md_file}] 解析失败,在位置 {index} [{context}] 附近有格式: [{err}]")
if flag: if flag:
dump_json(os.path.join(section_path, "config.json"), dump_json(os.path.join(section_path, "config.json"),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册