From 5bf956833b57b70093c1e3d311739cbe11183364 Mon Sep 17 00:00:00 2001 From: crossdark Date: Thu, 3 Oct 2024 21:45:44 +0800 Subject: [PATCH] =?UTF-8?q?1.2emoji=E5=A5=BD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 14 ++++++++------ README.html | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index e421854..d70c279 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -1,3 +1,4 @@ +import emoji from markdown.extensions import Extension from markdown.treeprocessors import Treeprocessor from markdown.inlinepatterns import Pattern @@ -82,11 +83,12 @@ class Style(Preprocessor): def run(self, lines: List[str]) -> List[str]: new_line = [] for line in lines: - line = self.strikethrough(line) # 渲染删除线 - line = self.underline(line) # 渲染下划线 - line = self.highlight(line) # 渲染高亮 - line = self.up(line) # 渲染上部文本 - line = self.hide(line) # 渲染隐藏文本 + line = re.sub(r'~~([^~\n]+)~~', r'\1', line) # ~~删除线~~ + line = re.sub(r'~([^~\n]+)~', r'\1', line) # ~下划线~ + line = re.sub(r'==([^=\n]+)==', r'\1', line) # ==高亮== + line = re.sub(r'\[(.*?)]\^\((.*?)\)', r'\1\2', line) # [在文本的正上方添加一行小文本]^(主要用于标拼音) + line = re.sub(r'\[(.*?)]-\((.*?)\)', r'\1', line) # [在指定的文本里面隐藏一段文本]-(只有鼠标放在上面才会显示隐藏文本) + line = emoji.emojize(line) # 渲染Emoji new_line.append(line) return new_line @@ -145,7 +147,7 @@ class Tag(Treeprocessor): elif header.tag == 'ul': # 是无序列表 for i in header: # 遍历列表内容 try: - i[0].set('href', '#' + i[0].text.split(' ')[0]) # 是目录 + i[0].set('href', '#' + i[0].text.split(' ')[0]) # 是目录,更改链接为标准格式 except IndexError: pass # 是普通的无序列表 diff --git a/README.html b/README.html index 8531817..1f7f9f6 100644 --- a/README.html +++ b/README.html @@ -275,8 +275,8 @@

这是一条警告

11 Emoji

-

:person_biking:

-

:grinning_face_with_big_eyes:

+

🚴

+

😃

12 扩展语法

12.1 警告