1 Star 0 Fork 0

ytianxia6/pyWolai2Obsidian

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
resolvefolderlink.py 734 Bytes
一键复制 编辑 原始数据 按行查看 历史
ytianxia6 提交于 2023-10-08 17:30 +08:00 . feat: 增加路径修正功能
import re
from pathlib import Path
import utils
from wolai import Note
# 处理文件夹链接
# 对于文件夹链接形式, 即 'XX/XX.md',校正为 'XX'
def resolve_folder_link(src: str):
root = Path(src).resolve()
for x in root.glob('**/*'):
if not x.is_file() or x.suffix.lower() != '.md':
continue
print('扫描文件 ' + str(x))
note = Note(root, x.parent.relative_to(root), x.stem, x.suffix)
for l in note.links:
match = re.match(r'(.+)\\\1\.md', l)
if match:
new_link = match.group(1)
print('替换文件 {} 中的链接 {} 为 {}'.format(x, l, new_link))
utils.replace_note_link(x, l, new_link)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/ytianxia6/pyWolai2Obsidian.git
[email protected]:ytianxia6/pyWolai2Obsidian.git
ytianxia6
pyWolai2Obsidian
pyWolai2Obsidian
main

搜索帮助