1.7.1 强调好了

This commit is contained in:
跨越晨昏 2024-10-10 18:32:52 +08:00
parent b22a4f319e
commit 30670780e8
3 changed files with 23 additions and 14 deletions

View File

@ -199,11 +199,20 @@ class CodeLine(Treeprocessor):
if elem.findall('code'): # 找到单行代码
for code in elem:
if re.match(r'\$[^$]*\$', code.text): # 渲染Latex
if isinstance(elem.text, str):
elem.text += fr'\({code.text[1:-1]}\){code.tail}'
if isinstance(elem.text, str): # 这个段落还有其它内容
elem.text += fr'\({code.text[1:-1]}\){code.tail}' # 插入latex
else:
elem.text = fr'\({code.text}\)'
elem.text = fr'\({code.text}\)' # latex是段落中唯一的内容
elem.remove(code)
elif re.match(r'¥[^$]*¥', code.text): # 是数学函数(单行)
if EXTRA_ABLE:
expression, range_ = re.findall(r'¥([^$]*)¥(€[^$]*€)?', code)[0] # 分离表达式与范围(如果有)
x_r = (-10, 10)
y_r = (-20, 20)
elif re.match(r'\{[^$]*}', code.text): # 是强调
code.tag = 'span'
code.set('class', 'block')
code.text = code.text[1:-1]
class Basic(Extension):

View File

@ -179,7 +179,7 @@
<p><code>¥y=x**2¥€-50,50€</code> // 定义了x范围</p>
<p><code>¥y=x**3¥€-50,50|-100,100€</code> // 定义了y范围</p>
<h3 id="4.1.3">4.1.3 强调</h3>
<p><code>{强调文本}</code></p>
<p><span class="block">强调文本</span></p>
<h2 id="4.2">4.2 多行</h2>
<h3 id="4.2.1">4.2.1 YAML</h3>
<pre><code class="language-yaml">A:
@ -195,11 +195,11 @@
<pre><code class="language-python">print('CrossDown')
</code></pre>
<h3 id="4.2.3">4.2.3 Mermaid</h3>
<pre><code class="language-mermaid">graph LR
A--&gt;B
A--&gt;C
B--&gt;D
C--&gt;D
<pre><code class="language-mermaid">graph TD
A[开始]--&gt;B[流程]
B--&gt;C{判断}
C--&gt;|结果1|D[结束1]
C--&gt;|结果2|E[结束2]
</code></pre>
<h1 id="5">5 转义</h1>
<p>\ </p>

View File

@ -134,11 +134,11 @@ print('CrossDown')
4.2.3 Mermaid
```mermaid
graph LR
A-->B
A-->C
B-->D
C-->D
graph TD
A[开始]-->B[流程]
B-->C{判断}
C-->|结果1|D[结束1]
C-->|结果2|E[结束2]
```
5 转义