3.2.4 添加锚点

This commit is contained in:
跨越晨昏 2024-10-29 18:49:52 +08:00
parent 2824832906
commit e1201293c7
4 changed files with 3 additions and 40 deletions

View File

@ -34,25 +34,6 @@ from pymdownx.magiclink import MagiclinkExtension
from .Define import Variable from .Define import Variable
class PreProcess(Preprocessor):
"""预处理"""
def __init__(self, variable: Variable):
super().__init__()
self.variable = variable
def run(self, lines: List[str]) -> List[str]:
new_lines = []
for line in lines: # 逐行遍历
for value in re.findall(r'\{\[(.+?)]}', line): # 找到变量
if value in self.variable: # 变量已定义
line = re.sub(fr'\{{\[{value}]}}', self.variable[value], line) # 替换变量为值
else:
line = re.sub(fr'\{{\[{value}]}}', value, line) # 不替换变量
new_lines.append(line)
return new_lines
class Simple(InlineProcessor): class Simple(InlineProcessor):
""" """
可通过简单的正则表达式和HTML标签实现的样式 可通过简单的正则表达式和HTML标签实现的样式
@ -212,26 +193,6 @@ class LinkLine(InlineProcessor):
return tag, m.start(), m.end() return tag, m.start(), m.end()
class Pre(Extension):
"""预处理"""
def __init__(self, variable: Variable):
"""
初始化
:param variable: 变量字典
"""
super().__init__()
self.variable = variable
def extendMarkdown(self, md: Markdown):
"""
添加扩展
:param md: 转换器
"""
md.registerExtension(self) # 注册扩展
md.preprocessors.register(PreProcess(self.variable), 'pre_process', 1000)
class BasicExtension(Extension): class BasicExtension(Extension):
""" """
渲染基本样式 渲染基本样式

View File

@ -272,6 +272,7 @@
<div class="highlight"><pre><span></span><code>#! usr/bin/python3.11 <div class="highlight"><pre><span></span><code>#! usr/bin/python3.11
def main(): def main():
print(&#39;CrossDown&#39;) print(&#39;CrossDown&#39;)
`#!py3 print(&#39;cd&#39;)`
</code></pre></div> </code></pre></div>
<h1 id="5">5 转义</h1> <h1 id="5">5 转义</h1>
<p>\ </p> <p>\ </p>

View File

@ -199,6 +199,7 @@ $$
#! usr/bin/python3.11 #! usr/bin/python3.11
def main(): def main():
print('CrossDown') print('CrossDown')
`#!py3 print('cd')`
``` ```
5 转义 5 转义

View File

@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup( setuptools.setup(
name="CrossDown", name="CrossDown",
version="2.2.0", version="3.2.4",
author="CrossDark", author="CrossDark",
author_email="liuhanbo333@icloud.com", author_email="liuhanbo333@icloud.com",
description="CrossDark's MarkDown", description="CrossDark's MarkDown",