From ccc4724d7d325f8fb1f19d97777b2cd41a3f0cbe Mon Sep 17 00:00:00 2001 From: crossdark Date: Thu, 3 Oct 2024 21:27:28 +0800 Subject: [PATCH] =?UTF-8?q?1.1.1=E9=94=9A=E7=82=B9=E4=BE=9D=E7=84=B6?= =?UTF-8?q?=E6=9C=89=E7=82=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 12 ++++-- README.html | 104 +++++++++++++++++++++++----------------------- 2 files changed, 60 insertions(+), 56 deletions(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index 5abbb29..a4ab04f 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -126,11 +126,11 @@ class Value(Preprocessor): lines.remove(line) # 删除 else: # 应该被赋值 lines[index] = re.sub('{' + key + '}', value, line) # 对变量赋值 - elif any(anchor in line for anchor in anchors): # 匹配到了锚点 + if any(anchor in line for anchor in anchors): # 匹配到了锚点 if re.search('\{#', line): # 是锚点定义 lines[index] = re.sub(r'\{#(.+)}', r'', line) # 定义锚点 else: # 是页内链接 - pass + print(line) return lines @@ -142,8 +142,12 @@ class Tag(Treeprocessor): for header in root.iter(): if header.tag in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6'): # 查找标题 header.set('id', header.text.split(' ')[0]) # 给标题添加锚点 - if header.text is not None: # 不是空行 - pass + elif header.tag == 'ul': # 是无序列表 + for i in header: # 遍历列表内容 + try: + i[0].set('id', i[0].text.split(' ')[0]) # 是目录 + except IndexError: + pass # 是普通的无序列表 class Basic(Extension): diff --git a/README.html b/README.html index 443941f..c971d65 100644 --- a/README.html +++ b/README.html @@ -28,17 +28,17 @@