首先Github的Markdown文档:GitHub Flavored Markdown Spec。
- 简单粗暴。
- 繁琐,需要图床,Github放图片的话大一点就很慢。
Chrome浏览器插件:mathjax-plugin-for-github。
- 装了插件才可见。
- 不需要图床。
- 保留公式全部信息,编辑修改方便。
其一:Codecogs

其二:Github自己的API
https://render.githubusercontent.com/render/math?math=
注意事项:
- 不要有多余的空格,回车。
- 需要用
\\
表示\
,因为要转义。
优缺点:
找个python脚本latex2pic.py专门来做,自动化起来:
import re
from urllib.parse import quote
if __name__ == "__main__":
text = open("index.md",encoding="utf-8").read()
parts = text.split("$$")
for i, part in enumerate(parts):
if i & 1:
parts[i] = f')})'
text_out = "\n\n".join(parts)
lines = text_out.split('\n')
for lid, line in enumerate(lines):
parts = re.split(r"\$(.*?)\$", line)
for i, part in enumerate(parts):
if i & 1:
parts[i] = f')})'
lines[lid] = ' '.join(parts)
text_out = "\n".join(lines)
with open("readme.md", "w", encoding='utf-8') as f:
f.write(text_out)