From 3becbd9f47033607ccf5f65e95c6ed34aae6e7c7 Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 21 Sep 2024 12:40:33 +0800 Subject: [PATCH] =?UTF-8?q?0.8.2=E6=8F=90=E7=BA=B2=E6=9C=89=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown.py | 14 ++++++++------ README.html | Bin 5697 -> 4005 bytes README.md | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CrossDown.py b/CrossDown.py index 4245019..56ff1d4 100644 --- a/CrossDown.py +++ b/CrossDown.py @@ -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 diff --git a/README.html b/README.html index 795e4775bca852d89ee0d8f5773d4d4fc89b4a94..a36aaa0b3e9886888e42112da1649716ccca27e9 100644 GIT binary patch delta 1060 zcmZ8f%Wo1v7>|i97O_oC)L0+=lFFe*maq$@#m&a5M@TgBV0}dpA|_IhQez{gRii*_ zCAwBx#7He9J+##pO)aGu&y9&EuU?pi{V$xIS=Pn9e2?Gb`(|c;oGSKwF77rP0e?0? zAIeg0x$$X5D$UXsV*@FlkU!4x)`-~Nw&;lnHipH$4OB_16c&^CKuD0@=4#s_Z^fyG zu)vSTqT!L-LVZ0$P_-ls@p60LX^m?KeoUx+n?}jk_40S#I`+@Tfo%ko%**oy0*z8g z>@gf}qfR#rSJmu~;r=1ba}ZGSIZCY)RYY9dbDWKWm8yB=EF8#UReD)e6`XS5`Bix` zt80t>9m5AT0t@I}wVq1Qxj#E*n$tLJhSGC#B2Bg8^$xRGHFn!00@e_KXq5XxtJ&IS z3SX+W3X89`@pT$aR;cmKy}@G-*+;5^18HLmP37e`+4_@B%IG#7JwP%JYFmr-{A2V! zLy?HdtRjpJ4|97j1s+gDHud&W4IYOI*~Y?)W{HWzLmoHfo#{LxzS?(>o|OQCXF*R(O99LxgOBvuZp?;)Dgx>&1hB*O2n`E#pdo3SVr{%vdes zAkO==Uos9Zi^YY(me4{#GqdQ~Q*5ocX~h-AQLFwp)d0Jm<iiB literal 5697 zcmb_gZExE~5>CGMS8Ul2O@c}rNq&n%@!;4gio(7Wtq-^Y0RoC*MA{U^BPly>Q6RaV zV>_|yppEVLC0931FF{*7Ij5~1S$6&mNlBmXFWf9&cV)$}59bdCN1T~`W_D)w;qvbe zT^k(z{FAFlvCEo(&^tVNK$@tR^4u3nYVglo@T)8q$peBvzAW1!k`&RjWINCOW%R>T zpRbj?)Wx!#=O$En(x{j=hop*b%Q`4eszqDL7v%|6l2g9$0aA6Ccq=_- z{R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