V0.5基本完成,开始查bug+做转义

This commit is contained in:
跨越晨昏 2024-08-31 14:38:03 +08:00
parent 65503f0ea7
commit 491ad5ea4e

View File

@ -67,6 +67,20 @@ class Style:
""" """
self.text = re.sub(r'==([^=\n]+)==', r'<mark>\1</mark>', self.text) self.text = re.sub(r'==([^=\n]+)==', r'<mark>\1</mark>', self.text)
def up(self):
"""
在文本的正上方添加一行小文本,主要用于标拼音
:return:
"""
self.text = re.sub(r'\[(.*?)]\^\((.*?)\)', r'<ruby>\1<rt>\2</rt></ruby>', self.text)
def hide(self):
"""
在指定的文本里面隐藏一段文本,只有鼠标放在上面才会显示隐藏文本
:return:
"""
self.text = re.sub(r'\[(.*?)]-\((.*?)\)', r'<span title="\2">\1</span>', self.text)
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
""" """
一键运行 一键运行
@ -79,6 +93,8 @@ class Style:
self.strikethrough() self.strikethrough()
self.underline() self.underline()
self.highlight() self.highlight()
self.up()
self.hide()
return self.text return self.text
@ -94,7 +110,18 @@ class Function:
""" """
self.text = text self.text = text
def image(self):
"""
实现链接
:return:
"""
self.text = re.sub(r'!\[([^\[\]\n]+)]\(([^()\n]+)\)', r'<img src="\2" alt="\1">', self.text)
def link(self): def link(self):
"""
实现链接
:return:
"""
self.text = re.sub(r'\[([^\[\]\n]+)]\(([^()\n]+)\)', r'<a href="\2">\1</a>', self.text) self.text = re.sub(r'\[([^\[\]\n]+)]\(([^()\n]+)\)', r'<a href="\2">\1</a>', self.text)
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
@ -104,6 +131,7 @@ class Function:
:param kwargs: :param kwargs:
:return: :return:
""" """
self.image()
self.link() self.link()
return self.text return self.text