forked from CrossDark/CrossDown
2.2.1 变量可以在代码块里用了
This commit is contained in:
parent
bf399ff836
commit
9bc4dc28b8
@ -68,6 +68,7 @@ class PreProcess(Preprocessor):
|
|||||||
def run(self, lines: List[str]) -> List[str]:
|
def run(self, lines: List[str]) -> List[str]:
|
||||||
new_lines = []
|
new_lines = []
|
||||||
for line in lines: # 逐行遍历
|
for line in lines: # 逐行遍历
|
||||||
|
print(line)
|
||||||
for value in re.findall(r'\{\[(.+?)]}', line): # 找到变量
|
for value in re.findall(r'\{\[(.+?)]}', line): # 找到变量
|
||||||
if value in self.variable: # 变量已定义
|
if value in self.variable: # 变量已定义
|
||||||
line = re.sub(fr'\{{\[{value}]}}', self.variable[value], line) # 替换变量为值
|
line = re.sub(fr'\{{\[{value}]}}', self.variable[value], line) # 替换变量为值
|
||||||
@ -366,7 +367,7 @@ class Pre(Extension):
|
|||||||
:param md: 转换器
|
:param md: 转换器
|
||||||
"""
|
"""
|
||||||
md.registerExtension(self) # 注册扩展
|
md.registerExtension(self) # 注册扩展
|
||||||
md.preprocessors.register(PreProcess(self.variable), 'pre_process', 0)
|
md.preprocessors.register(PreProcess(self.variable), 'pre_process', 1000)
|
||||||
|
|
||||||
|
|
||||||
class Basic(Extension):
|
class Basic(Extension):
|
||||||
|
@ -187,6 +187,9 @@
|
|||||||
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">a</span>
|
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">a</span>
|
||||||
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">b</span>
|
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">b</span>
|
||||||
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">c</span>
|
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">c</span>
|
||||||
|
<span class="nt">强调值</span><span class="p">:</span>
|
||||||
|
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">a</span>
|
||||||
|
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">b</span>
|
||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
|
|
||||||
<h3 id="4.2.2">4.2.2 Python</h3>
|
<h3 id="4.2.2">4.2.2 Python</h3>
|
||||||
@ -405,7 +408,7 @@
|
|||||||
<h1 id="17">17 属性设置</h1>
|
<h1 id="17">17 属性设置</h1>
|
||||||
<p style="font-family: sans-serif;">可以设置文段的字体为sans-serif</p>
|
<p style="font-family: sans-serif;">可以设置文段的字体为sans-serif</p>
|
||||||
<p style="font-family: Helvetica;">可以设置文段的字体为Helvetica</p>
|
<p style="font-family: Helvetica;">可以设置文段的字体为Helvetica</p>
|
||||||
<p style=font-family: SetoFont; src="url('https://crossdark.com/wp-content/uploads/file-manager/小濑字体.ttf') format('truetype');">可以设置文段的自定义字体为Courier New</p>
|
<p style="font-family: SetoFont;">可以设置文段的自定义字体为小赖字体</p>
|
||||||
<p style="display: inline-block; border: 1px solid yellow;">可以设置文本的黄色外框</p>
|
<p style="display: inline-block; border: 1px solid yellow;">可以设置文本的黄色外框</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -126,6 +126,9 @@ B:
|
|||||||
- a
|
- a
|
||||||
- b
|
- b
|
||||||
- c
|
- c
|
||||||
|
{[强调变量]}:
|
||||||
|
- a
|
||||||
|
- b
|
||||||
```
|
```
|
||||||
|
|
||||||
4.2.2 Python
|
4.2.2 Python
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="CrossDown",
|
name="CrossDown",
|
||||||
version="2.1.3",
|
version="2.2.0",
|
||||||
author="CrossDark",
|
author="CrossDark",
|
||||||
author_email="liuhanbo333@icloud.com",
|
author_email="liuhanbo333@icloud.com",
|
||||||
description="CrossDark's MarkDown",
|
description="CrossDark's MarkDown",
|
||||||
|
Loading…
Reference in New Issue
Block a user