From 2c04390756293ccfd541d6aafe5a00cadd536cfd Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 19 Oct 2024 14:24:58 +0800 Subject: [PATCH] =?UTF-8?q?2.1.2=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 28 ++++++++++++++++++++-------- setup.py | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index 56e614c..d9f9668 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -269,21 +269,33 @@ class BoxBlock(BlockProcessor): class _Anchor(InlineProcessor): - def handleMatch(self, match, match_line): + def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[None, None, None]: + """ + 处理匹配 + :param m: re模块的匹配对象 + :param data: 被匹配的原始文本 + :return: 标签 匹配开始 匹配结束 + """ tag = xml.etree.ElementTree.Element('span') # 创建标签 - tag.text = match.group(1) - tag.set('id', match.group(1)) # 设置id + tag.text = m.group(1) + tag.set('id', m.group(1)) # 设置id - return tag, match.start(), match.end() + return tag, m.start(), m.end() class LinkLine(InlineProcessor): - def handleMatch(self, match, match_line): + def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[None, None, None]: + """ + 处理匹配 + :param m: re模块的匹配对象 + :param data: 被匹配的原始文本 + :return: 标签 匹配开始 匹配结束 + """ tag = xml.etree.ElementTree.Element('a') # 创建标签 - tag.set('href', '#' + match.group(1)) # 设置id - tag.text = match.group(1) + tag.set('href', '#' + m.group(1)) # 设置id + tag.text = m.group(1) - return tag, match.start(), match.end() + return tag, m.start(), m.end() class CodeLine(Treeprocessor): diff --git a/setup.py b/setup.py index 3b9df0e..e7f8a29 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="CrossDown", - version="2.1.0", + version="2.1.2", author="CrossDark", author_email="liuhanbo333@icloud.com", description="CrossDark's MarkDown",