0.8.2提纲有问题

This commit is contained in:
跨越晨昏 2024-09-21 12:40:33 +08:00
parent 23f5672f9e
commit 3becbd9f47
3 changed files with 9 additions and 6 deletions

View File

@ -309,11 +309,13 @@ class Cite:
class Syllabus:
"""
1. 找到提纲
1.1 找到符合若干个数字++数字且首尾都是数字的行
2 找到符合若干个数字++数字且首尾都是数字的行
每个提纲编号全文只能出现一次
"""
def __init__(self, text):
def __init__(self, text: str):
self.text = text
self.syllabus = {tuple(num.split('.')): txt for num, txt in re.findall(r'([\.|\d]+) ([^ ]+?)\n', self.text) if not num.endswith('.')} # 找出提纲
self.syllabus = {tuple(syllabus[0].split('.')): syllabus[1] for syllabus in [re.match(r'([\.|\d]+) ([^ ]+?)\n', i) for i in self.text.split('\n')] if syllabus is not None} # 找出提纲
print(self.syllabus)
def __call__(self, *args, **kwargs):
for num, txt in self.syllabus.items():
@ -386,8 +388,8 @@ def body(text: str) -> Tuple[str, Dict[str, str]]:
:param text: 输入正文
:return: 输出渲染后的正文
"""
escape = Escape(text) # 转义
text = escape()
# escape = Escape(text) # 转义
# text = escape()
text = Basic.week_annotation(text) # 移除弱注释
text = Syllabus(text)() # 渲染提纲
text, values = Value(text)() # 提取变量并赋值到文本中
@ -397,7 +399,7 @@ def body(text: str) -> Tuple[str, Dict[str, str]]:
# text = Cite(text)() # 渲染引用
# text = Basic(text)() # 渲染基础格式
text = markdown.markdown(text, extensions=['markdown.extensions.extra']) # 渲染标准markdown
text = escape.back(text) # 放回被转义的字符
# text = escape.back(text) # 放回被转义的字符
# text = Basic.paragraph(text) # 渲染段落
return text, values

Binary file not shown.

View File

@ -84,6 +84,7 @@ graph LR
> 引文内添加*斜体***粗体**~下划线~~~删除线~~==高亮==
6 提纲
7 注释
7.1 强注释
|=