From 491ad5ea4ef9a3ca89ef73798b0ceefc83e7a5cd Mon Sep 17 00:00:00 2001 From: crossdark Date: Sat, 31 Aug 2024 14:38:03 +0800 Subject: [PATCH] =?UTF-8?q?V0.5=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90,?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=9F=A5bug+=E5=81=9A=E8=BD=AC=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CrossDown.py b/CrossDown.py index 331b703..81c5063 100644 --- a/CrossDown.py +++ b/CrossDown.py @@ -67,6 +67,20 @@ class Style: """ self.text = re.sub(r'==([^=\n]+)==', r'\1', self.text) + def up(self): + """ + 在文本的正上方添加一行小文本,主要用于标拼音 + :return: + """ + self.text = re.sub(r'\[(.*?)]\^\((.*?)\)', r'\1\2', self.text) + + def hide(self): + """ + 在指定的文本里面隐藏一段文本,只有鼠标放在上面才会显示隐藏文本 + :return: + """ + self.text = re.sub(r'\[(.*?)]-\((.*?)\)', r'\1', self.text) + def __call__(self, *args, **kwargs): """ 一键运行 @@ -79,6 +93,8 @@ class Style: self.strikethrough() self.underline() self.highlight() + self.up() + self.hide() return self.text @@ -94,7 +110,18 @@ class Function: """ self.text = text + def image(self): + """ + 实现链接 + :return: + """ + self.text = re.sub(r'!\[([^\[\]\n]+)]\(([^()\n]+)\)', r'\1', self.text) + def link(self): + """ + 实现链接 + :return: + """ self.text = re.sub(r'\[([^\[\]\n]+)]\(([^()\n]+)\)', r'\1', self.text) def __call__(self, *args, **kwargs): @@ -104,6 +131,7 @@ class Function: :param kwargs: :return: """ + self.image() self.link() return self.text