支持公式和脚注的知乎回答剪藏web clipper模板

支持公式和脚注的知乎回答剪藏web clipper模板

感谢

@HAFEN 佬的这个脚本基础上修改: 修改并写了新的知乎剪藏模版obsidian web clipper

新增功能:

  • 公式的支持,包括行内公式和独立的大型公式
  • 脚注的支持,现在摘录有脚注的内容可以完美识别了

注:GPT-5.5写的,反复调了几版,只测试了几篇比较典型的文章

配置文件如下


{
	"schemaVersion": "0.1.0",
	"name": "知乎回答",
	"behavior": "create",
	"noteContentFormat": "{{selectorHtml:.RichContent-inner|first|replace:\"/<span class=\\\"ztext-math\\\"[^>]*data-tex=\\\"([^\\\"]*\\\\begin\\\\{[^\\\"]*\\\\end\\\\{[^\\\"]*)\\\"[^>]*>[\\\\s\\\\S]*?<\\\\/span><\\\\/span>/g\":\"<code>ZZZCLIPPERMATHBLOCK$1ZZZ</code>\"|replace:\"/<span class=\\\"ztext-math\\\"[^>]*data-tex=\\\"([^\\\"]*)\\\"[^>]*>[\\\\s\\\\S]*?<script type=\\\"math\\/tex;mode=display\\\"[\\\\s\\\\S]*?<\\\\/script>[\\\\s\\\\S]*?<\\\\/span><\\\\/span>/g\":\"<code>ZZZCLIPPERMATHBLOCK$1ZZZ</code>\"|replace:\"/<span class=\\\"ztext-math\\\"[^>]*data-tex=\\\"([^\\\"]*)\\\"[^>]*>[\\\\s\\\\S]*?<\\\\/span><\\\\/span>/g\":\"<code>ZZZCLIPPERMATHINLINE$1ZZZ</code>\"|remove_html:\".math-holder\"|replace:\"/<sup[^>]*data-numero=\\\"(\\\\d+)\\\"[^>]*>[\\\\s\\\\S]*?<\\\\/sup>/g\":\"ZZZCLIPPERFOOTNOTEREF$1ZZZ\"|replace:\"href=\\\"https\\://zhida\":\"\"|markdown|replace:\"/&amp;/g\":\"&\"|replace:\"/&#39;/g\":\"'\"|replace:\"/&lt;/g\":\"<\"|replace:\"/&gt;/g\":\">\"|replace:\"/␣/g\":\"⊔\"|replace:\"/⧵/g\":\"∖\"|replace:\"/`ZZZCLIPPERMATHBLOCK\\\\s*([\\\\s\\\\S]*?\\\\S?)\\\\s*(?:\\\\\\\\)?\\\\s*ZZZ`/g\":\"\\n$$$$\\n$1\\n$$$$\\n\"|replace:\"/`ZZZCLIPPERMATHINLINE\\\\s*([\\\\s\\\\S]*?\\\\S)\\\\s*(?:\\\\\\\\)?\\\\s*ZZZ`/g\":\"$$$1$$\"|replace:\"/ZZZCLIPPERFOOTNOTEREF(\\\\d+)ZZZ/g\":\"[^$1]\"|replace:\"/^\\\\s*(\\\\d+)\\\\.\\\\s+\\\\[\\\\^\\\\]\\\\(#ref_\\\\d+_0\\\\)\\\\s*(.*)$/gm\":\"[^$1]: $2\"|replace:\"/\\\\n{3,}/g\":\"\\\\n\\\\n\"}}",
	"properties": [
		{
			"name": "title",
			"value": "{{title|replace:\\\" - 知乎\\\":\\\"\\\"}}",
			"type": "text"
		},
		{
			"name": "source",
			"value": "{{url}}",
			"type": "text"
		},
		{
			"name": "author",
			"value": "{{selector:.UserLink-link|slice:1,2}}",
			"type": "multitext"
		},
		{
			"name": "published",
			"value": "{{selector:.ContentItem-time|split:\\\",\\\"|first|split:\\\"发布于 \\\"|last|date:\\\"YYYY-MM-DD\\\"}}",
			"type": "date"
		},
		{
			"name": "created",
			"value": "{{date}}",
			"type": "date"
		},
		{
			"name": "description",
			"value": "{{description}}",
			"type": "text"
		}
	],
	"triggers": [
		"/^https.+zhihu.+answer.+$/"
	],
	"noteNameFormat": "{{title|replace:\" - 知乎\":\"\"}}",
	"path": "70_Clippings (剪藏)"
}


tips:

  • 包含大量公式的回答请先慢慢滚动到最底部,等回答中的公式全部都加载出来(而不是latex原格式)后再使用clipper剪藏。
  • AI写的,未经过严格测试,比如行内公式的测试只粗略浏览了一下,找出了明显有问题的bug并修复,如果还是有不能识别的情况请回帖。

测试用例:

1 个赞