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'): # 找到单行代码 if elem.findall('code'): # 找到单行代码
for code in elem: for code in elem:
if re.match(r'\$[^$]*\$', code.text): # 渲染Latex if re.match(r'\$[^$]*\$', code.text): # 渲染Latex
if isinstance(elem.text, str): if isinstance(elem.text, str): # 这个段落还有其它内容
elem.text += fr'\({code.text[1:-1]}\){code.tail}' elem.text += fr'\({code.text[1:-1]}\){code.tail}' # 插入latex
else: else:
elem.text = fr'\({code.text}\)' elem.text = fr'\({code.text}\)' # latex是段落中唯一的内容
elem.remove(code) 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): class Basic(Extension):

View File

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

View File

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