diff --git a/CrossDown/Core.py b/CrossDown/Core.py index 2eabd9d..a532a9c 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -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): diff --git a/README.html b/README.html index ea43ae0..f284751 100644 --- a/README.html +++ b/README.html @@ -179,7 +179,7 @@
¥y=x**2¥€-50,50€
// 定义了x范围
¥y=x**3¥€-50,50|-100,100€
// 定义了y范围
{强调文本}
强调文本
A:
@@ -195,11 +195,11 @@
print('CrossDown')
4.2.3 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 转义
\
diff --git a/README.md b/README.md
index b795604..a7094db 100644
--- a/README.md
+++ b/README.md
@@ -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 转义