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]:
|
||||
new_lines = []
|
||||
for line in lines: # 逐行遍历
|
||||
print(line)
|
||||
for value in re.findall(r'\{\[(.+?)]}', line): # 找到变量
|
||||
if value in self.variable: # 变量已定义
|
||||
line = re.sub(fr'\{{\[{value}]}}', self.variable[value], line) # 替换变量为值
|
||||
@ -366,7 +367,7 @@ class Pre(Extension):
|
||||
:param md: 转换器
|
||||
"""
|
||||
md.registerExtension(self) # 注册扩展
|
||||
md.preprocessors.register(PreProcess(self.variable), 'pre_process', 0)
|
||||
md.preprocessors.register(PreProcess(self.variable), 'pre_process', 1000)
|
||||
|
||||
|
||||
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">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="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>
|
||||
|
||||
<h3 id="4.2.2">4.2.2 Python</h3>
|
||||
@ -405,7 +408,7 @@
|
||||
<h1 id="17">17 属性设置</h1>
|
||||
<p style="font-family: sans-serif;">可以设置文段的字体为sans-serif</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>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -126,6 +126,9 @@ B:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
{[强调变量]}:
|
||||
- a
|
||||
- b
|
||||
```
|
||||
|
||||
4.2.2 Python
|
||||
@ -372,4 +375,4 @@ Orange
|
||||
|
||||
可以设置文段的自定义字体{@style=font-family: SetoFont;}为小赖字体
|
||||
|
||||
可以设置文本的黄色外框{@style=display: inline-block; border: 1px solid yellow;}
|
||||
可以设置文本的黄色外框{@style=display: inline-block; border: 1px solid yellow;}
|
||||
|
Loading…
Reference in New Issue
Block a user