0.9.0添加Extra语法
This commit is contained in:
parent
90b50d1440
commit
6de7e32ca3
@ -3,6 +3,12 @@ import re
|
||||
|
||||
import markdown
|
||||
|
||||
try: # 检测当前平台是否支持扩展语法
|
||||
import Extra
|
||||
EXTRA_ABLE = True
|
||||
except ModuleNotFoundError:
|
||||
EXTRA_ABLE = False
|
||||
|
||||
|
||||
class Header:
|
||||
def __init__(self, text: str):
|
||||
|
38
Extra.py
Normal file
38
Extra.py
Normal file
@ -0,0 +1,38 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import base64
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
def plot_function_to_base64(function, x_range=(-10, 10), y_range=(-20, 20), dpi=100):
|
||||
# 创建一个图像和坐标轴对象
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
# 生成x值
|
||||
x = np.linspace(x_range[0], x_range[1], 400)
|
||||
|
||||
# 计算y值
|
||||
y = function(x)
|
||||
|
||||
# 绘制图像
|
||||
ax.plot(x, y)
|
||||
|
||||
# 设置坐标轴范围
|
||||
ax.set_xlim(x_range)
|
||||
ax.set_ylim(y_range)
|
||||
|
||||
# 隐藏坐标轴
|
||||
ax.axis('on')
|
||||
|
||||
# 将图像保存到BytesIO对象
|
||||
buf = BytesIO()
|
||||
fig.savefig(buf, format='png', dpi=dpi)
|
||||
|
||||
# 获取图像数据的Base64编码
|
||||
data = base64.b64encode(buf.getbuffer()).decode("ascii")
|
||||
|
||||
# 关闭图像和坐标轴对象
|
||||
plt.close(fig)
|
||||
|
||||
# 返回Base64编码的字符串
|
||||
return f'<img src="data:image/png;base64,{data}" alt="Base64 图片">'
|
@ -120,9 +120,9 @@
|
||||
<h2>6.1<span id="6.1"></span> 提纲号</h2>
|
||||
<p>以数字和点组成,通过空格与提纲名分隔,例如:</p>
|
||||
<h3>6.1.1<span id="6.1.1"></span> 提纲号示例</h3>
|
||||
<p>点不能出现在开头或结尾,例如
|
||||
.6.1.2 错误示范
|
||||
6.1.3. 错误示范</p>
|
||||
<p>点不能出现在开头或结尾,例如</p>
|
||||
<p>.6.1.2 错误示范</p>
|
||||
<p>6.1.3. 错误示范</p>
|
||||
<h1>7<span id="7"></span> 注释</h1>
|
||||
<h2>7.1<span id="7.1"></span> 强注释</h2>
|
||||
<h2>7.2<span id="7.2"></span> 弱注释</h2>
|
||||
|
Loading…
Reference in New Issue
Block a user