From 70d3427bb935013fad183e03b3a8f60e2b754af3 Mon Sep 17 00:00:00 2001 From: crossdark Date: Sun, 22 Sep 2024 19:54:01 +0800 Subject: [PATCH] =?UTF-8?q?0.9.2=E4=BF=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CrossDown.py b/CrossDown.py index 9944fe2..8c641b6 100644 --- a/CrossDown.py +++ b/CrossDown.py @@ -249,7 +249,9 @@ class CodeBlock: x_r = tuple(int(i) for i in ranges[0].split(',')) if len(ranges) == 2: # 定义了y范围 y_r = tuple(int(i) for i in ranges[1].split(',')) - self.codes[index] = CrossMore.function_drawing(function=lambda x: eval(expression.split('=')[1]), x_range=x_r, y_range=y_r) + self.codes[index] = CrossMore.function_drawing( # 绘制函数图像 + function=lambda x: eval(expression.split('=')[1]), x_range=x_r, y_range=y_r + ) else: self.codes[index] = '该平台不支持扩展语法' @@ -344,11 +346,14 @@ class Syllabus: def __call__(self, *args, **kwargs): return '\n'.join([ (lambda match, origen: - re.sub(f'^({match.groups()[0]})', + re.sub(f'^({match.groups()[0]})', # 按照提纲等级添加#和锚点 fr'{"#" * len(match.groups()[0].split("."))} \1{{#' + match.groups()[0] + '}', origen) if match is not None else origen) # 对于不是提纲的行,直接返回原始字符 ((lambda x: re.match(r'^([\d.]+) ', x) # 判断是否是提纲 - if not any((x.startswith('.'), re.search('\. ', x) is not None)) + if not any((x.startswith('.'), # 以.开头 + re.search('\. ', x) is not None, # 存在.+空格 + re.search('\.{2,}', x), # 存在连续的. + )) else None)(line), line) # 排除.在提纲号开头或结尾的情况 for line in self.text.splitlines() # 分割并遍历文本的每一行 ])