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",