We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
./
库 |--文件夹 | |--test1.md | |--test2.md | |--test2.md
在 test1 文件中创建同目录下 test2 文件的相对链接,其结果会指向根目录的 test2。
这个问题是 ob 语法的歧义导致的,它会自动生成 […](test2),而不是 […](./test2)。于是 ob 就会把链接指向库的根目录。
[…](test2)
[…](./test2)
可否自动将非 ../ 开头的文件路径前,自动加上 ./?
../
The text was updated successfully, but these errors were encountered:
其实这不算是歧义,路径如果没有以 / 或 ../ 开头,默认就应该是相对当前路径的,加不加 ./ 效果都应该是一样的。严格来说,应该是 Obsidian 解析相对路径的逻辑有问题。
/
所以要真正解决这个问题,最好给 Obsidian 提个 Issue,让 Obsidian 在解析路径时,如果开启了 Relative path to file 选项,就优先从相对路径查找文件,而不是从根目录查找。
Relative path to file
如果在这个插件里解决的话,只能保证所有被此插件处理的路径都包含了 ./。但大部分链接都是通过 Obsidian 插入或修改的,还是没有 ./。最终只能解决很小一部分问题,还会导致有的链接带 ./,有的没带,看起来很混乱。
如果想临时解决这个问题,可以找找或自己写个插件,修改 Obsidian 插入的链接,默认都包含 ./。
然后再找到 .obsidian/plugins/update-relative-links/main.js 这个文件,在 stackToPath 函数第一行添加 if (stack.length === 1) stack.unshift("."),修改后的代码:
.obsidian/plugins/update-relative-links/main.js
stackToPath
if (stack.length === 1) stack.unshift(".")
function stackToPath(stack) { if (stack.length === 1) stack.unshift("."); return stack.join(SEP); }
经过测试可以解决这个问题。
一般根目录下也不会有太多文件,这个问题其实影响不是很大,改了反倒有上面说的一些问题。所以这个改动就不提交了,有需要的话自己改下吧。
Sorry, something went wrong.
收到,谢谢大佬!
No branches or pull requests
在 test1 文件中创建同目录下 test2 文件的相对链接,其结果会指向根目录的 test2。
这个问题是 ob 语法的歧义导致的,它会自动生成
[…](test2)
,而不是[…](./test2)
。于是 ob 就会把链接指向库的根目录。可否自动将非
../
开头的文件路径前,自动加上./
?The text was updated successfully, but these errors were encountered: