From 42640173d350b82abf290512deb9baa3f060ce9a Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 5 Oct 2024 13:40:05 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20CrossDown/Core.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BasicSimple->Simple --- CrossDown/Core.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index 590f96a..c6fc961 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -37,7 +37,7 @@ except ModuleNotFoundError: EXTRA_ABLE = False -class BasicSimple(InlineProcessor): +class Simple(InlineProcessor): """ 可通过简单的正则表达式和HTML标签实现的样式 """ @@ -114,9 +114,9 @@ class Basic(Extension): def extendMarkdown(self, md): md.registerExtension(self) # 注册扩展 - md.inlinePatterns.register(BasicSimple(r'~~(.*?)~~', tag='s'), 'strikethrough', 0) # ~~删除线~~ - md.inlinePatterns.register(BasicSimple(r'~(.*?)~', tag='u'), 'underline', 0) # ~下划线~ - md.inlinePatterns.register(BasicSimple(r'==(.*?)==', tag='mark'), 'high_light', 0) # ==高亮== + md.inlinePatterns.register(Simple(r'~~(.*?)~~', tag='s'), 'strikethrough', 0) # ~~删除线~~ + md.inlinePatterns.register(Simple(r'~(.*?)~', tag='u'), 'underline', 0) # ~下划线~ + md.inlinePatterns.register(Simple(r'==(.*?)==', tag='mark'), 'high_light', 0) # ==高亮== md.inlinePatterns.register(BasicDifficult( r'\[(.*?)]\^\((.*?)\)', outer_tag='ruby', inner_tag='rt'), 'up', 0 ) # [在文本的正上方添加一行小文本]^(主要用于标拼音) From 8f7cbd2e6f74dd67d3efbd17da807e70b2dd8e8b Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 5 Oct 2024 13:45:04 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20CrossDown/Core.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index c6fc961..5358eed 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -57,9 +57,9 @@ class Simple(InlineProcessor): return tag, match.start(), match.end() -class BasicDifficult(InlineProcessor): +class Nest(InlineProcessor): """ - 不能通过简单的正则表达式和HTML标签实现的样式 + 需要嵌套HTML标签实现的样式 """ def __init__(self, pattern: str, outer_tag: str, inner_tag: str): """ @@ -81,9 +81,9 @@ class BasicDifficult(InlineProcessor): return outer_tag, match.start(), match.end() -class BasicPro(InlineProcessor): +class ID(InlineProcessor): """ - 不能通过简单的正则表达式和HTML标签实现的样式 + 需要对HTML标签设置ID实现的样式 """ def __init__(self, pattern: str, tag: str, key: str, value: str): """ @@ -117,7 +117,7 @@ class Basic(Extension): md.inlinePatterns.register(Simple(r'~~(.*?)~~', tag='s'), 'strikethrough', 0) # ~~删除线~~ md.inlinePatterns.register(Simple(r'~(.*?)~', tag='u'), 'underline', 0) # ~下划线~ md.inlinePatterns.register(Simple(r'==(.*?)==', tag='mark'), 'high_light', 0) # ==高亮== - md.inlinePatterns.register(BasicDifficult( + md.inlinePatterns.register(Nest( r'\[(.*?)]\^\((.*?)\)', outer_tag='ruby', inner_tag='rt'), 'up', 0 ) # [在文本的正上方添加一行小文本]^(主要用于标拼音) md.inlinePatterns.register(BasicDifficult( From 579ba149b2833ff226cfc97562261853316d7d6d Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 5 Oct 2024 13:46:05 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20CrossDown/Core.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index 5358eed..0e84bdd 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -120,7 +120,7 @@ class Basic(Extension): md.inlinePatterns.register(Nest( r'\[(.*?)]\^\((.*?)\)', outer_tag='ruby', inner_tag='rt'), 'up', 0 ) # [在文本的正上方添加一行小文本]^(主要用于标拼音) - md.inlinePatterns.register(BasicDifficult( + md.inlinePatterns.register(ID( r'\[(.*?)]-\((.*?)\)', outer_tag='ruby', inner_tag='rt'), 'hide', 0 ) # [在指定的文本里面隐藏一段文本]-(只有鼠标放在上面才会显示隐藏文本) From fd653014336846532c9507912428239c91c4e66e Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 5 Oct 2024 13:54:37 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20CrossDown/Core.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index 0e84bdd..42d585d 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -85,7 +85,7 @@ class ID(InlineProcessor): """ 需要对HTML标签设置ID实现的样式 """ - def __init__(self, pattern: str, tag: str, key: str, value: str): + def __init__(self, pattern: str, tag: str, property: str): """ 初始化 :param pattern: 正则表达式 @@ -95,16 +95,14 @@ class ID(InlineProcessor): """ super().__init__(pattern) self.tag = tag - self.key = key - self.value = value + self.property = property def handleMatch(self, match, match_line): - outer_tag = xml.etree.ElementTree.Element(self.outer_tag) # 创建外层标签 - inner_tag = xml.etree.ElementTree.SubElement(outer_tag, self.inner_tag) # 创建内层标签 - outer_tag.text = match.group(1) # 设置外层标签文本 - inner_tag.text = match.group(2) # 设置内层标签文本 + tag = xml.etree.ElementTree.Element(self.tag) # 创建标签 + tag.text = match.groups(1) + tag.set(self.property, match.groups(2)) - return outer_tag, match.start(), match.end() + return tag, match.start(), match.end() class Basic(Extension): @@ -121,7 +119,7 @@ class Basic(Extension): r'\[(.*?)]\^\((.*?)\)', outer_tag='ruby', inner_tag='rt'), 'up', 0 ) # [在文本的正上方添加一行小文本]^(主要用于标拼音) md.inlinePatterns.register(ID( - r'\[(.*?)]-\((.*?)\)', outer_tag='ruby', inner_tag='rt'), 'hide', 0 + r'\[(.*?)]-\((.*?)\)', tag='ruby', property='rt'), 'hide', 0 ) # [在指定的文本里面隐藏一段文本]-(只有鼠标放在上面才会显示隐藏文本) From 30ac4a34d1b8944e13fd1fc6fc4ae10825c10108 Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 5 Oct 2024 13:55:34 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20CrossDown/Core.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index 42d585d..fab0618 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -119,7 +119,7 @@ class Basic(Extension): r'\[(.*?)]\^\((.*?)\)', outer_tag='ruby', inner_tag='rt'), 'up', 0 ) # [在文本的正上方添加一行小文本]^(主要用于标拼音) md.inlinePatterns.register(ID( - r'\[(.*?)]-\((.*?)\)', tag='ruby', property='rt'), 'hide', 0 + r'\[(.*?)]-\((.*?)\)', tag='span', property='title'), 'hide', 0 ) # [在指定的文本里面隐藏一段文本]-(只有鼠标放在上面才会显示隐藏文本) From e243daae9162f55aae0e0d2b3ae0cbfc5f15f4ad Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 5 Oct 2024 14:00:18 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20CrossDown/Core.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index fab0618..49d062e 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -90,8 +90,7 @@ class ID(InlineProcessor): 初始化 :param pattern: 正则表达式 :param tag: html标签 - :param key: html标签属性 - :param value: html标签属性的值 + :param property: html标签属性名称 """ super().__init__(pattern) self.tag = tag @@ -99,8 +98,8 @@ class ID(InlineProcessor): def handleMatch(self, match, match_line): tag = xml.etree.ElementTree.Element(self.tag) # 创建标签 - tag.text = match.groups(1) - tag.set(self.property, match.groups(2)) + tag.text = match.groups(1) # 设置标签内容 + tag.set(self.property, match.groups(2)) # 设置标签属性 return tag, match.start(), match.end() From 38ae221755f5c5b130adf82401a3e7addb1ed756 Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 5 Oct 2024 14:11:25 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3fa654..4be20aa 100644 --- a/README.md +++ b/README.md @@ -230,4 +230,8 @@ graph LR :grinning_face_with_big_eyes: -13 扩展语法 +13 脚注 + +这是一个[^脚注] + +[^脚注]: 一段长的文本用于说明 From 213284caa2511111480bfefe5f08d8ab74857ee3 Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 5 Oct 2024 14:22:39 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 4be20aa..5be6e4e 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,14 @@ graph LR 13 脚注 +13.1 使用 + 这是一个[^脚注] +13.2 定义 + [^脚注]: 一段长的文本用于说明 + +13.3 放置 + +///Footnotes Go Here///