修正: deepseek 笔记 96 处块级公式改为多行写法(适配 SilverBullet 行首锚点), 索引脚本同步 _abstract 命名
This commit is contained in:
@@ -134,7 +134,9 @@ def main():
|
||||
out.append('- **作者**:%s' % (a[:300] + ('…' if len(a) > 300 else '')))
|
||||
out.append('- **原文 PDF**:[%s.pdf](%s)' % (stem, p['pdf_path'].replace('\\', '/')))
|
||||
if done:
|
||||
out.append('- **中文翻译**:[%s.md](%s)' % (stem, p['md_path'].replace('\\', '/')))
|
||||
out.append('- **中文翻译**:[%s](%s)' % (
|
||||
os.path.basename(p['md_path'].replace('\\', '/')),
|
||||
p['md_path'].replace('\\', '/')))
|
||||
else:
|
||||
out.append('- **中文翻译**:(待生成)')
|
||||
out.append('')
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
"""Audit / convert single-line $$...$$ math blocks for SilverBullet compatibility.
|
||||
|
||||
SilverBullet's Math library defines block math with the line-anchored marker
|
||||
regex ^\\$\\$$ for BOTH start and end, so `$$...$$` written on one line never
|
||||
closes and is rendered as raw text.
|
||||
|
||||
Usage:
|
||||
python math_fix.py audit <base_dir>
|
||||
python math_fix.py convert <base_dir> [--apply]
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
CMD = sys.argv[1]
|
||||
BASE = sys.argv[2] if len(sys.argv) > 2 else '.'
|
||||
APPLY = '--apply' in sys.argv
|
||||
|
||||
LINE_RE = re.compile(r'^\$\$(.+)\$\$$')
|
||||
|
||||
|
||||
def notes():
|
||||
for root, dirs, files in os.walk(BASE):
|
||||
if any(x in root for x in ['_scripts', '_text', '_digest', '.git']):
|
||||
continue
|
||||
for fn in sorted(files):
|
||||
if fn.endswith('.md') and fn != 'README.md':
|
||||
yield os.path.join(root, fn)
|
||||
|
||||
|
||||
def walk_lines(path):
|
||||
"""Yield (index, line, in_fence)."""
|
||||
fence = False
|
||||
lines = open(path, encoding='utf-8').read().split('\n')
|
||||
for i, line in enumerate(lines):
|
||||
if line.lstrip().startswith('```'):
|
||||
yield i, line, fence
|
||||
fence = not fence
|
||||
continue
|
||||
yield i, line, fence
|
||||
|
||||
|
||||
def audit():
|
||||
total = indented = multi = in_fence = trailing = 0
|
||||
samples = []
|
||||
for p in notes():
|
||||
for i, line, fence in walk_lines(p):
|
||||
s = line.strip()
|
||||
if not s.startswith('$$') or s.count('$$') < 2:
|
||||
continue
|
||||
total += 1
|
||||
if fence:
|
||||
in_fence += 1
|
||||
samples.append(('FENCE', p, i, s[:90]))
|
||||
if line != line.lstrip():
|
||||
indented += 1
|
||||
samples.append(('INDENT', p, i, s[:90]))
|
||||
if s.count('$$') > 2:
|
||||
multi += 1
|
||||
samples.append(('MULTI', p, i, s[:90]))
|
||||
if not s.endswith('$$'):
|
||||
trailing += 1
|
||||
samples.append(('TAILTEXT', p, i, s[-80:]))
|
||||
print('单行 $$ 块总数 :', total)
|
||||
print(' 其中在代码块内 :', in_fence)
|
||||
print(' 其中带前导缩进 :', indented)
|
||||
print(' 其中一行含 >2 个 $$ :', multi)
|
||||
print(' 其中不以 $$ 结尾 :', trailing)
|
||||
for kind, p, i, s in samples[:20]:
|
||||
print(' [%s] %s:%d %s' % (kind, os.path.relpath(p, BASE), i + 1, s))
|
||||
|
||||
|
||||
def convert():
|
||||
files_changed = 0
|
||||
blocks_changed = 0
|
||||
skipped = []
|
||||
for p in notes():
|
||||
lines = open(p, encoding='utf-8').read().split('\n')
|
||||
out = []
|
||||
fence = False
|
||||
n = 0
|
||||
for line in lines:
|
||||
if line.lstrip().startswith('```'):
|
||||
fence = not fence
|
||||
out.append(line)
|
||||
continue
|
||||
m = LINE_RE.match(line)
|
||||
if m and not fence:
|
||||
body = m.group(1).strip()
|
||||
if '$$' in body:
|
||||
skipped.append((os.path.relpath(p, BASE), line[:90]))
|
||||
out.append(line)
|
||||
continue
|
||||
out.append('$$')
|
||||
out.append(body)
|
||||
out.append('$$')
|
||||
n += 1
|
||||
continue
|
||||
out.append(line)
|
||||
if n:
|
||||
files_changed += 1
|
||||
blocks_changed += n
|
||||
print('%3d 处 %s' % (n, os.path.relpath(p, BASE)))
|
||||
if APPLY:
|
||||
with open(p, 'w', encoding='utf-8', newline='\n') as f:
|
||||
f.write('\n'.join(out))
|
||||
print()
|
||||
print('文件数: %d 转换块数: %d' % (files_changed, blocks_changed))
|
||||
if skipped:
|
||||
print('跳过(正文含 $$,需人工确认):')
|
||||
for s in skipped:
|
||||
print(' ', s)
|
||||
print('模式:', '已写入' if APPLY else '预演(未写入,加 --apply 才落盘)')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if CMD == 'audit':
|
||||
audit()
|
||||
elif CMD == 'convert':
|
||||
convert()
|
||||
else:
|
||||
raise SystemExit('unknown command: ' + CMD)
|
||||
@@ -14,7 +14,7 @@
|
||||
"dir": "01-基础模型",
|
||||
"stem": "01-DeepSeek-LLM-2401.02954",
|
||||
"pdf_path": "01-基础模型\\01-DeepSeek-LLM-2401.02954.pdf",
|
||||
"md_path": "01-基础模型\\01-DeepSeek-LLM-2401.02954.md"
|
||||
"md_path": "01-基础模型\\01-DeepSeek-LLM-2401.02954_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2401.06066",
|
||||
@@ -31,7 +31,7 @@
|
||||
"dir": "01-基础模型",
|
||||
"stem": "02-DeepSeekMoE-2401.06066",
|
||||
"pdf_path": "01-基础模型\\02-DeepSeekMoE-2401.06066.pdf",
|
||||
"md_path": "01-基础模型\\02-DeepSeekMoE-2401.06066.md"
|
||||
"md_path": "01-基础模型\\02-DeepSeekMoE-2401.06066_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2401.14196",
|
||||
@@ -48,7 +48,7 @@
|
||||
"dir": "02-代码模型",
|
||||
"stem": "01-DeepSeek-Coder-2401.14196",
|
||||
"pdf_path": "02-代码模型\\01-DeepSeek-Coder-2401.14196.pdf",
|
||||
"md_path": "02-代码模型\\01-DeepSeek-Coder-2401.14196.md"
|
||||
"md_path": "02-代码模型\\01-DeepSeek-Coder-2401.14196_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2402.03300",
|
||||
@@ -65,7 +65,7 @@
|
||||
"dir": "03-数学模型",
|
||||
"stem": "01-DeepSeekMath-2402.03300",
|
||||
"pdf_path": "03-数学模型\\01-DeepSeekMath-2402.03300.pdf",
|
||||
"md_path": "03-数学模型\\01-DeepSeekMath-2402.03300.md"
|
||||
"md_path": "03-数学模型\\01-DeepSeekMath-2402.03300_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2403.05525",
|
||||
@@ -82,7 +82,7 @@
|
||||
"dir": "05-多模态",
|
||||
"stem": "01-DeepSeek-VL-2403.05525",
|
||||
"pdf_path": "05-多模态\\01-DeepSeek-VL-2403.05525.pdf",
|
||||
"md_path": "05-多模态\\01-DeepSeek-VL-2403.05525.md"
|
||||
"md_path": "05-多模态\\01-DeepSeek-VL-2403.05525_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2405.04434",
|
||||
@@ -99,7 +99,7 @@
|
||||
"dir": "01-基础模型",
|
||||
"stem": "03-DeepSeek-V2-2405.04434",
|
||||
"pdf_path": "01-基础模型\\03-DeepSeek-V2-2405.04434.pdf",
|
||||
"md_path": "01-基础模型\\03-DeepSeek-V2-2405.04434.md"
|
||||
"md_path": "01-基础模型\\03-DeepSeek-V2-2405.04434_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2405.14333",
|
||||
@@ -116,7 +116,7 @@
|
||||
"dir": "06-形式化证明",
|
||||
"stem": "01-DeepSeek-Prover-2405.14333",
|
||||
"pdf_path": "06-形式化证明\\01-DeepSeek-Prover-2405.14333.pdf",
|
||||
"md_path": "06-形式化证明\\01-DeepSeek-Prover-2405.14333.md"
|
||||
"md_path": "06-形式化证明\\01-DeepSeek-Prover-2405.14333_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2406.11931",
|
||||
@@ -133,7 +133,7 @@
|
||||
"dir": "02-代码模型",
|
||||
"stem": "02-DeepSeek-Coder-V2-2406.11931",
|
||||
"pdf_path": "02-代码模型\\02-DeepSeek-Coder-V2-2406.11931.pdf",
|
||||
"md_path": "02-代码模型\\02-DeepSeek-Coder-V2-2406.11931.md"
|
||||
"md_path": "02-代码模型\\02-DeepSeek-Coder-V2-2406.11931_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2407.01906",
|
||||
@@ -150,7 +150,7 @@
|
||||
"dir": "08-训练方法",
|
||||
"stem": "01-ESFT-专家专精微调-2407.01906",
|
||||
"pdf_path": "08-训练方法\\01-ESFT-专家专精微调-2407.01906.pdf",
|
||||
"md_path": "08-训练方法\\01-ESFT-专家专精微调-2407.01906.md"
|
||||
"md_path": "08-训练方法\\01-ESFT-专家专精微调-2407.01906_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2408.08152",
|
||||
@@ -167,7 +167,7 @@
|
||||
"dir": "06-形式化证明",
|
||||
"stem": "02-DeepSeek-Prover-V1.5-2408.08152",
|
||||
"pdf_path": "06-形式化证明\\02-DeepSeek-Prover-V1.5-2408.08152.pdf",
|
||||
"md_path": "06-形式化证明\\02-DeepSeek-Prover-V1.5-2408.08152.md"
|
||||
"md_path": "06-形式化证明\\02-DeepSeek-Prover-V1.5-2408.08152_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2408.14158",
|
||||
@@ -184,7 +184,7 @@
|
||||
"dir": "09-基础设施",
|
||||
"stem": "01-Fire-Flyer-AI-HPC-2408.14158",
|
||||
"pdf_path": "09-基础设施\\01-Fire-Flyer-AI-HPC-2408.14158.pdf",
|
||||
"md_path": "09-基础设施\\01-Fire-Flyer-AI-HPC-2408.14158.md"
|
||||
"md_path": "09-基础设施\\01-Fire-Flyer-AI-HPC-2408.14158_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2410.13848",
|
||||
@@ -201,7 +201,7 @@
|
||||
"dir": "05-多模态",
|
||||
"stem": "02-Janus-2410.13848",
|
||||
"pdf_path": "05-多模态\\02-Janus-2410.13848.pdf",
|
||||
"md_path": "05-多模态\\02-Janus-2410.13848.md"
|
||||
"md_path": "05-多模态\\02-Janus-2410.13848_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2412.10302",
|
||||
@@ -218,7 +218,7 @@
|
||||
"dir": "05-多模态",
|
||||
"stem": "03-DeepSeek-VL2-2412.10302",
|
||||
"pdf_path": "05-多模态\\03-DeepSeek-VL2-2412.10302.pdf",
|
||||
"md_path": "05-多模态\\03-DeepSeek-VL2-2412.10302.md"
|
||||
"md_path": "05-多模态\\03-DeepSeek-VL2-2412.10302_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2412.19437",
|
||||
@@ -235,7 +235,7 @@
|
||||
"dir": "01-基础模型",
|
||||
"stem": "04-DeepSeek-V3-2412.19437",
|
||||
"pdf_path": "01-基础模型\\04-DeepSeek-V3-2412.19437.pdf",
|
||||
"md_path": "01-基础模型\\04-DeepSeek-V3-2412.19437.md"
|
||||
"md_path": "01-基础模型\\04-DeepSeek-V3-2412.19437_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2501.12948",
|
||||
@@ -252,7 +252,7 @@
|
||||
"dir": "04-推理模型",
|
||||
"stem": "01-DeepSeek-R1-2501.12948",
|
||||
"pdf_path": "04-推理模型\\01-DeepSeek-R1-2501.12948.pdf",
|
||||
"md_path": "04-推理模型\\01-DeepSeek-R1-2501.12948.md"
|
||||
"md_path": "04-推理模型\\01-DeepSeek-R1-2501.12948_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2501.17811",
|
||||
@@ -269,7 +269,7 @@
|
||||
"dir": "05-多模态",
|
||||
"stem": "04-Janus-Pro-2501.17811",
|
||||
"pdf_path": "05-多模态\\04-Janus-Pro-2501.17811.pdf",
|
||||
"md_path": "05-多模态\\04-Janus-Pro-2501.17811.md"
|
||||
"md_path": "05-多模态\\04-Janus-Pro-2501.17811_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2504.02495",
|
||||
@@ -286,7 +286,7 @@
|
||||
"dir": "08-训练方法",
|
||||
"stem": "02-DeepSeek-GRM-2504.02495",
|
||||
"pdf_path": "08-训练方法\\02-DeepSeek-GRM-2504.02495.pdf",
|
||||
"md_path": "08-训练方法\\02-DeepSeek-GRM-2504.02495.md"
|
||||
"md_path": "08-训练方法\\02-DeepSeek-GRM-2504.02495_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2504.21801",
|
||||
@@ -303,7 +303,7 @@
|
||||
"dir": "06-形式化证明",
|
||||
"stem": "03-DeepSeek-Prover-V2-2504.21801",
|
||||
"pdf_path": "06-形式化证明\\03-DeepSeek-Prover-V2-2504.21801.pdf",
|
||||
"md_path": "06-形式化证明\\03-DeepSeek-Prover-V2-2504.21801.md"
|
||||
"md_path": "06-形式化证明\\03-DeepSeek-Prover-V2-2504.21801_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2505.09343",
|
||||
@@ -320,7 +320,7 @@
|
||||
"dir": "09-基础设施",
|
||||
"stem": "02-Insights-into-DeepSeek-V3-2505.09343",
|
||||
"pdf_path": "09-基础设施\\02-Insights-into-DeepSeek-V3-2505.09343.pdf",
|
||||
"md_path": "09-基础设施\\02-Insights-into-DeepSeek-V3-2505.09343.md"
|
||||
"md_path": "09-基础设施\\02-Insights-into-DeepSeek-V3-2505.09343_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2510.18234",
|
||||
@@ -337,7 +337,7 @@
|
||||
"dir": "05-多模态",
|
||||
"stem": "05-DeepSeek-OCR-2510.18234",
|
||||
"pdf_path": "05-多模态\\05-DeepSeek-OCR-2510.18234.pdf",
|
||||
"md_path": "05-多模态\\05-DeepSeek-OCR-2510.18234.md"
|
||||
"md_path": "05-多模态\\05-DeepSeek-OCR-2510.18234_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2511.22570",
|
||||
@@ -354,7 +354,7 @@
|
||||
"dir": "03-数学模型",
|
||||
"stem": "02-DeepSeekMath-V2-2511.22570",
|
||||
"pdf_path": "03-数学模型\\02-DeepSeekMath-V2-2511.22570.pdf",
|
||||
"md_path": "03-数学模型\\02-DeepSeekMath-V2-2511.22570.md"
|
||||
"md_path": "03-数学模型\\02-DeepSeekMath-V2-2511.22570_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2512.02556",
|
||||
@@ -371,7 +371,7 @@
|
||||
"dir": "01-基础模型",
|
||||
"stem": "05-DeepSeek-V3.2-2512.02556",
|
||||
"pdf_path": "01-基础模型\\05-DeepSeek-V3.2-2512.02556.pdf",
|
||||
"md_path": "01-基础模型\\05-DeepSeek-V3.2-2512.02556.md"
|
||||
"md_path": "01-基础模型\\05-DeepSeek-V3.2-2512.02556_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2512.24880",
|
||||
@@ -388,7 +388,7 @@
|
||||
"dir": "07-架构",
|
||||
"stem": "01-mHC-2512.24880",
|
||||
"pdf_path": "07-架构\\01-mHC-2512.24880.pdf",
|
||||
"md_path": "07-架构\\01-mHC-2512.24880.md"
|
||||
"md_path": "07-架构\\01-mHC-2512.24880_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2601.07372",
|
||||
@@ -405,7 +405,7 @@
|
||||
"dir": "07-架构",
|
||||
"stem": "02-Engram-条件记忆-2601.07372",
|
||||
"pdf_path": "07-架构\\02-Engram-条件记忆-2601.07372.pdf",
|
||||
"md_path": "07-架构\\02-Engram-条件记忆-2601.07372.md"
|
||||
"md_path": "07-架构\\02-Engram-条件记忆-2601.07372_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2601.20552",
|
||||
@@ -422,7 +422,7 @@
|
||||
"dir": "05-多模态",
|
||||
"stem": "06-DeepSeek-OCR-2-2601.20552",
|
||||
"pdf_path": "05-多模态\\06-DeepSeek-OCR-2-2601.20552.pdf",
|
||||
"md_path": "05-多模态\\06-DeepSeek-OCR-2-2601.20552.md"
|
||||
"md_path": "05-多模态\\06-DeepSeek-OCR-2-2601.20552_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2602.21548",
|
||||
@@ -439,7 +439,7 @@
|
||||
"dir": "09-基础设施",
|
||||
"stem": "03-DualPath-2602.21548",
|
||||
"pdf_path": "09-基础设施\\03-DualPath-2602.21548.pdf",
|
||||
"md_path": "09-基础设施\\03-DualPath-2602.21548.md"
|
||||
"md_path": "09-基础设施\\03-DualPath-2602.21548_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2606.19348",
|
||||
@@ -456,7 +456,7 @@
|
||||
"dir": "01-基础模型",
|
||||
"stem": "06-DeepSeek-V4-2606.19348",
|
||||
"pdf_path": "01-基础模型\\06-DeepSeek-V4-2606.19348.pdf",
|
||||
"md_path": "01-基础模型\\06-DeepSeek-V4-2606.19348.md"
|
||||
"md_path": "01-基础模型\\06-DeepSeek-V4-2606.19348_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2609.19969",
|
||||
@@ -473,7 +473,7 @@
|
||||
"dir": "01-基础模型",
|
||||
"stem": "07-DeepSeek-V4.1-Flash-2609.19969",
|
||||
"pdf_path": "01-基础模型\\07-DeepSeek-V4.1-Flash-2609.19969.pdf",
|
||||
"md_path": "01-基础模型\\07-DeepSeek-V4.1-Flash-2609.19969.md"
|
||||
"md_path": "01-基础模型\\07-DeepSeek-V4.1-Flash-2609.19969_abstract.md"
|
||||
},
|
||||
{
|
||||
"id": "2310.16818",
|
||||
@@ -487,7 +487,7 @@
|
||||
"dir": "05-多模态",
|
||||
"stem": "08-DreamCraft3D-2310.16818",
|
||||
"pdf_path": "05-多模态\\08-DreamCraft3D-2310.16818.pdf",
|
||||
"md_path": "05-多模态\\08-DreamCraft3D-2310.16818.md",
|
||||
"md_path": "05-多模态\\08-DreamCraft3D-2310.16818_abstract.md",
|
||||
"pdf_url": "https://arxiv.org/pdf/2310.16818",
|
||||
"abs_url": "https://arxiv.org/abs/2310.16818"
|
||||
},
|
||||
@@ -503,7 +503,7 @@
|
||||
"dir": "07-架构",
|
||||
"stem": "04-Aux-Loss-Free-Load-Balancing-2408.15664",
|
||||
"pdf_path": "07-架构\\04-Aux-Loss-Free-Load-Balancing-2408.15664.pdf",
|
||||
"md_path": "07-架构\\04-Aux-Loss-Free-Load-Balancing-2408.15664.md",
|
||||
"md_path": "07-架构\\04-Aux-Loss-Free-Load-Balancing-2408.15664_abstract.md",
|
||||
"pdf_url": "https://arxiv.org/pdf/2408.15664",
|
||||
"abs_url": "https://arxiv.org/abs/2408.15664"
|
||||
},
|
||||
@@ -519,7 +519,7 @@
|
||||
"dir": "05-多模态",
|
||||
"stem": "07-JanusFlow-2411.07975",
|
||||
"pdf_path": "05-多模态\\07-JanusFlow-2411.07975.pdf",
|
||||
"md_path": "05-多模态\\07-JanusFlow-2411.07975.md",
|
||||
"md_path": "05-多模态\\07-JanusFlow-2411.07975_abstract.md",
|
||||
"pdf_url": "https://arxiv.org/pdf/2411.07975",
|
||||
"abs_url": "https://arxiv.org/abs/2411.07975"
|
||||
},
|
||||
@@ -535,7 +535,7 @@
|
||||
"dir": "02-代码模型",
|
||||
"stem": "03-CodeIO-2502.07316",
|
||||
"pdf_path": "02-代码模型\\03-CodeIO-2502.07316.pdf",
|
||||
"md_path": "02-代码模型\\03-CodeIO-2502.07316.md",
|
||||
"md_path": "02-代码模型\\03-CodeIO-2502.07316_abstract.md",
|
||||
"pdf_url": "https://arxiv.org/pdf/2502.07316",
|
||||
"abs_url": "https://arxiv.org/abs/2502.07316"
|
||||
},
|
||||
@@ -551,7 +551,7 @@
|
||||
"dir": "07-架构",
|
||||
"stem": "03-NSA-原生稀疏注意力-2502.11089",
|
||||
"pdf_path": "07-架构\\03-NSA-原生稀疏注意力-2502.11089.pdf",
|
||||
"md_path": "07-架构\\03-NSA-原生稀疏注意力-2502.11089.md",
|
||||
"md_path": "07-架构\\03-NSA-原生稀疏注意力-2502.11089_abstract.md",
|
||||
"pdf_url": "https://arxiv.org/pdf/2502.11089",
|
||||
"abs_url": "https://arxiv.org/abs/2502.11089"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
"""Sync plan.json md_path with the actual note filenames on disk.
|
||||
|
||||
The notes were renamed with an `_abstract` suffix to avoid page-name clashes
|
||||
with the same-named PDFs in SilverBullet. This rewrites plan.json accordingly.
|
||||
|
||||
Usage: python sync_plan_paths.py <plan.json> <base_dir>
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
plan_path, base = sys.argv[1], sys.argv[2]
|
||||
plan = json.load(open(plan_path, encoding='utf-8'))
|
||||
changed = 0
|
||||
missing = []
|
||||
for p in plan:
|
||||
d = p['dir']
|
||||
stem = p['stem']
|
||||
candidates = [
|
||||
os.path.join(d, stem + '.md'),
|
||||
os.path.join(d, stem + '_abstract.md'),
|
||||
]
|
||||
found = None
|
||||
for c in candidates:
|
||||
if os.path.exists(os.path.join(base, c)):
|
||||
found = c
|
||||
break
|
||||
if not found:
|
||||
missing.append((p['id'], stem))
|
||||
continue
|
||||
if p['md_path'] != found:
|
||||
p['md_path'] = found
|
||||
changed += 1
|
||||
|
||||
json.dump(plan, open(plan_path, 'w', encoding='utf-8'), ensure_ascii=False, indent=1)
|
||||
print('md_path 已更新:', changed, '/', len(plan))
|
||||
if missing:
|
||||
print('未找到对应 md 的论文:')
|
||||
for m in missing:
|
||||
print(' !', m)
|
||||
Reference in New Issue
Block a user