4

zhihu markdown导入(2022年6月)

 1 year ago
source link: https://zhen8838.github.io/2022/07/01/zhihu-markdown/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

zhihu markdown导入(2022年6月)

我最近想把写的东西弄到知乎上,但是发现一堆问题,按照之前的方式出现了老多错误,因此记录一下.

按照markdown4zhihu的方案,我本地把公式处理成知乎可以预览的模式之后, 本地显示如下:

old_sln.png

然后导入知乎后,全部变成空白了:

old_sln_zhihu.png

然后我各种尝试才发现现在知乎可以直接接受$$.*$$的导入,但是不接受$.*$的导入, 因此修改代码如下:

def formula_ops(_lines):
# _lines = re.sub(r'\$\$\n*([\s\S]*?)\n*\$\$',
# r'\n<img src="https://www.zhihu.com/equation?tex=\1" alt="\1" class="ee_img tr_noresize" eeimg="1">\n', _lines)
_lines = re.sub(r'\$(.+?)\$',
r'$$\1$$', _lines)
return _lines

问了客服, 知乎暂时还不支持标注的导入, 而且手写起来特别麻烦, 简直吐血.

Share


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK